From 2c029fd0cb1ca710c74363b4a3f359577dcc51cf Mon Sep 17 00:00:00 2001 From: Green Baneling Date: Wed, 11 Jan 2023 13:22:22 +0000 Subject: [PATCH 01/80] Allow duplicate topics in smart contract events (#13065) * Removed `has_duplicates` check form the `deposit_event`. Removed the usage of `Error::DuplicateTopics`. * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts Co-authored-by: command-bot <> --- frame/contracts/src/lib.rs | 2 - frame/contracts/src/wasm/mod.rs | 56 +- frame/contracts/src/wasm/runtime.rs | 18 +- frame/contracts/src/weights.rs | 1874 ++++++++++++++------------- 4 files changed, 972 insertions(+), 978 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 9df790e09a..9efeec65f5 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -816,8 +816,6 @@ pub mod pallet { RandomSubjectTooLong, /// The amount of topics passed to `seal_deposit_events` exceeds the limit. TooManyTopics, - /// The topics passed to `seal_deposit_events` contains at least one duplicate. - DuplicateTopics, /// The chain does not provide a chain extension. Calling the chain extension results /// in this error. Note that this usually shouldn't happen as deploying such contracts /// is rejected. diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index f1d0ccc7c2..b540b3deb4 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -1988,7 +1988,7 @@ mod tests { assert!(mock_ext.gas_meter.gas_left().ref_time() > 0); } - const CODE_DEPOSIT_EVENT_MAX_TOPICS: &str = r#" + const CODE_DEPOSIT_EVENT_DUPLICATES: &str = r#" (module (import "seal0" "seal_deposit_event" (func $seal_deposit_event (param i32 i32 i32 i32))) (import "env" "memory" (memory 1 1)) @@ -1996,7 +1996,7 @@ mod tests { (func (export "call") (call $seal_deposit_event (i32.const 32) ;; Pointer to the start of topics buffer - (i32.const 161) ;; The length of the topics buffer. + (i32.const 129) ;; The length of the topics buffer. (i32.const 8) ;; Pointer to the start of the data buffer (i32.const 13) ;; Length of the buffer ) @@ -2005,29 +2005,36 @@ mod tests { (data (i32.const 8) "\00\01\2A\00\00\00\00\00\00\00\E5\14\00") - ;; Encoded Vec>, the buffer has length of 161 bytes. - (data (i32.const 32) "\14" + ;; Encoded Vec>, the buffer has length of 129 bytes. + (data (i32.const 32) "\10" "\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01" "\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02" -"\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03" -"\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04" -"\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05") +"\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01" +"\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04") ) "#; - /// Checks that the runtime traps if there are more than `max_topic_events` topics. + /// Checks that the runtime allows duplicate topics. #[test] - fn deposit_event_max_topics() { + fn deposit_event_duplicates_allowed() { + let mut mock_ext = MockExt::default(); + assert_ok!(execute(CODE_DEPOSIT_EVENT_DUPLICATES, vec![], &mut mock_ext,)); + assert_eq!( - execute(CODE_DEPOSIT_EVENT_MAX_TOPICS, vec![], MockExt::default(),), - Err(ExecError { - error: Error::::TooManyTopics.into(), - origin: ErrorOrigin::Caller, - }) + mock_ext.events, + vec![( + vec![ + H256::repeat_byte(0x01), + H256::repeat_byte(0x02), + H256::repeat_byte(0x01), + H256::repeat_byte(0x04) + ], + vec![0x00, 0x01, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x14, 0x00] + )] ); } - const CODE_DEPOSIT_EVENT_DUPLICATES: &str = r#" + const CODE_DEPOSIT_EVENT_MAX_TOPICS: &str = r#" (module (import "seal0" "seal_deposit_event" (func $seal_deposit_event (param i32 i32 i32 i32))) (import "env" "memory" (memory 1 1)) @@ -2035,7 +2042,7 @@ mod tests { (func (export "call") (call $seal_deposit_event (i32.const 32) ;; Pointer to the start of topics buffer - (i32.const 129) ;; The length of the topics buffer. + (i32.const 161) ;; The length of the topics buffer. (i32.const 8) ;; Pointer to the start of the data buffer (i32.const 13) ;; Length of the buffer ) @@ -2044,22 +2051,23 @@ mod tests { (data (i32.const 8) "\00\01\2A\00\00\00\00\00\00\00\E5\14\00") - ;; Encoded Vec>, the buffer has length of 129 bytes. - (data (i32.const 32) "\10" + ;; Encoded Vec>, the buffer has length of 161 bytes. + (data (i32.const 32) "\14" "\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01" "\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02\02" -"\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01\01" -"\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04") +"\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03\03" +"\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04\04" +"\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05\05") ) "#; - /// Checks that the runtime traps if there are duplicates. + /// Checks that the runtime traps if there are more than `max_topic_events` topics. #[test] - fn deposit_event_duplicates() { + fn deposit_event_max_topics() { assert_eq!( - execute(CODE_DEPOSIT_EVENT_DUPLICATES, vec![], MockExt::default(),), + execute(CODE_DEPOSIT_EVENT_MAX_TOPICS, vec![], MockExt::default(),), Err(ExecError { - error: Error::::DuplicateTopics.into(), + error: Error::::TooManyTopics.into(), origin: ErrorOrigin::Caller, }) ); diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 098f8d280e..b5398bb620 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2085,15 +2085,6 @@ pub mod env { data_ptr: u32, data_len: u32, ) -> Result<(), TrapReason> { - fn has_duplicates(items: &mut Vec) -> bool { - items.sort(); - // Find any two consecutive equal elements. - items.windows(2).any(|w| match &w { - &[a, b] => a == b, - _ => false, - }) - } - let num_topic = topics_len .checked_div(sp_std::mem::size_of::>() as u32) .ok_or("Zero sized topics are not allowed")?; @@ -2102,7 +2093,7 @@ pub mod env { return Err(Error::::ValueTooLarge.into()) } - let mut topics: Vec::T>> = match topics_len { + let topics: Vec::T>> = match topics_len { 0 => Vec::new(), _ => ctx.read_sandbox_memory_as_unbounded(memory, topics_ptr, topics_len)?, }; @@ -2112,13 +2103,6 @@ pub mod env { return Err(Error::::TooManyTopics.into()) } - // Check for duplicate topics. If there are any, then trap. - // Complexity O(n * log(n)) and no additional allocations. - // This also sorts the topics. - if has_duplicates(&mut topics) { - return Err(Error::::DuplicateTopics.into()) - } - let event_data = ctx.read_sandbox_memory(memory, data_ptr, data_len)?; ctx.ext.deposit_event(topics, event_data); diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 69fcbd6eec..7ae1a9c594 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -172,17 +172,17 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_process_deletion_queue_batch() -> Weight { - // Minimum execution time: 3_196 nanoseconds. - Weight::from_ref_time(3_293_000) + // Minimum execution time: 3_326 nanoseconds. + Weight::from_ref_time(3_433_000) .saturating_add(T::DbWeight::get().reads(1)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - // Minimum execution time: 14_857 nanoseconds. - Weight::from_ref_time(14_957_593) - // Standard Error: 1_015 - .saturating_add(Weight::from_ref_time(935_359).saturating_mul(k.into())) + // Minimum execution time: 15_703 nanoseconds. + Weight::from_ref_time(15_288_927) + // Standard Error: 951 + .saturating_add(Weight::from_ref_time(940_816).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -190,10 +190,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts DeletionQueue (r:1 w:0) /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - // Minimum execution time: 3_231 nanoseconds. - Weight::from_ref_time(14_859_580) - // Standard Error: 3_479 - .saturating_add(Weight::from_ref_time(1_185_600).saturating_mul(q.into())) + // Minimum execution time: 3_548 nanoseconds. + Weight::from_ref_time(15_764_121) + // Standard Error: 3_339 + .saturating_add(Weight::from_ref_time(1_214_890).saturating_mul(q.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -201,10 +201,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn reinstrument(c: u32, ) -> Weight { - // Minimum execution time: 34_565 nanoseconds. - Weight::from_ref_time(29_199_016) - // Standard Error: 70 - .saturating_add(Weight::from_ref_time(47_107).saturating_mul(c.into())) + // Minimum execution time: 29_801 nanoseconds. + Weight::from_ref_time(27_932_706) + // Standard Error: 49 + .saturating_add(Weight::from_ref_time(50_532).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -215,10 +215,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `c` is `[0, 131072]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - // Minimum execution time: 392_074 nanoseconds. - Weight::from_ref_time(404_090_909) - // Standard Error: 24 - .saturating_add(Weight::from_ref_time(30_454).saturating_mul(c.into())) + // Minimum execution time: 307_894 nanoseconds. + Weight::from_ref_time(322_346_319) + // Standard Error: 25 + .saturating_add(Weight::from_ref_time(30_678).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -234,14 +234,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 3_785_934 nanoseconds. - Weight::from_ref_time(683_143_843) - // Standard Error: 272 - .saturating_add(Weight::from_ref_time(87_620).saturating_mul(c.into())) + // Minimum execution time: 3_610_424 nanoseconds. + Weight::from_ref_time(583_426_386) + // Standard Error: 277 + .saturating_add(Weight::from_ref_time(90_224).saturating_mul(c.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_363).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_325).saturating_mul(i.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_778).saturating_mul(s.into())) + .saturating_add(Weight::from_ref_time(1_727).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(9)) } @@ -255,12 +255,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { - // Minimum execution time: 1_935_310 nanoseconds. - Weight::from_ref_time(203_531_122) + // Minimum execution time: 1_892_996 nanoseconds. + Weight::from_ref_time(202_958_196) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_674).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_627).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_789).saturating_mul(s.into())) + .saturating_add(Weight::from_ref_time(1_755).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -270,8 +270,8 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: System EventTopics (r:2 w:2) fn call() -> Weight { - // Minimum execution time: 151_999 nanoseconds. - Weight::from_ref_time(153_527_000) + // Minimum execution time: 157_347 nanoseconds. + Weight::from_ref_time(159_084_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -281,10 +281,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn upload_code(c: u32, ) -> Weight { - // Minimum execution time: 391_165 nanoseconds. - Weight::from_ref_time(394_519_487) - // Standard Error: 75 - .saturating_add(Weight::from_ref_time(89_736).saturating_mul(c.into())) + // Minimum execution time: 299_987 nanoseconds. + Weight::from_ref_time(305_274_879) + // Standard Error: 72 + .saturating_add(Weight::from_ref_time(91_916).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -293,8 +293,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts CodeStorage (r:0 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn remove_code() -> Weight { - // Minimum execution time: 39_354 nanoseconds. - Weight::from_ref_time(39_855_000) + // Minimum execution time: 40_795 nanoseconds. + Weight::from_ref_time(41_297_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -302,8 +302,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:2 w:2) // Storage: System EventTopics (r:3 w:3) fn set_code() -> Weight { - // Minimum execution time: 40_909 nanoseconds. - Weight::from_ref_time(41_275_000) + // Minimum execution time: 41_957 nanoseconds. + Weight::from_ref_time(42_536_000) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(6)) } @@ -314,10 +314,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - // Minimum execution time: 380_150 nanoseconds. - Weight::from_ref_time(384_429_035) - // Standard Error: 34_740 - .saturating_add(Weight::from_ref_time(15_582_218).saturating_mul(r.into())) + // Minimum execution time: 293_544 nanoseconds. + Weight::from_ref_time(298_981_222) + // Standard Error: 39_139 + .saturating_add(Weight::from_ref_time(17_278_436).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -328,10 +328,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - // Minimum execution time: 380_608 nanoseconds. - Weight::from_ref_time(326_544_805) - // Standard Error: 475_381 - .saturating_add(Weight::from_ref_time(190_717_772).saturating_mul(r.into())) + // Minimum execution time: 293_500 nanoseconds. + Weight::from_ref_time(237_825_284) + // Standard Error: 450_234 + .saturating_add(Weight::from_ref_time(198_995_806).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -343,10 +343,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 382_780 nanoseconds. - Weight::from_ref_time(333_775_113) - // Standard Error: 446_086 - .saturating_add(Weight::from_ref_time(232_531_042).saturating_mul(r.into())) + // Minimum execution time: 295_851 nanoseconds. + Weight::from_ref_time(258_113_447) + // Standard Error: 408_747 + .saturating_add(Weight::from_ref_time(237_490_216).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -358,10 +358,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 381_815 nanoseconds. - Weight::from_ref_time(390_931_793) - // Standard Error: 61_918 - .saturating_add(Weight::from_ref_time(18_798_438).saturating_mul(r.into())) + // Minimum execution time: 294_614 nanoseconds. + Weight::from_ref_time(301_528_998) + // Standard Error: 40_613 + .saturating_add(Weight::from_ref_time(20_815_088).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -372,10 +372,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - // Minimum execution time: 379_162 nanoseconds. - Weight::from_ref_time(383_796_363) - // Standard Error: 25_555 - .saturating_add(Weight::from_ref_time(10_843_721).saturating_mul(r.into())) + // Minimum execution time: 293_088 nanoseconds. + Weight::from_ref_time(299_120_595) + // Standard Error: 23_277 + .saturating_add(Weight::from_ref_time(11_130_334).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -386,10 +386,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - // Minimum execution time: 380_307 nanoseconds. - Weight::from_ref_time(390_211_779) - // Standard Error: 53_326 - .saturating_add(Weight::from_ref_time(15_311_171).saturating_mul(r.into())) + // Minimum execution time: 295_110 nanoseconds. + Weight::from_ref_time(305_295_787) + // Standard Error: 48_521 + .saturating_add(Weight::from_ref_time(16_610_806).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -400,10 +400,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - // Minimum execution time: 380_230 nanoseconds. - Weight::from_ref_time(383_470_453) - // Standard Error: 45_007 - .saturating_add(Weight::from_ref_time(15_582_472).saturating_mul(r.into())) + // Minimum execution time: 293_414 nanoseconds. + Weight::from_ref_time(299_960_283) + // Standard Error: 32_003 + .saturating_add(Weight::from_ref_time(16_652_433).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -414,10 +414,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - // Minimum execution time: 380_244 nanoseconds. - Weight::from_ref_time(388_092_461) - // Standard Error: 98_199 - .saturating_add(Weight::from_ref_time(97_339_528).saturating_mul(r.into())) + // Minimum execution time: 292_429 nanoseconds. + Weight::from_ref_time(301_025_128) + // Standard Error: 92_155 + .saturating_add(Weight::from_ref_time(92_731_719).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -428,10 +428,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - // Minimum execution time: 380_242 nanoseconds. - Weight::from_ref_time(384_078_258) - // Standard Error: 28_510 - .saturating_add(Weight::from_ref_time(15_423_359).saturating_mul(r.into())) + // Minimum execution time: 293_516 nanoseconds. + Weight::from_ref_time(300_071_428) + // Standard Error: 25_871 + .saturating_add(Weight::from_ref_time(16_599_369).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -442,10 +442,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - // Minimum execution time: 379_890 nanoseconds. - Weight::from_ref_time(383_658_430) - // Standard Error: 44_976 - .saturating_add(Weight::from_ref_time(15_451_905).saturating_mul(r.into())) + // Minimum execution time: 293_666 nanoseconds. + Weight::from_ref_time(299_803_599) + // Standard Error: 24_508 + .saturating_add(Weight::from_ref_time(16_500_973).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -456,10 +456,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - // Minimum execution time: 380_269 nanoseconds. - Weight::from_ref_time(383_580_481) - // Standard Error: 31_862 - .saturating_add(Weight::from_ref_time(15_230_473).saturating_mul(r.into())) + // Minimum execution time: 289_193 nanoseconds. + Weight::from_ref_time(297_946_784) + // Standard Error: 43_719 + .saturating_add(Weight::from_ref_time(16_442_254).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -470,10 +470,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - // Minimum execution time: 380_308 nanoseconds. - Weight::from_ref_time(383_732_372) - // Standard Error: 38_359 - .saturating_add(Weight::from_ref_time(15_358_775).saturating_mul(r.into())) + // Minimum execution time: 288_897 nanoseconds. + Weight::from_ref_time(298_856_658) + // Standard Error: 31_003 + .saturating_add(Weight::from_ref_time(16_490_508).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -485,10 +485,10 @@ impl WeightInfo for SubstrateWeight { // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - // Minimum execution time: 380_834 nanoseconds. - Weight::from_ref_time(388_999_459) - // Standard Error: 96_447 - .saturating_add(Weight::from_ref_time(86_714_414).saturating_mul(r.into())) + // Minimum execution time: 289_850 nanoseconds. + Weight::from_ref_time(302_898_449) + // Standard Error: 92_822 + .saturating_add(Weight::from_ref_time(86_376_874).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -499,10 +499,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - // Minimum execution time: 140_955 nanoseconds. - Weight::from_ref_time(144_716_423) - // Standard Error: 11_370 - .saturating_add(Weight::from_ref_time(7_858_807).saturating_mul(r.into())) + // Minimum execution time: 145_105 nanoseconds. + Weight::from_ref_time(152_388_934) + // Standard Error: 29_988 + .saturating_add(Weight::from_ref_time(7_761_947).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -513,10 +513,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - // Minimum execution time: 380_210 nanoseconds. - Weight::from_ref_time(384_185_776) - // Standard Error: 49_038 - .saturating_add(Weight::from_ref_time(13_649_793).saturating_mul(r.into())) + // Minimum execution time: 289_319 nanoseconds. + Weight::from_ref_time(298_390_911) + // Standard Error: 27_329 + .saturating_add(Weight::from_ref_time(14_225_527).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -527,10 +527,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 396_209 nanoseconds. - Weight::from_ref_time(424_522_611) - // Standard Error: 3_917 - .saturating_add(Weight::from_ref_time(9_627_216).saturating_mul(n.into())) + // Minimum execution time: 305_538 nanoseconds. + Weight::from_ref_time(339_734_596) + // Standard Error: 4_636 + .saturating_add(Weight::from_ref_time(9_592_149).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -541,10 +541,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { - // Minimum execution time: 378_412 nanoseconds. - Weight::from_ref_time(380_502_085) - // Standard Error: 201_552 - .saturating_add(Weight::from_ref_time(1_434_214).saturating_mul(r.into())) + // Minimum execution time: 287_189 nanoseconds. + Weight::from_ref_time(295_472_383) + // Standard Error: 314_142 + .saturating_add(Weight::from_ref_time(214_016).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -555,10 +555,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 381_463 nanoseconds. - Weight::from_ref_time(383_955_553) - // Standard Error: 998 - .saturating_add(Weight::from_ref_time(230_512).saturating_mul(n.into())) + // Minimum execution time: 289_380 nanoseconds. + Weight::from_ref_time(296_302_404) + // Standard Error: 889 + .saturating_add(Weight::from_ref_time(190_017).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -571,10 +571,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - // Minimum execution time: 379_877 nanoseconds. - Weight::from_ref_time(381_729_546) - // Standard Error: 214_004 - .saturating_add(Weight::from_ref_time(52_528_353).saturating_mul(r.into())) + // Minimum execution time: 292_383 nanoseconds. + Weight::from_ref_time(297_557_691) + // Standard Error: 251_228 + .saturating_add(Weight::from_ref_time(56_688_008).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -588,10 +588,10 @@ impl WeightInfo for SubstrateWeight { // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - // Minimum execution time: 380_275 nanoseconds. - Weight::from_ref_time(386_495_777) - // Standard Error: 94_674 - .saturating_add(Weight::from_ref_time(108_432_929).saturating_mul(r.into())) + // Minimum execution time: 293_019 nanoseconds. + Weight::from_ref_time(301_747_439) + // Standard Error: 92_043 + .saturating_add(Weight::from_ref_time(109_861_144).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -602,10 +602,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - // Minimum execution time: 379_095 nanoseconds. - Weight::from_ref_time(393_997_924) - // Standard Error: 141_916 - .saturating_add(Weight::from_ref_time(212_937_170).saturating_mul(r.into())) + // Minimum execution time: 287_586 nanoseconds. + Weight::from_ref_time(304_751_302) + // Standard Error: 127_698 + .saturating_add(Weight::from_ref_time(221_525_053).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -617,12 +617,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - // Minimum execution time: 1_241_001 nanoseconds. - Weight::from_ref_time(548_526_917) - // Standard Error: 496_807 - .saturating_add(Weight::from_ref_time(177_087_769).saturating_mul(t.into())) - // Standard Error: 136_447 - .saturating_add(Weight::from_ref_time(71_558_402).saturating_mul(n.into())) + // Minimum execution time: 1_182_204 nanoseconds. + Weight::from_ref_time(508_607_957) + // Standard Error: 503_533 + .saturating_add(Weight::from_ref_time(173_998_655).saturating_mul(t.into())) + // Standard Error: 138_294 + .saturating_add(Weight::from_ref_time(67_991_373).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -635,20 +635,20 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - // Minimum execution time: 159_158 nanoseconds. - Weight::from_ref_time(163_427_712) - // Standard Error: 22_442 - .saturating_add(Weight::from_ref_time(12_647_838).saturating_mul(r.into())) + // Minimum execution time: 157_706 nanoseconds. + Weight::from_ref_time(161_895_583) + // Standard Error: 14_952 + .saturating_add(Weight::from_ref_time(12_990_237).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_068 nanoseconds. - Weight::from_ref_time(341_041_230) - // Standard Error: 464_053 - .saturating_add(Weight::from_ref_time(402_677_314).saturating_mul(r.into())) + // Minimum execution time: 290_063 nanoseconds. + Weight::from_ref_time(256_404_853) + // Standard Error: 436_195 + .saturating_add(Weight::from_ref_time(406_569_743).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -657,10 +657,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - // Minimum execution time: 508_695 nanoseconds. - Weight::from_ref_time(663_159_695) - // Standard Error: 1_419_342 - .saturating_add(Weight::from_ref_time(96_558_570).saturating_mul(n.into())) + // Minimum execution time: 426_295 nanoseconds. + Weight::from_ref_time(582_989_911) + // Standard Error: 1_404_141 + .saturating_add(Weight::from_ref_time(89_545_963).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(52)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(50)) @@ -669,10 +669,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - // Minimum execution time: 508_542 nanoseconds. - Weight::from_ref_time(634_146_978) - // Standard Error: 1_168_252 - .saturating_add(Weight::from_ref_time(64_231_947).saturating_mul(n.into())) + // Minimum execution time: 425_062 nanoseconds. + Weight::from_ref_time(552_380_900) + // Standard Error: 1_140_169 + .saturating_add(Weight::from_ref_time(64_085_108).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(49)) @@ -681,10 +681,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_743 nanoseconds. - Weight::from_ref_time(337_309_674) - // Standard Error: 527_407 - .saturating_add(Weight::from_ref_time(395_767_068).saturating_mul(r.into())) + // Minimum execution time: 294_421 nanoseconds. + Weight::from_ref_time(260_897_072) + // Standard Error: 474_135 + .saturating_add(Weight::from_ref_time(403_191_862).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -693,10 +693,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 478_283 nanoseconds. - Weight::from_ref_time(616_673_245) - // Standard Error: 1_290_784 - .saturating_add(Weight::from_ref_time(66_534_552).saturating_mul(n.into())) + // Minimum execution time: 391_743 nanoseconds. + Weight::from_ref_time(535_327_545) + // Standard Error: 1_297_157 + .saturating_add(Weight::from_ref_time(67_222_981).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(48)) @@ -705,10 +705,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_916 nanoseconds. - Weight::from_ref_time(349_150_912) - // Standard Error: 443_388 - .saturating_add(Weight::from_ref_time(316_975_558).saturating_mul(r.into())) + // Minimum execution time: 294_947 nanoseconds. + Weight::from_ref_time(266_280_887) + // Standard Error: 382_477 + .saturating_add(Weight::from_ref_time(323_306_898).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -716,10 +716,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 459_294 nanoseconds. - Weight::from_ref_time(579_698_524) - // Standard Error: 1_111_681 - .saturating_add(Weight::from_ref_time(159_276_087).saturating_mul(n.into())) + // Minimum execution time: 375_487 nanoseconds. + Weight::from_ref_time(497_019_365) + // Standard Error: 1_141_672 + .saturating_add(Weight::from_ref_time(152_354_482).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -727,10 +727,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_700 nanoseconds. - Weight::from_ref_time(352_544_675) - // Standard Error: 401_504 - .saturating_add(Weight::from_ref_time(304_380_106).saturating_mul(r.into())) + // Minimum execution time: 294_716 nanoseconds. + Weight::from_ref_time(266_187_186) + // Standard Error: 395_323 + .saturating_add(Weight::from_ref_time(309_907_221).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -738,10 +738,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 455_595 nanoseconds. - Weight::from_ref_time(560_428_166) - // Standard Error: 991_088 - .saturating_add(Weight::from_ref_time(61_810_610).saturating_mul(n.into())) + // Minimum execution time: 371_667 nanoseconds. + Weight::from_ref_time(478_075_482) + // Standard Error: 979_116 + .saturating_add(Weight::from_ref_time(62_075_707).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -749,10 +749,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - // Minimum execution time: 382_000 nanoseconds. - Weight::from_ref_time(336_164_219) - // Standard Error: 601_744 - .saturating_add(Weight::from_ref_time(406_198_079).saturating_mul(r.into())) + // Minimum execution time: 292_147 nanoseconds. + Weight::from_ref_time(254_374_598) + // Standard Error: 442_367 + .saturating_add(Weight::from_ref_time(413_674_705).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -761,10 +761,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 482_335 nanoseconds. - Weight::from_ref_time(634_245_177) - // Standard Error: 1_418_845 - .saturating_add(Weight::from_ref_time(164_352_113).saturating_mul(n.into())) + // Minimum execution time: 398_554 nanoseconds. + Weight::from_ref_time(553_715_911) + // Standard Error: 1_415_272 + .saturating_add(Weight::from_ref_time(158_254_544).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(51)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(48)) @@ -777,10 +777,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - // Minimum execution time: 382_142 nanoseconds. - Weight::from_ref_time(317_581_708) - // Standard Error: 682_156 - .saturating_add(Weight::from_ref_time(1_305_289_569).saturating_mul(r.into())) + // Minimum execution time: 295_081 nanoseconds. + Weight::from_ref_time(253_461_581) + // Standard Error: 740_198 + .saturating_add(Weight::from_ref_time(1_369_153_623).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(4)) @@ -793,10 +793,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { - // Minimum execution time: 383_580 nanoseconds. - Weight::from_ref_time(384_176_000) - // Standard Error: 6_483_482 - .saturating_add(Weight::from_ref_time(28_047_685_517).saturating_mul(r.into())) + // Minimum execution time: 296_089 nanoseconds. + Weight::from_ref_time(297_193_000) + // Standard Error: 6_571_547 + .saturating_add(Weight::from_ref_time(21_080_280_397).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().reads((160_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -809,10 +809,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { - // Minimum execution time: 384_523 nanoseconds. - Weight::from_ref_time(385_105_000) - // Standard Error: 6_156_142 - .saturating_add(Weight::from_ref_time(27_780_652_513).saturating_mul(r.into())) + // Minimum execution time: 296_828 nanoseconds. + Weight::from_ref_time(297_685_000) + // Standard Error: 6_864_880 + .saturating_add(Weight::from_ref_time(20_770_321_946).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((150_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -826,12 +826,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - // Minimum execution time: 9_509_961 nanoseconds. - Weight::from_ref_time(8_509_991_348) - // Standard Error: 6_614_757 - .saturating_add(Weight::from_ref_time(1_244_514_376).saturating_mul(t.into())) - // Standard Error: 9_918 - .saturating_add(Weight::from_ref_time(9_856_517).saturating_mul(c.into())) + // Minimum execution time: 9_824_671 nanoseconds. + Weight::from_ref_time(8_713_861_450) + // Standard Error: 7_388_925 + .saturating_add(Weight::from_ref_time(1_327_819_806).saturating_mul(t.into())) + // Standard Error: 11_079 + .saturating_add(Weight::from_ref_time(9_789_514).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(167)) .saturating_add(T::DbWeight::get().reads((81_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(163)) @@ -846,10 +846,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:80 w:80) /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { - // Minimum execution time: 384_604 nanoseconds. - Weight::from_ref_time(385_278_000) - // Standard Error: 21_140_468 - .saturating_add(Weight::from_ref_time(33_100_726_150).saturating_mul(r.into())) + // Minimum execution time: 293_374 nanoseconds. + Weight::from_ref_time(302_067_000) + // Standard Error: 20_137_097 + .saturating_add(Weight::from_ref_time(26_444_812_817).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().reads((400_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(5)) @@ -866,12 +866,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 960]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 129_699_480 nanoseconds. - Weight::from_ref_time(10_187_699_005) - // Standard Error: 155_040 - .saturating_add(Weight::from_ref_time(125_284_310).saturating_mul(i.into())) - // Standard Error: 155_040 - .saturating_add(Weight::from_ref_time(125_850_564).saturating_mul(s.into())) + // Minimum execution time: 126_456_770 nanoseconds. + Weight::from_ref_time(9_223_715_752) + // Standard Error: 96_040_318 + .saturating_add(Weight::from_ref_time(19_550_519).saturating_mul(t.into())) + // Standard Error: 156_614 + .saturating_add(Weight::from_ref_time(122_958_298).saturating_mul(i.into())) + // Standard Error: 156_614 + .saturating_add(Weight::from_ref_time(123_316_079).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(249)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(T::DbWeight::get().writes(247)) @@ -884,10 +886,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - // Minimum execution time: 380_397 nanoseconds. - Weight::from_ref_time(382_881_855) - // Standard Error: 290_948 - .saturating_add(Weight::from_ref_time(41_017_644).saturating_mul(r.into())) + // Minimum execution time: 289_275 nanoseconds. + Weight::from_ref_time(297_803_961) + // Standard Error: 303_405 + .saturating_add(Weight::from_ref_time(40_800_138).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -898,10 +900,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 422_439 nanoseconds. - Weight::from_ref_time(423_480_000) - // Standard Error: 56_072 - .saturating_add(Weight::from_ref_time(329_103_825).saturating_mul(n.into())) + // Minimum execution time: 336_077 nanoseconds. + Weight::from_ref_time(336_846_000) + // Standard Error: 51_610 + .saturating_add(Weight::from_ref_time(322_208_787).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -912,10 +914,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - // Minimum execution time: 380_433 nanoseconds. - Weight::from_ref_time(382_325_624) - // Standard Error: 139_248 - .saturating_add(Weight::from_ref_time(53_159_175).saturating_mul(r.into())) + // Minimum execution time: 290_189 nanoseconds. + Weight::from_ref_time(298_454_259) + // Standard Error: 252_946 + .saturating_add(Weight::from_ref_time(55_034_240).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -926,10 +928,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 434_834 nanoseconds. - Weight::from_ref_time(435_383_000) - // Standard Error: 59_824 - .saturating_add(Weight::from_ref_time(251_297_967).saturating_mul(n.into())) + // Minimum execution time: 350_030 nanoseconds. + Weight::from_ref_time(351_356_000) + // Standard Error: 57_422 + .saturating_add(Weight::from_ref_time(256_912_844).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -940,10 +942,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - // Minimum execution time: 379_088 nanoseconds. - Weight::from_ref_time(381_627_077) - // Standard Error: 152_561 - .saturating_add(Weight::from_ref_time(31_696_922).saturating_mul(r.into())) + // Minimum execution time: 288_480 nanoseconds. + Weight::from_ref_time(297_613_263) + // Standard Error: 456_736 + .saturating_add(Weight::from_ref_time(38_100_936).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -954,10 +956,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 411_630 nanoseconds. - Weight::from_ref_time(412_354_000) - // Standard Error: 50_788 - .saturating_add(Weight::from_ref_time(103_105_715).saturating_mul(n.into())) + // Minimum execution time: 321_195 nanoseconds. + Weight::from_ref_time(325_561_000) + // Standard Error: 46_289 + .saturating_add(Weight::from_ref_time(99_536_902).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -968,10 +970,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - // Minimum execution time: 379_549 nanoseconds. - Weight::from_ref_time(382_406_346) - // Standard Error: 701_449 - .saturating_add(Weight::from_ref_time(31_066_353).saturating_mul(r.into())) + // Minimum execution time: 287_659 nanoseconds. + Weight::from_ref_time(295_963_340) + // Standard Error: 433_889 + .saturating_add(Weight::from_ref_time(30_251_859).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -982,10 +984,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 412_112 nanoseconds. - Weight::from_ref_time(412_710_000) - // Standard Error: 54_875 - .saturating_add(Weight::from_ref_time(103_169_035).saturating_mul(n.into())) + // Minimum execution time: 324_298 nanoseconds. + Weight::from_ref_time(325_738_000) + // Standard Error: 48_563 + .saturating_add(Weight::from_ref_time(99_479_838).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -996,10 +998,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - // Minimum execution time: 381_994 nanoseconds. - Weight::from_ref_time(383_832_551) - // Standard Error: 676_656 - .saturating_add(Weight::from_ref_time(3_020_035_748).saturating_mul(r.into())) + // Minimum execution time: 294_257 nanoseconds. + Weight::from_ref_time(299_467_620) + // Standard Error: 589_749 + .saturating_add(Weight::from_ref_time(3_015_389_579).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -1010,10 +1012,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - // Minimum execution time: 381_472 nanoseconds. - Weight::from_ref_time(383_590_834) - // Standard Error: 538_574 - .saturating_add(Weight::from_ref_time(2_077_926_265).saturating_mul(r.into())) + // Minimum execution time: 289_480 nanoseconds. + Weight::from_ref_time(298_762_412) + // Standard Error: 397_004 + .saturating_add(Weight::from_ref_time(743_937_087).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -1025,10 +1027,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts OwnerInfoOf (r:16 w:16) /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 381_527 nanoseconds. - Weight::from_ref_time(382_291_000) - // Standard Error: 2_760_840 - .saturating_add(Weight::from_ref_time(1_356_115_009).saturating_mul(r.into())) + // Minimum execution time: 293_494 nanoseconds. + Weight::from_ref_time(297_756_000) + // Standard Error: 2_731_227 + .saturating_add(Weight::from_ref_time(1_387_380_436).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().reads((225_u64).saturating_mul(r.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -1041,10 +1043,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 382_722 nanoseconds. - Weight::from_ref_time(387_231_409) - // Standard Error: 28_817 - .saturating_add(Weight::from_ref_time(11_349_809).saturating_mul(r.into())) + // Minimum execution time: 295_339 nanoseconds. + Weight::from_ref_time(301_577_907) + // Standard Error: 23_836 + .saturating_add(Weight::from_ref_time(10_876_508).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -1055,10 +1057,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 383_568 nanoseconds. - Weight::from_ref_time(419_835_108) - // Standard Error: 125_982 - .saturating_add(Weight::from_ref_time(25_241_800).saturating_mul(r.into())) + // Minimum execution time: 297_096 nanoseconds. + Weight::from_ref_time(336_319_823) + // Standard Error: 128_941 + .saturating_add(Weight::from_ref_time(25_211_374).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -1070,376 +1072,376 @@ impl WeightInfo for SubstrateWeight { // Storage: Contracts Nonce (r:1 w:1) /// The range of component `r` is `[0, 20]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { - // Minimum execution time: 382_084 nanoseconds. - Weight::from_ref_time(388_155_568) - // Standard Error: 29_161 - .saturating_add(Weight::from_ref_time(9_015_217).saturating_mul(r.into())) + // Minimum execution time: 293_819 nanoseconds. + Weight::from_ref_time(302_765_659) + // Standard Error: 28_518 + .saturating_add(Weight::from_ref_time(9_325_552).saturating_mul(r.into())) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - // Minimum execution time: 593 nanoseconds. - Weight::from_ref_time(816_706) - // Standard Error: 173 - .saturating_add(Weight::from_ref_time(344_732).saturating_mul(r.into())) + // Minimum execution time: 805 nanoseconds. + Weight::from_ref_time(1_002_066) + // Standard Error: 609 + .saturating_add(Weight::from_ref_time(346_608).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - // Minimum execution time: 705 nanoseconds. - Weight::from_ref_time(1_191_205) - // Standard Error: 600 - .saturating_add(Weight::from_ref_time(986_102).saturating_mul(r.into())) + // Minimum execution time: 917 nanoseconds. + Weight::from_ref_time(1_247_710) + // Standard Error: 1_069 + .saturating_add(Weight::from_ref_time(984_608).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - // Minimum execution time: 717 nanoseconds. - Weight::from_ref_time(1_019_448) - // Standard Error: 421 - .saturating_add(Weight::from_ref_time(882_531).saturating_mul(r.into())) + // Minimum execution time: 917 nanoseconds. + Weight::from_ref_time(1_244_315) + // Standard Error: 524 + .saturating_add(Weight::from_ref_time(882_167).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - // Minimum execution time: 642 nanoseconds. - Weight::from_ref_time(917_880) - // Standard Error: 362 - .saturating_add(Weight::from_ref_time(957_235).saturating_mul(r.into())) + // Minimum execution time: 791 nanoseconds. + Weight::from_ref_time(1_119_053) + // Standard Error: 379 + .saturating_add(Weight::from_ref_time(956_169).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - // Minimum execution time: 630 nanoseconds. - Weight::from_ref_time(694_427) - // Standard Error: 1_506 - .saturating_add(Weight::from_ref_time(1_298_411).saturating_mul(r.into())) + // Minimum execution time: 782 nanoseconds. + Weight::from_ref_time(773_373) + // Standard Error: 463 + .saturating_add(Weight::from_ref_time(1_299_306).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - // Minimum execution time: 634 nanoseconds. - Weight::from_ref_time(1_101_754) - // Standard Error: 840 - .saturating_add(Weight::from_ref_time(526_433).saturating_mul(r.into())) + // Minimum execution time: 743 nanoseconds. + Weight::from_ref_time(1_273_896) + // Standard Error: 925 + .saturating_add(Weight::from_ref_time(527_015).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - // Minimum execution time: 651 nanoseconds. - Weight::from_ref_time(790_908) - // Standard Error: 849 - .saturating_add(Weight::from_ref_time(800_188).saturating_mul(r.into())) + // Minimum execution time: 761 nanoseconds. + Weight::from_ref_time(929_565) + // Standard Error: 1_275 + .saturating_add(Weight::from_ref_time(805_592).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - // Minimum execution time: 622 nanoseconds. - Weight::from_ref_time(416_266) - // Standard Error: 1_574 - .saturating_add(Weight::from_ref_time(1_080_225).saturating_mul(r.into())) + // Minimum execution time: 813 nanoseconds. + Weight::from_ref_time(703_802) + // Standard Error: 1_665 + .saturating_add(Weight::from_ref_time(1_074_321).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - // Minimum execution time: 2_131 nanoseconds. - Weight::from_ref_time(2_540_446) - // Standard Error: 75 - .saturating_add(Weight::from_ref_time(4_997).saturating_mul(e.into())) + // Minimum execution time: 2_347 nanoseconds. + Weight::from_ref_time(2_752_638) + // Standard Error: 69 + .saturating_add(Weight::from_ref_time(4_771).saturating_mul(e.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - // Minimum execution time: 650 nanoseconds. - Weight::from_ref_time(1_577_978) - // Standard Error: 2_696 - .saturating_add(Weight::from_ref_time(2_204_044).saturating_mul(r.into())) + // Minimum execution time: 826 nanoseconds. + Weight::from_ref_time(1_784_596) + // Standard Error: 1_646 + .saturating_add(Weight::from_ref_time(2_189_993).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - // Minimum execution time: 742 nanoseconds. - Weight::from_ref_time(1_947_575) - // Standard Error: 1_651 - .saturating_add(Weight::from_ref_time(2_799_445).saturating_mul(r.into())) + // Minimum execution time: 926 nanoseconds. + Weight::from_ref_time(1_898_358) + // Standard Error: 2_678 + .saturating_add(Weight::from_ref_time(2_811_379).saturating_mul(r.into())) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - // Minimum execution time: 4_230 nanoseconds. - Weight::from_ref_time(5_079_432) - // Standard Error: 315 - .saturating_add(Weight::from_ref_time(179_278).saturating_mul(p.into())) + // Minimum execution time: 4_428 nanoseconds. + Weight::from_ref_time(5_257_445) + // Standard Error: 306 + .saturating_add(Weight::from_ref_time(178_882).saturating_mul(p.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { - // Minimum execution time: 2_830 nanoseconds. - Weight::from_ref_time(3_601_633) - // Standard Error: 31 - .saturating_add(Weight::from_ref_time(92_499).saturating_mul(l.into())) + // Minimum execution time: 2_945 nanoseconds. + Weight::from_ref_time(4_240_619) + // Standard Error: 39 + .saturating_add(Weight::from_ref_time(46_640).saturating_mul(l.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - // Minimum execution time: 2_896 nanoseconds. - Weight::from_ref_time(3_137_247) - // Standard Error: 245 - .saturating_add(Weight::from_ref_time(364_431).saturating_mul(r.into())) + // Minimum execution time: 2_204 nanoseconds. + Weight::from_ref_time(2_430_272) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(365_718).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - // Minimum execution time: 2_795 nanoseconds. - Weight::from_ref_time(3_199_878) - // Standard Error: 549 - .saturating_add(Weight::from_ref_time(380_524).saturating_mul(r.into())) + // Minimum execution time: 2_117 nanoseconds. + Weight::from_ref_time(2_429_354) + // Standard Error: 240 + .saturating_add(Weight::from_ref_time(381_830).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - // Minimum execution time: 2_807 nanoseconds. - Weight::from_ref_time(3_130_120) - // Standard Error: 319 - .saturating_add(Weight::from_ref_time(525_857).saturating_mul(r.into())) + // Minimum execution time: 2_123 nanoseconds. + Weight::from_ref_time(2_460_016) + // Standard Error: 262 + .saturating_add(Weight::from_ref_time(526_554).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - // Minimum execution time: 678 nanoseconds. - Weight::from_ref_time(1_013_348) - // Standard Error: 362 - .saturating_add(Weight::from_ref_time(810_232).saturating_mul(r.into())) + // Minimum execution time: 892 nanoseconds. + Weight::from_ref_time(1_234_618) + // Standard Error: 485 + .saturating_add(Weight::from_ref_time(813_721).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - // Minimum execution time: 624 nanoseconds. - Weight::from_ref_time(973_583) - // Standard Error: 373 - .saturating_add(Weight::from_ref_time(829_360).saturating_mul(r.into())) + // Minimum execution time: 901 nanoseconds. + Weight::from_ref_time(1_182_838) + // Standard Error: 482 + .saturating_add(Weight::from_ref_time(831_308).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - // Minimum execution time: 698 nanoseconds. - Weight::from_ref_time(904_862) - // Standard Error: 360 - .saturating_add(Weight::from_ref_time(694_614).saturating_mul(r.into())) + // Minimum execution time: 929 nanoseconds. + Weight::from_ref_time(1_221_388) + // Standard Error: 434 + .saturating_add(Weight::from_ref_time(693_301).saturating_mul(r.into())) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - // Minimum execution time: 642 nanoseconds. - Weight::from_ref_time(735_085) - // Standard Error: 105_815 - .saturating_add(Weight::from_ref_time(233_816_514).saturating_mul(r.into())) + // Minimum execution time: 808 nanoseconds. + Weight::from_ref_time(906_944) + // Standard Error: 6_164 + .saturating_add(Weight::from_ref_time(187_445_255).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - // Minimum execution time: 606 nanoseconds. - Weight::from_ref_time(850_590) - // Standard Error: 262 - .saturating_add(Weight::from_ref_time(507_721).saturating_mul(r.into())) + // Minimum execution time: 807 nanoseconds. + Weight::from_ref_time(1_064_776) + // Standard Error: 287 + .saturating_add(Weight::from_ref_time(507_278).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - // Minimum execution time: 663 nanoseconds. - Weight::from_ref_time(853_060) - // Standard Error: 250 - .saturating_add(Weight::from_ref_time(514_225).saturating_mul(r.into())) + // Minimum execution time: 776 nanoseconds. + Weight::from_ref_time(1_033_205) + // Standard Error: 443 + .saturating_add(Weight::from_ref_time(512_445).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - // Minimum execution time: 605 nanoseconds. - Weight::from_ref_time(849_563) - // Standard Error: 275 - .saturating_add(Weight::from_ref_time(511_494).saturating_mul(r.into())) + // Minimum execution time: 909 nanoseconds. + Weight::from_ref_time(1_089_083) + // Standard Error: 335 + .saturating_add(Weight::from_ref_time(510_392).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - // Minimum execution time: 618 nanoseconds. - Weight::from_ref_time(839_855) - // Standard Error: 228 - .saturating_add(Weight::from_ref_time(524_614).saturating_mul(r.into())) + // Minimum execution time: 791 nanoseconds. + Weight::from_ref_time(1_063_118) + // Standard Error: 210 + .saturating_add(Weight::from_ref_time(522_817).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - // Minimum execution time: 637 nanoseconds. - Weight::from_ref_time(860_326) + // Minimum execution time: 789 nanoseconds. + Weight::from_ref_time(1_056_006) // Standard Error: 240 - .saturating_add(Weight::from_ref_time(504_847).saturating_mul(r.into())) + .saturating_add(Weight::from_ref_time(505_198).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - // Minimum execution time: 623 nanoseconds. - Weight::from_ref_time(844_585) - // Standard Error: 235 - .saturating_add(Weight::from_ref_time(505_821).saturating_mul(r.into())) + // Minimum execution time: 804 nanoseconds. + Weight::from_ref_time(1_087_882) + // Standard Error: 234 + .saturating_add(Weight::from_ref_time(503_830).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - // Minimum execution time: 672 nanoseconds. - Weight::from_ref_time(826_784) - // Standard Error: 225 - .saturating_add(Weight::from_ref_time(504_632).saturating_mul(r.into())) + // Minimum execution time: 756 nanoseconds. + Weight::from_ref_time(1_050_994) + // Standard Error: 172 + .saturating_add(Weight::from_ref_time(503_343).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - // Minimum execution time: 642 nanoseconds. - Weight::from_ref_time(867_080) - // Standard Error: 231 - .saturating_add(Weight::from_ref_time(732_430).saturating_mul(r.into())) + // Minimum execution time: 775 nanoseconds. + Weight::from_ref_time(1_061_228) + // Standard Error: 232 + .saturating_add(Weight::from_ref_time(730_751).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - // Minimum execution time: 639 nanoseconds. - Weight::from_ref_time(866_094) - // Standard Error: 272 - .saturating_add(Weight::from_ref_time(732_560).saturating_mul(r.into())) + // Minimum execution time: 809 nanoseconds. + Weight::from_ref_time(1_080_957) + // Standard Error: 320 + .saturating_add(Weight::from_ref_time(732_246).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - // Minimum execution time: 619 nanoseconds. - Weight::from_ref_time(928_672) - // Standard Error: 484 - .saturating_add(Weight::from_ref_time(739_523).saturating_mul(r.into())) + // Minimum execution time: 808 nanoseconds. + Weight::from_ref_time(1_055_752) + // Standard Error: 496 + .saturating_add(Weight::from_ref_time(740_084).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - // Minimum execution time: 612 nanoseconds. - Weight::from_ref_time(863_312) - // Standard Error: 328 - .saturating_add(Weight::from_ref_time(743_687).saturating_mul(r.into())) + // Minimum execution time: 792 nanoseconds. + Weight::from_ref_time(1_111_972) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(741_581).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - // Minimum execution time: 648 nanoseconds. - Weight::from_ref_time(931_331) - // Standard Error: 612 - .saturating_add(Weight::from_ref_time(747_653).saturating_mul(r.into())) + // Minimum execution time: 862 nanoseconds. + Weight::from_ref_time(1_111_246) + // Standard Error: 263 + .saturating_add(Weight::from_ref_time(746_026).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - // Minimum execution time: 632 nanoseconds. - Weight::from_ref_time(868_901) - // Standard Error: 276 - .saturating_add(Weight::from_ref_time(744_778).saturating_mul(r.into())) + // Minimum execution time: 810 nanoseconds. + Weight::from_ref_time(1_094_933) + // Standard Error: 271 + .saturating_add(Weight::from_ref_time(743_645).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - // Minimum execution time: 629 nanoseconds. - Weight::from_ref_time(898_516) - // Standard Error: 288 - .saturating_add(Weight::from_ref_time(734_393).saturating_mul(r.into())) + // Minimum execution time: 769 nanoseconds. + Weight::from_ref_time(819_933) + // Standard Error: 4_528 + .saturating_add(Weight::from_ref_time(751_599).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - // Minimum execution time: 603 nanoseconds. - Weight::from_ref_time(853_744) - // Standard Error: 204 - .saturating_add(Weight::from_ref_time(739_499).saturating_mul(r.into())) + // Minimum execution time: 797 nanoseconds. + Weight::from_ref_time(1_107_352) + // Standard Error: 344 + .saturating_add(Weight::from_ref_time(738_684).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - // Minimum execution time: 625 nanoseconds. - Weight::from_ref_time(885_174) - // Standard Error: 238 - .saturating_add(Weight::from_ref_time(734_010).saturating_mul(r.into())) + // Minimum execution time: 784 nanoseconds. + Weight::from_ref_time(1_068_487) + // Standard Error: 3_796 + .saturating_add(Weight::from_ref_time(741_207).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - // Minimum execution time: 602 nanoseconds. - Weight::from_ref_time(915_329) - // Standard Error: 273 - .saturating_add(Weight::from_ref_time(738_209).saturating_mul(r.into())) + // Minimum execution time: 813 nanoseconds. + Weight::from_ref_time(1_067_278) + // Standard Error: 459 + .saturating_add(Weight::from_ref_time(737_841).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - // Minimum execution time: 585 nanoseconds. - Weight::from_ref_time(862_239) - // Standard Error: 294 - .saturating_add(Weight::from_ref_time(719_000).saturating_mul(r.into())) + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_100_254) + // Standard Error: 297 + .saturating_add(Weight::from_ref_time(717_622).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - // Minimum execution time: 633 nanoseconds. - Weight::from_ref_time(881_696) - // Standard Error: 195 - .saturating_add(Weight::from_ref_time(713_153).saturating_mul(r.into())) + // Minimum execution time: 778 nanoseconds. + Weight::from_ref_time(1_063_748) + // Standard Error: 378 + .saturating_add(Weight::from_ref_time(713_577).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - // Minimum execution time: 629 nanoseconds. - Weight::from_ref_time(856_238) - // Standard Error: 269 - .saturating_add(Weight::from_ref_time(715_451).saturating_mul(r.into())) + // Minimum execution time: 780 nanoseconds. + Weight::from_ref_time(1_088_755) + // Standard Error: 316 + .saturating_add(Weight::from_ref_time(714_127).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - // Minimum execution time: 633 nanoseconds. - Weight::from_ref_time(880_804) - // Standard Error: 725 - .saturating_add(Weight::from_ref_time(1_349_577).saturating_mul(r.into())) + // Minimum execution time: 776 nanoseconds. + Weight::from_ref_time(1_062_591) + // Standard Error: 610 + .saturating_add(Weight::from_ref_time(1_355_430).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - // Minimum execution time: 639 nanoseconds. - Weight::from_ref_time(867_528) - // Standard Error: 1_940 - .saturating_add(Weight::from_ref_time(1_287_959).saturating_mul(r.into())) + // Minimum execution time: 801 nanoseconds. + Weight::from_ref_time(1_092_395) + // Standard Error: 423 + .saturating_add(Weight::from_ref_time(1_282_356).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - // Minimum execution time: 595 nanoseconds. - Weight::from_ref_time(851_253) - // Standard Error: 503 - .saturating_add(Weight::from_ref_time(1_398_668).saturating_mul(r.into())) + // Minimum execution time: 822 nanoseconds. + Weight::from_ref_time(1_083_079) + // Standard Error: 562 + .saturating_add(Weight::from_ref_time(1_398_522).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - // Minimum execution time: 604 nanoseconds. - Weight::from_ref_time(804_977) - // Standard Error: 812 - .saturating_add(Weight::from_ref_time(1_288_816).saturating_mul(r.into())) + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_088_997) + // Standard Error: 401 + .saturating_add(Weight::from_ref_time(1_283_442).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - // Minimum execution time: 609 nanoseconds. - Weight::from_ref_time(890_945) - // Standard Error: 1_645 - .saturating_add(Weight::from_ref_time(719_770).saturating_mul(r.into())) + // Minimum execution time: 815 nanoseconds. + Weight::from_ref_time(1_081_903) + // Standard Error: 264 + .saturating_add(Weight::from_ref_time(718_069).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - // Minimum execution time: 628 nanoseconds. - Weight::from_ref_time(897_973) - // Standard Error: 1_641 - .saturating_add(Weight::from_ref_time(718_838).saturating_mul(r.into())) + // Minimum execution time: 813 nanoseconds. + Weight::from_ref_time(1_091_426) + // Standard Error: 296 + .saturating_add(Weight::from_ref_time(717_894).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - // Minimum execution time: 634 nanoseconds. - Weight::from_ref_time(848_440) - // Standard Error: 249 - .saturating_add(Weight::from_ref_time(718_206).saturating_mul(r.into())) + // Minimum execution time: 794 nanoseconds. + Weight::from_ref_time(1_040_144) + // Standard Error: 400 + .saturating_add(Weight::from_ref_time(719_886).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - // Minimum execution time: 625 nanoseconds. - Weight::from_ref_time(881_579) - // Standard Error: 273 - .saturating_add(Weight::from_ref_time(736_934).saturating_mul(r.into())) + // Minimum execution time: 774 nanoseconds. + Weight::from_ref_time(1_092_466) + // Standard Error: 4_173 + .saturating_add(Weight::from_ref_time(739_873).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - // Minimum execution time: 630 nanoseconds. - Weight::from_ref_time(897_813) - // Standard Error: 249 - .saturating_add(Weight::from_ref_time(734_657).saturating_mul(r.into())) + // Minimum execution time: 793 nanoseconds. + Weight::from_ref_time(1_105_611) + // Standard Error: 394 + .saturating_add(Weight::from_ref_time(735_358).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - // Minimum execution time: 607 nanoseconds. - Weight::from_ref_time(871_660) - // Standard Error: 312 - .saturating_add(Weight::from_ref_time(735_377).saturating_mul(r.into())) + // Minimum execution time: 805 nanoseconds. + Weight::from_ref_time(1_130_462) + // Standard Error: 327 + .saturating_add(Weight::from_ref_time(734_198).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - // Minimum execution time: 610 nanoseconds. - Weight::from_ref_time(861_640) - // Standard Error: 293 - .saturating_add(Weight::from_ref_time(735_524).saturating_mul(r.into())) + // Minimum execution time: 831 nanoseconds. + Weight::from_ref_time(1_118_894) + // Standard Error: 389 + .saturating_add(Weight::from_ref_time(733_834).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - // Minimum execution time: 625 nanoseconds. - Weight::from_ref_time(880_203) - // Standard Error: 373 - .saturating_add(Weight::from_ref_time(737_354).saturating_mul(r.into())) + // Minimum execution time: 772 nanoseconds. + Weight::from_ref_time(1_123_733) + // Standard Error: 337 + .saturating_add(Weight::from_ref_time(733_923).saturating_mul(r.into())) } } @@ -1447,17 +1449,17 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Contracts DeletionQueue (r:1 w:0) fn on_process_deletion_queue_batch() -> Weight { - // Minimum execution time: 3_196 nanoseconds. - Weight::from_ref_time(3_293_000) + // Minimum execution time: 3_326 nanoseconds. + Weight::from_ref_time(3_433_000) .saturating_add(RocksDbWeight::get().reads(1)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - // Minimum execution time: 14_857 nanoseconds. - Weight::from_ref_time(14_957_593) - // Standard Error: 1_015 - .saturating_add(Weight::from_ref_time(935_359).saturating_mul(k.into())) + // Minimum execution time: 15_703 nanoseconds. + Weight::from_ref_time(15_288_927) + // Standard Error: 951 + .saturating_add(Weight::from_ref_time(940_816).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -1465,10 +1467,10 @@ impl WeightInfo for () { // Storage: Contracts DeletionQueue (r:1 w:0) /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - // Minimum execution time: 3_231 nanoseconds. - Weight::from_ref_time(14_859_580) - // Standard Error: 3_479 - .saturating_add(Weight::from_ref_time(1_185_600).saturating_mul(q.into())) + // Minimum execution time: 3_548 nanoseconds. + Weight::from_ref_time(15_764_121) + // Standard Error: 3_339 + .saturating_add(Weight::from_ref_time(1_214_890).saturating_mul(q.into())) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -1476,10 +1478,10 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn reinstrument(c: u32, ) -> Weight { - // Minimum execution time: 34_565 nanoseconds. - Weight::from_ref_time(29_199_016) - // Standard Error: 70 - .saturating_add(Weight::from_ref_time(47_107).saturating_mul(c.into())) + // Minimum execution time: 29_801 nanoseconds. + Weight::from_ref_time(27_932_706) + // Standard Error: 49 + .saturating_add(Weight::from_ref_time(50_532).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -1490,10 +1492,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `c` is `[0, 131072]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - // Minimum execution time: 392_074 nanoseconds. - Weight::from_ref_time(404_090_909) - // Standard Error: 24 - .saturating_add(Weight::from_ref_time(30_454).saturating_mul(c.into())) + // Minimum execution time: 307_894 nanoseconds. + Weight::from_ref_time(322_346_319) + // Standard Error: 25 + .saturating_add(Weight::from_ref_time(30_678).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(4)) } @@ -1509,14 +1511,14 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 3_785_934 nanoseconds. - Weight::from_ref_time(683_143_843) - // Standard Error: 272 - .saturating_add(Weight::from_ref_time(87_620).saturating_mul(c.into())) + // Minimum execution time: 3_610_424 nanoseconds. + Weight::from_ref_time(583_426_386) + // Standard Error: 277 + .saturating_add(Weight::from_ref_time(90_224).saturating_mul(c.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_363).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_325).saturating_mul(i.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_778).saturating_mul(s.into())) + .saturating_add(Weight::from_ref_time(1_727).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(9)) } @@ -1530,12 +1532,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { - // Minimum execution time: 1_935_310 nanoseconds. - Weight::from_ref_time(203_531_122) + // Minimum execution time: 1_892_996 nanoseconds. + Weight::from_ref_time(202_958_196) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_674).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_627).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_789).saturating_mul(s.into())) + .saturating_add(Weight::from_ref_time(1_755).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(7)) } @@ -1545,8 +1547,8 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: System EventTopics (r:2 w:2) fn call() -> Weight { - // Minimum execution time: 151_999 nanoseconds. - Weight::from_ref_time(153_527_000) + // Minimum execution time: 157_347 nanoseconds. + Weight::from_ref_time(159_084_000) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(4)) } @@ -1556,10 +1558,10 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:0 w:1) /// The range of component `c` is `[0, 64226]`. fn upload_code(c: u32, ) -> Weight { - // Minimum execution time: 391_165 nanoseconds. - Weight::from_ref_time(394_519_487) - // Standard Error: 75 - .saturating_add(Weight::from_ref_time(89_736).saturating_mul(c.into())) + // Minimum execution time: 299_987 nanoseconds. + Weight::from_ref_time(305_274_879) + // Standard Error: 72 + .saturating_add(Weight::from_ref_time(91_916).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(4)) } @@ -1568,8 +1570,8 @@ impl WeightInfo for () { // Storage: Contracts CodeStorage (r:0 w:1) // Storage: Contracts PristineCode (r:0 w:1) fn remove_code() -> Weight { - // Minimum execution time: 39_354 nanoseconds. - Weight::from_ref_time(39_855_000) + // Minimum execution time: 40_795 nanoseconds. + Weight::from_ref_time(41_297_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(4)) } @@ -1577,8 +1579,8 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:2 w:2) // Storage: System EventTopics (r:3 w:3) fn set_code() -> Weight { - // Minimum execution time: 40_909 nanoseconds. - Weight::from_ref_time(41_275_000) + // Minimum execution time: 41_957 nanoseconds. + Weight::from_ref_time(42_536_000) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(6)) } @@ -1589,10 +1591,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - // Minimum execution time: 380_150 nanoseconds. - Weight::from_ref_time(384_429_035) - // Standard Error: 34_740 - .saturating_add(Weight::from_ref_time(15_582_218).saturating_mul(r.into())) + // Minimum execution time: 293_544 nanoseconds. + Weight::from_ref_time(298_981_222) + // Standard Error: 39_139 + .saturating_add(Weight::from_ref_time(17_278_436).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1603,10 +1605,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - // Minimum execution time: 380_608 nanoseconds. - Weight::from_ref_time(326_544_805) - // Standard Error: 475_381 - .saturating_add(Weight::from_ref_time(190_717_772).saturating_mul(r.into())) + // Minimum execution time: 293_500 nanoseconds. + Weight::from_ref_time(237_825_284) + // Standard Error: 450_234 + .saturating_add(Weight::from_ref_time(198_995_806).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1618,10 +1620,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 382_780 nanoseconds. - Weight::from_ref_time(333_775_113) - // Standard Error: 446_086 - .saturating_add(Weight::from_ref_time(232_531_042).saturating_mul(r.into())) + // Minimum execution time: 295_851 nanoseconds. + Weight::from_ref_time(258_113_447) + // Standard Error: 408_747 + .saturating_add(Weight::from_ref_time(237_490_216).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1633,10 +1635,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 381_815 nanoseconds. - Weight::from_ref_time(390_931_793) - // Standard Error: 61_918 - .saturating_add(Weight::from_ref_time(18_798_438).saturating_mul(r.into())) + // Minimum execution time: 294_614 nanoseconds. + Weight::from_ref_time(301_528_998) + // Standard Error: 40_613 + .saturating_add(Weight::from_ref_time(20_815_088).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1647,10 +1649,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - // Minimum execution time: 379_162 nanoseconds. - Weight::from_ref_time(383_796_363) - // Standard Error: 25_555 - .saturating_add(Weight::from_ref_time(10_843_721).saturating_mul(r.into())) + // Minimum execution time: 293_088 nanoseconds. + Weight::from_ref_time(299_120_595) + // Standard Error: 23_277 + .saturating_add(Weight::from_ref_time(11_130_334).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1661,10 +1663,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - // Minimum execution time: 380_307 nanoseconds. - Weight::from_ref_time(390_211_779) - // Standard Error: 53_326 - .saturating_add(Weight::from_ref_time(15_311_171).saturating_mul(r.into())) + // Minimum execution time: 295_110 nanoseconds. + Weight::from_ref_time(305_295_787) + // Standard Error: 48_521 + .saturating_add(Weight::from_ref_time(16_610_806).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1675,10 +1677,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - // Minimum execution time: 380_230 nanoseconds. - Weight::from_ref_time(383_470_453) - // Standard Error: 45_007 - .saturating_add(Weight::from_ref_time(15_582_472).saturating_mul(r.into())) + // Minimum execution time: 293_414 nanoseconds. + Weight::from_ref_time(299_960_283) + // Standard Error: 32_003 + .saturating_add(Weight::from_ref_time(16_652_433).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1689,10 +1691,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - // Minimum execution time: 380_244 nanoseconds. - Weight::from_ref_time(388_092_461) - // Standard Error: 98_199 - .saturating_add(Weight::from_ref_time(97_339_528).saturating_mul(r.into())) + // Minimum execution time: 292_429 nanoseconds. + Weight::from_ref_time(301_025_128) + // Standard Error: 92_155 + .saturating_add(Weight::from_ref_time(92_731_719).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1703,10 +1705,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - // Minimum execution time: 380_242 nanoseconds. - Weight::from_ref_time(384_078_258) - // Standard Error: 28_510 - .saturating_add(Weight::from_ref_time(15_423_359).saturating_mul(r.into())) + // Minimum execution time: 293_516 nanoseconds. + Weight::from_ref_time(300_071_428) + // Standard Error: 25_871 + .saturating_add(Weight::from_ref_time(16_599_369).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1717,10 +1719,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - // Minimum execution time: 379_890 nanoseconds. - Weight::from_ref_time(383_658_430) - // Standard Error: 44_976 - .saturating_add(Weight::from_ref_time(15_451_905).saturating_mul(r.into())) + // Minimum execution time: 293_666 nanoseconds. + Weight::from_ref_time(299_803_599) + // Standard Error: 24_508 + .saturating_add(Weight::from_ref_time(16_500_973).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1731,10 +1733,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - // Minimum execution time: 380_269 nanoseconds. - Weight::from_ref_time(383_580_481) - // Standard Error: 31_862 - .saturating_add(Weight::from_ref_time(15_230_473).saturating_mul(r.into())) + // Minimum execution time: 289_193 nanoseconds. + Weight::from_ref_time(297_946_784) + // Standard Error: 43_719 + .saturating_add(Weight::from_ref_time(16_442_254).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1745,10 +1747,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - // Minimum execution time: 380_308 nanoseconds. - Weight::from_ref_time(383_732_372) - // Standard Error: 38_359 - .saturating_add(Weight::from_ref_time(15_358_775).saturating_mul(r.into())) + // Minimum execution time: 288_897 nanoseconds. + Weight::from_ref_time(298_856_658) + // Standard Error: 31_003 + .saturating_add(Weight::from_ref_time(16_490_508).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1760,10 +1762,10 @@ impl WeightInfo for () { // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - // Minimum execution time: 380_834 nanoseconds. - Weight::from_ref_time(388_999_459) - // Standard Error: 96_447 - .saturating_add(Weight::from_ref_time(86_714_414).saturating_mul(r.into())) + // Minimum execution time: 289_850 nanoseconds. + Weight::from_ref_time(302_898_449) + // Standard Error: 92_822 + .saturating_add(Weight::from_ref_time(86_376_874).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1774,10 +1776,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - // Minimum execution time: 140_955 nanoseconds. - Weight::from_ref_time(144_716_423) - // Standard Error: 11_370 - .saturating_add(Weight::from_ref_time(7_858_807).saturating_mul(r.into())) + // Minimum execution time: 145_105 nanoseconds. + Weight::from_ref_time(152_388_934) + // Standard Error: 29_988 + .saturating_add(Weight::from_ref_time(7_761_947).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1788,10 +1790,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - // Minimum execution time: 380_210 nanoseconds. - Weight::from_ref_time(384_185_776) - // Standard Error: 49_038 - .saturating_add(Weight::from_ref_time(13_649_793).saturating_mul(r.into())) + // Minimum execution time: 289_319 nanoseconds. + Weight::from_ref_time(298_390_911) + // Standard Error: 27_329 + .saturating_add(Weight::from_ref_time(14_225_527).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1802,10 +1804,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 396_209 nanoseconds. - Weight::from_ref_time(424_522_611) - // Standard Error: 3_917 - .saturating_add(Weight::from_ref_time(9_627_216).saturating_mul(n.into())) + // Minimum execution time: 305_538 nanoseconds. + Weight::from_ref_time(339_734_596) + // Standard Error: 4_636 + .saturating_add(Weight::from_ref_time(9_592_149).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1816,10 +1818,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { - // Minimum execution time: 378_412 nanoseconds. - Weight::from_ref_time(380_502_085) - // Standard Error: 201_552 - .saturating_add(Weight::from_ref_time(1_434_214).saturating_mul(r.into())) + // Minimum execution time: 287_189 nanoseconds. + Weight::from_ref_time(295_472_383) + // Standard Error: 314_142 + .saturating_add(Weight::from_ref_time(214_016).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1830,10 +1832,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 381_463 nanoseconds. - Weight::from_ref_time(383_955_553) - // Standard Error: 998 - .saturating_add(Weight::from_ref_time(230_512).saturating_mul(n.into())) + // Minimum execution time: 289_380 nanoseconds. + Weight::from_ref_time(296_302_404) + // Standard Error: 889 + .saturating_add(Weight::from_ref_time(190_017).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1846,10 +1848,10 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:1 w:1) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - // Minimum execution time: 379_877 nanoseconds. - Weight::from_ref_time(381_729_546) - // Standard Error: 214_004 - .saturating_add(Weight::from_ref_time(52_528_353).saturating_mul(r.into())) + // Minimum execution time: 292_383 nanoseconds. + Weight::from_ref_time(297_557_691) + // Standard Error: 251_228 + .saturating_add(Weight::from_ref_time(56_688_008).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1863,10 +1865,10 @@ impl WeightInfo for () { // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - // Minimum execution time: 380_275 nanoseconds. - Weight::from_ref_time(386_495_777) - // Standard Error: 94_674 - .saturating_add(Weight::from_ref_time(108_432_929).saturating_mul(r.into())) + // Minimum execution time: 293_019 nanoseconds. + Weight::from_ref_time(301_747_439) + // Standard Error: 92_043 + .saturating_add(Weight::from_ref_time(109_861_144).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1877,10 +1879,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - // Minimum execution time: 379_095 nanoseconds. - Weight::from_ref_time(393_997_924) - // Standard Error: 141_916 - .saturating_add(Weight::from_ref_time(212_937_170).saturating_mul(r.into())) + // Minimum execution time: 287_586 nanoseconds. + Weight::from_ref_time(304_751_302) + // Standard Error: 127_698 + .saturating_add(Weight::from_ref_time(221_525_053).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -1892,12 +1894,12 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - // Minimum execution time: 1_241_001 nanoseconds. - Weight::from_ref_time(548_526_917) - // Standard Error: 496_807 - .saturating_add(Weight::from_ref_time(177_087_769).saturating_mul(t.into())) - // Standard Error: 136_447 - .saturating_add(Weight::from_ref_time(71_558_402).saturating_mul(n.into())) + // Minimum execution time: 1_182_204 nanoseconds. + Weight::from_ref_time(508_607_957) + // Standard Error: 503_533 + .saturating_add(Weight::from_ref_time(173_998_655).saturating_mul(t.into())) + // Standard Error: 138_294 + .saturating_add(Weight::from_ref_time(67_991_373).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1910,20 +1912,20 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - // Minimum execution time: 159_158 nanoseconds. - Weight::from_ref_time(163_427_712) - // Standard Error: 22_442 - .saturating_add(Weight::from_ref_time(12_647_838).saturating_mul(r.into())) + // Minimum execution time: 157_706 nanoseconds. + Weight::from_ref_time(161_895_583) + // Standard Error: 14_952 + .saturating_add(Weight::from_ref_time(12_990_237).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_068 nanoseconds. - Weight::from_ref_time(341_041_230) - // Standard Error: 464_053 - .saturating_add(Weight::from_ref_time(402_677_314).saturating_mul(r.into())) + // Minimum execution time: 290_063 nanoseconds. + Weight::from_ref_time(256_404_853) + // Standard Error: 436_195 + .saturating_add(Weight::from_ref_time(406_569_743).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1932,10 +1934,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - // Minimum execution time: 508_695 nanoseconds. - Weight::from_ref_time(663_159_695) - // Standard Error: 1_419_342 - .saturating_add(Weight::from_ref_time(96_558_570).saturating_mul(n.into())) + // Minimum execution time: 426_295 nanoseconds. + Weight::from_ref_time(582_989_911) + // Standard Error: 1_404_141 + .saturating_add(Weight::from_ref_time(89_545_963).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(52)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(50)) @@ -1944,10 +1946,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - // Minimum execution time: 508_542 nanoseconds. - Weight::from_ref_time(634_146_978) - // Standard Error: 1_168_252 - .saturating_add(Weight::from_ref_time(64_231_947).saturating_mul(n.into())) + // Minimum execution time: 425_062 nanoseconds. + Weight::from_ref_time(552_380_900) + // Standard Error: 1_140_169 + .saturating_add(Weight::from_ref_time(64_085_108).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(49)) @@ -1956,10 +1958,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_743 nanoseconds. - Weight::from_ref_time(337_309_674) - // Standard Error: 527_407 - .saturating_add(Weight::from_ref_time(395_767_068).saturating_mul(r.into())) + // Minimum execution time: 294_421 nanoseconds. + Weight::from_ref_time(260_897_072) + // Standard Error: 474_135 + .saturating_add(Weight::from_ref_time(403_191_862).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1968,10 +1970,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 478_283 nanoseconds. - Weight::from_ref_time(616_673_245) - // Standard Error: 1_290_784 - .saturating_add(Weight::from_ref_time(66_534_552).saturating_mul(n.into())) + // Minimum execution time: 391_743 nanoseconds. + Weight::from_ref_time(535_327_545) + // Standard Error: 1_297_157 + .saturating_add(Weight::from_ref_time(67_222_981).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(48)) @@ -1980,10 +1982,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_916 nanoseconds. - Weight::from_ref_time(349_150_912) - // Standard Error: 443_388 - .saturating_add(Weight::from_ref_time(316_975_558).saturating_mul(r.into())) + // Minimum execution time: 294_947 nanoseconds. + Weight::from_ref_time(266_280_887) + // Standard Error: 382_477 + .saturating_add(Weight::from_ref_time(323_306_898).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -1991,10 +1993,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 459_294 nanoseconds. - Weight::from_ref_time(579_698_524) - // Standard Error: 1_111_681 - .saturating_add(Weight::from_ref_time(159_276_087).saturating_mul(n.into())) + // Minimum execution time: 375_487 nanoseconds. + Weight::from_ref_time(497_019_365) + // Standard Error: 1_141_672 + .saturating_add(Weight::from_ref_time(152_354_482).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2002,10 +2004,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - // Minimum execution time: 381_700 nanoseconds. - Weight::from_ref_time(352_544_675) - // Standard Error: 401_504 - .saturating_add(Weight::from_ref_time(304_380_106).saturating_mul(r.into())) + // Minimum execution time: 294_716 nanoseconds. + Weight::from_ref_time(266_187_186) + // Standard Error: 395_323 + .saturating_add(Weight::from_ref_time(309_907_221).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2013,10 +2015,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 455_595 nanoseconds. - Weight::from_ref_time(560_428_166) - // Standard Error: 991_088 - .saturating_add(Weight::from_ref_time(61_810_610).saturating_mul(n.into())) + // Minimum execution time: 371_667 nanoseconds. + Weight::from_ref_time(478_075_482) + // Standard Error: 979_116 + .saturating_add(Weight::from_ref_time(62_075_707).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2024,10 +2026,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - // Minimum execution time: 382_000 nanoseconds. - Weight::from_ref_time(336_164_219) - // Standard Error: 601_744 - .saturating_add(Weight::from_ref_time(406_198_079).saturating_mul(r.into())) + // Minimum execution time: 292_147 nanoseconds. + Weight::from_ref_time(254_374_598) + // Standard Error: 442_367 + .saturating_add(Weight::from_ref_time(413_674_705).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2036,10 +2038,10 @@ impl WeightInfo for () { // Storage: Skipped Metadata (r:0 w:0) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 482_335 nanoseconds. - Weight::from_ref_time(634_245_177) - // Standard Error: 1_418_845 - .saturating_add(Weight::from_ref_time(164_352_113).saturating_mul(n.into())) + // Minimum execution time: 398_554 nanoseconds. + Weight::from_ref_time(553_715_911) + // Standard Error: 1_415_272 + .saturating_add(Weight::from_ref_time(158_254_544).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(51)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(48)) @@ -2052,10 +2054,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - // Minimum execution time: 382_142 nanoseconds. - Weight::from_ref_time(317_581_708) - // Standard Error: 682_156 - .saturating_add(Weight::from_ref_time(1_305_289_569).saturating_mul(r.into())) + // Minimum execution time: 295_081 nanoseconds. + Weight::from_ref_time(253_461_581) + // Standard Error: 740_198 + .saturating_add(Weight::from_ref_time(1_369_153_623).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(4)) @@ -2068,10 +2070,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { - // Minimum execution time: 383_580 nanoseconds. - Weight::from_ref_time(384_176_000) - // Standard Error: 6_483_482 - .saturating_add(Weight::from_ref_time(28_047_685_517).saturating_mul(r.into())) + // Minimum execution time: 296_089 nanoseconds. + Weight::from_ref_time(297_193_000) + // Standard Error: 6_571_547 + .saturating_add(Weight::from_ref_time(21_080_280_397).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().reads((160_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2084,10 +2086,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { - // Minimum execution time: 384_523 nanoseconds. - Weight::from_ref_time(385_105_000) - // Standard Error: 6_156_142 - .saturating_add(Weight::from_ref_time(27_780_652_513).saturating_mul(r.into())) + // Minimum execution time: 296_828 nanoseconds. + Weight::from_ref_time(297_685_000) + // Standard Error: 6_864_880 + .saturating_add(Weight::from_ref_time(20_770_321_946).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((150_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2101,12 +2103,12 @@ impl WeightInfo for () { /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - // Minimum execution time: 9_509_961 nanoseconds. - Weight::from_ref_time(8_509_991_348) - // Standard Error: 6_614_757 - .saturating_add(Weight::from_ref_time(1_244_514_376).saturating_mul(t.into())) - // Standard Error: 9_918 - .saturating_add(Weight::from_ref_time(9_856_517).saturating_mul(c.into())) + // Minimum execution time: 9_824_671 nanoseconds. + Weight::from_ref_time(8_713_861_450) + // Standard Error: 7_388_925 + .saturating_add(Weight::from_ref_time(1_327_819_806).saturating_mul(t.into())) + // Standard Error: 11_079 + .saturating_add(Weight::from_ref_time(9_789_514).saturating_mul(c.into())) .saturating_add(RocksDbWeight::get().reads(167)) .saturating_add(RocksDbWeight::get().reads((81_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(163)) @@ -2121,10 +2123,10 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:80 w:80) /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { - // Minimum execution time: 384_604 nanoseconds. - Weight::from_ref_time(385_278_000) - // Standard Error: 21_140_468 - .saturating_add(Weight::from_ref_time(33_100_726_150).saturating_mul(r.into())) + // Minimum execution time: 293_374 nanoseconds. + Weight::from_ref_time(302_067_000) + // Standard Error: 20_137_097 + .saturating_add(Weight::from_ref_time(26_444_812_817).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().reads((400_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(5)) @@ -2141,12 +2143,14 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 960]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 129_699_480 nanoseconds. - Weight::from_ref_time(10_187_699_005) - // Standard Error: 155_040 - .saturating_add(Weight::from_ref_time(125_284_310).saturating_mul(i.into())) - // Standard Error: 155_040 - .saturating_add(Weight::from_ref_time(125_850_564).saturating_mul(s.into())) + // Minimum execution time: 126_456_770 nanoseconds. + Weight::from_ref_time(9_223_715_752) + // Standard Error: 96_040_318 + .saturating_add(Weight::from_ref_time(19_550_519).saturating_mul(t.into())) + // Standard Error: 156_614 + .saturating_add(Weight::from_ref_time(122_958_298).saturating_mul(i.into())) + // Standard Error: 156_614 + .saturating_add(Weight::from_ref_time(123_316_079).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(249)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) .saturating_add(RocksDbWeight::get().writes(247)) @@ -2159,10 +2163,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - // Minimum execution time: 380_397 nanoseconds. - Weight::from_ref_time(382_881_855) - // Standard Error: 290_948 - .saturating_add(Weight::from_ref_time(41_017_644).saturating_mul(r.into())) + // Minimum execution time: 289_275 nanoseconds. + Weight::from_ref_time(297_803_961) + // Standard Error: 303_405 + .saturating_add(Weight::from_ref_time(40_800_138).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2173,10 +2177,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 422_439 nanoseconds. - Weight::from_ref_time(423_480_000) - // Standard Error: 56_072 - .saturating_add(Weight::from_ref_time(329_103_825).saturating_mul(n.into())) + // Minimum execution time: 336_077 nanoseconds. + Weight::from_ref_time(336_846_000) + // Standard Error: 51_610 + .saturating_add(Weight::from_ref_time(322_208_787).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2187,10 +2191,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - // Minimum execution time: 380_433 nanoseconds. - Weight::from_ref_time(382_325_624) - // Standard Error: 139_248 - .saturating_add(Weight::from_ref_time(53_159_175).saturating_mul(r.into())) + // Minimum execution time: 290_189 nanoseconds. + Weight::from_ref_time(298_454_259) + // Standard Error: 252_946 + .saturating_add(Weight::from_ref_time(55_034_240).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2201,10 +2205,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 434_834 nanoseconds. - Weight::from_ref_time(435_383_000) - // Standard Error: 59_824 - .saturating_add(Weight::from_ref_time(251_297_967).saturating_mul(n.into())) + // Minimum execution time: 350_030 nanoseconds. + Weight::from_ref_time(351_356_000) + // Standard Error: 57_422 + .saturating_add(Weight::from_ref_time(256_912_844).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2215,10 +2219,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - // Minimum execution time: 379_088 nanoseconds. - Weight::from_ref_time(381_627_077) - // Standard Error: 152_561 - .saturating_add(Weight::from_ref_time(31_696_922).saturating_mul(r.into())) + // Minimum execution time: 288_480 nanoseconds. + Weight::from_ref_time(297_613_263) + // Standard Error: 456_736 + .saturating_add(Weight::from_ref_time(38_100_936).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2229,10 +2233,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 411_630 nanoseconds. - Weight::from_ref_time(412_354_000) - // Standard Error: 50_788 - .saturating_add(Weight::from_ref_time(103_105_715).saturating_mul(n.into())) + // Minimum execution time: 321_195 nanoseconds. + Weight::from_ref_time(325_561_000) + // Standard Error: 46_289 + .saturating_add(Weight::from_ref_time(99_536_902).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2243,10 +2247,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - // Minimum execution time: 379_549 nanoseconds. - Weight::from_ref_time(382_406_346) - // Standard Error: 701_449 - .saturating_add(Weight::from_ref_time(31_066_353).saturating_mul(r.into())) + // Minimum execution time: 287_659 nanoseconds. + Weight::from_ref_time(295_963_340) + // Standard Error: 433_889 + .saturating_add(Weight::from_ref_time(30_251_859).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2257,10 +2261,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 412_112 nanoseconds. - Weight::from_ref_time(412_710_000) - // Standard Error: 54_875 - .saturating_add(Weight::from_ref_time(103_169_035).saturating_mul(n.into())) + // Minimum execution time: 324_298 nanoseconds. + Weight::from_ref_time(325_738_000) + // Standard Error: 48_563 + .saturating_add(Weight::from_ref_time(99_479_838).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2271,10 +2275,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - // Minimum execution time: 381_994 nanoseconds. - Weight::from_ref_time(383_832_551) - // Standard Error: 676_656 - .saturating_add(Weight::from_ref_time(3_020_035_748).saturating_mul(r.into())) + // Minimum execution time: 294_257 nanoseconds. + Weight::from_ref_time(299_467_620) + // Standard Error: 589_749 + .saturating_add(Weight::from_ref_time(3_015_389_579).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2285,10 +2289,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - // Minimum execution time: 381_472 nanoseconds. - Weight::from_ref_time(383_590_834) - // Standard Error: 538_574 - .saturating_add(Weight::from_ref_time(2_077_926_265).saturating_mul(r.into())) + // Minimum execution time: 289_480 nanoseconds. + Weight::from_ref_time(298_762_412) + // Standard Error: 397_004 + .saturating_add(Weight::from_ref_time(743_937_087).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2300,10 +2304,10 @@ impl WeightInfo for () { // Storage: Contracts OwnerInfoOf (r:16 w:16) /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 381_527 nanoseconds. - Weight::from_ref_time(382_291_000) - // Standard Error: 2_760_840 - .saturating_add(Weight::from_ref_time(1_356_115_009).saturating_mul(r.into())) + // Minimum execution time: 293_494 nanoseconds. + Weight::from_ref_time(297_756_000) + // Standard Error: 2_731_227 + .saturating_add(Weight::from_ref_time(1_387_380_436).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().reads((225_u64).saturating_mul(r.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -2316,10 +2320,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 382_722 nanoseconds. - Weight::from_ref_time(387_231_409) - // Standard Error: 28_817 - .saturating_add(Weight::from_ref_time(11_349_809).saturating_mul(r.into())) + // Minimum execution time: 295_339 nanoseconds. + Weight::from_ref_time(301_577_907) + // Standard Error: 23_836 + .saturating_add(Weight::from_ref_time(10_876_508).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2330,10 +2334,10 @@ impl WeightInfo for () { // Storage: System EventTopics (r:2 w:2) /// The range of component `r` is `[0, 20]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 383_568 nanoseconds. - Weight::from_ref_time(419_835_108) - // Standard Error: 125_982 - .saturating_add(Weight::from_ref_time(25_241_800).saturating_mul(r.into())) + // Minimum execution time: 297_096 nanoseconds. + Weight::from_ref_time(336_319_823) + // Standard Error: 128_941 + .saturating_add(Weight::from_ref_time(25_211_374).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(6)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -2345,375 +2349,375 @@ impl WeightInfo for () { // Storage: Contracts Nonce (r:1 w:1) /// The range of component `r` is `[0, 20]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { - // Minimum execution time: 382_084 nanoseconds. - Weight::from_ref_time(388_155_568) - // Standard Error: 29_161 - .saturating_add(Weight::from_ref_time(9_015_217).saturating_mul(r.into())) + // Minimum execution time: 293_819 nanoseconds. + Weight::from_ref_time(302_765_659) + // Standard Error: 28_518 + .saturating_add(Weight::from_ref_time(9_325_552).saturating_mul(r.into())) .saturating_add(RocksDbWeight::get().reads(7)) .saturating_add(RocksDbWeight::get().writes(4)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - // Minimum execution time: 593 nanoseconds. - Weight::from_ref_time(816_706) - // Standard Error: 173 - .saturating_add(Weight::from_ref_time(344_732).saturating_mul(r.into())) + // Minimum execution time: 805 nanoseconds. + Weight::from_ref_time(1_002_066) + // Standard Error: 609 + .saturating_add(Weight::from_ref_time(346_608).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - // Minimum execution time: 705 nanoseconds. - Weight::from_ref_time(1_191_205) - // Standard Error: 600 - .saturating_add(Weight::from_ref_time(986_102).saturating_mul(r.into())) + // Minimum execution time: 917 nanoseconds. + Weight::from_ref_time(1_247_710) + // Standard Error: 1_069 + .saturating_add(Weight::from_ref_time(984_608).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - // Minimum execution time: 717 nanoseconds. - Weight::from_ref_time(1_019_448) - // Standard Error: 421 - .saturating_add(Weight::from_ref_time(882_531).saturating_mul(r.into())) + // Minimum execution time: 917 nanoseconds. + Weight::from_ref_time(1_244_315) + // Standard Error: 524 + .saturating_add(Weight::from_ref_time(882_167).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - // Minimum execution time: 642 nanoseconds. - Weight::from_ref_time(917_880) - // Standard Error: 362 - .saturating_add(Weight::from_ref_time(957_235).saturating_mul(r.into())) + // Minimum execution time: 791 nanoseconds. + Weight::from_ref_time(1_119_053) + // Standard Error: 379 + .saturating_add(Weight::from_ref_time(956_169).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - // Minimum execution time: 630 nanoseconds. - Weight::from_ref_time(694_427) - // Standard Error: 1_506 - .saturating_add(Weight::from_ref_time(1_298_411).saturating_mul(r.into())) + // Minimum execution time: 782 nanoseconds. + Weight::from_ref_time(773_373) + // Standard Error: 463 + .saturating_add(Weight::from_ref_time(1_299_306).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - // Minimum execution time: 634 nanoseconds. - Weight::from_ref_time(1_101_754) - // Standard Error: 840 - .saturating_add(Weight::from_ref_time(526_433).saturating_mul(r.into())) + // Minimum execution time: 743 nanoseconds. + Weight::from_ref_time(1_273_896) + // Standard Error: 925 + .saturating_add(Weight::from_ref_time(527_015).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - // Minimum execution time: 651 nanoseconds. - Weight::from_ref_time(790_908) - // Standard Error: 849 - .saturating_add(Weight::from_ref_time(800_188).saturating_mul(r.into())) + // Minimum execution time: 761 nanoseconds. + Weight::from_ref_time(929_565) + // Standard Error: 1_275 + .saturating_add(Weight::from_ref_time(805_592).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - // Minimum execution time: 622 nanoseconds. - Weight::from_ref_time(416_266) - // Standard Error: 1_574 - .saturating_add(Weight::from_ref_time(1_080_225).saturating_mul(r.into())) + // Minimum execution time: 813 nanoseconds. + Weight::from_ref_time(703_802) + // Standard Error: 1_665 + .saturating_add(Weight::from_ref_time(1_074_321).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - // Minimum execution time: 2_131 nanoseconds. - Weight::from_ref_time(2_540_446) - // Standard Error: 75 - .saturating_add(Weight::from_ref_time(4_997).saturating_mul(e.into())) + // Minimum execution time: 2_347 nanoseconds. + Weight::from_ref_time(2_752_638) + // Standard Error: 69 + .saturating_add(Weight::from_ref_time(4_771).saturating_mul(e.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - // Minimum execution time: 650 nanoseconds. - Weight::from_ref_time(1_577_978) - // Standard Error: 2_696 - .saturating_add(Weight::from_ref_time(2_204_044).saturating_mul(r.into())) + // Minimum execution time: 826 nanoseconds. + Weight::from_ref_time(1_784_596) + // Standard Error: 1_646 + .saturating_add(Weight::from_ref_time(2_189_993).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - // Minimum execution time: 742 nanoseconds. - Weight::from_ref_time(1_947_575) - // Standard Error: 1_651 - .saturating_add(Weight::from_ref_time(2_799_445).saturating_mul(r.into())) + // Minimum execution time: 926 nanoseconds. + Weight::from_ref_time(1_898_358) + // Standard Error: 2_678 + .saturating_add(Weight::from_ref_time(2_811_379).saturating_mul(r.into())) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - // Minimum execution time: 4_230 nanoseconds. - Weight::from_ref_time(5_079_432) - // Standard Error: 315 - .saturating_add(Weight::from_ref_time(179_278).saturating_mul(p.into())) + // Minimum execution time: 4_428 nanoseconds. + Weight::from_ref_time(5_257_445) + // Standard Error: 306 + .saturating_add(Weight::from_ref_time(178_882).saturating_mul(p.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { - // Minimum execution time: 2_830 nanoseconds. - Weight::from_ref_time(3_601_633) - // Standard Error: 31 - .saturating_add(Weight::from_ref_time(92_499).saturating_mul(l.into())) + // Minimum execution time: 2_945 nanoseconds. + Weight::from_ref_time(4_240_619) + // Standard Error: 39 + .saturating_add(Weight::from_ref_time(46_640).saturating_mul(l.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - // Minimum execution time: 2_896 nanoseconds. - Weight::from_ref_time(3_137_247) - // Standard Error: 245 - .saturating_add(Weight::from_ref_time(364_431).saturating_mul(r.into())) + // Minimum execution time: 2_204 nanoseconds. + Weight::from_ref_time(2_430_272) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(365_718).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - // Minimum execution time: 2_795 nanoseconds. - Weight::from_ref_time(3_199_878) - // Standard Error: 549 - .saturating_add(Weight::from_ref_time(380_524).saturating_mul(r.into())) + // Minimum execution time: 2_117 nanoseconds. + Weight::from_ref_time(2_429_354) + // Standard Error: 240 + .saturating_add(Weight::from_ref_time(381_830).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - // Minimum execution time: 2_807 nanoseconds. - Weight::from_ref_time(3_130_120) - // Standard Error: 319 - .saturating_add(Weight::from_ref_time(525_857).saturating_mul(r.into())) + // Minimum execution time: 2_123 nanoseconds. + Weight::from_ref_time(2_460_016) + // Standard Error: 262 + .saturating_add(Weight::from_ref_time(526_554).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - // Minimum execution time: 678 nanoseconds. - Weight::from_ref_time(1_013_348) - // Standard Error: 362 - .saturating_add(Weight::from_ref_time(810_232).saturating_mul(r.into())) + // Minimum execution time: 892 nanoseconds. + Weight::from_ref_time(1_234_618) + // Standard Error: 485 + .saturating_add(Weight::from_ref_time(813_721).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - // Minimum execution time: 624 nanoseconds. - Weight::from_ref_time(973_583) - // Standard Error: 373 - .saturating_add(Weight::from_ref_time(829_360).saturating_mul(r.into())) + // Minimum execution time: 901 nanoseconds. + Weight::from_ref_time(1_182_838) + // Standard Error: 482 + .saturating_add(Weight::from_ref_time(831_308).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - // Minimum execution time: 698 nanoseconds. - Weight::from_ref_time(904_862) - // Standard Error: 360 - .saturating_add(Weight::from_ref_time(694_614).saturating_mul(r.into())) + // Minimum execution time: 929 nanoseconds. + Weight::from_ref_time(1_221_388) + // Standard Error: 434 + .saturating_add(Weight::from_ref_time(693_301).saturating_mul(r.into())) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - // Minimum execution time: 642 nanoseconds. - Weight::from_ref_time(735_085) - // Standard Error: 105_815 - .saturating_add(Weight::from_ref_time(233_816_514).saturating_mul(r.into())) + // Minimum execution time: 808 nanoseconds. + Weight::from_ref_time(906_944) + // Standard Error: 6_164 + .saturating_add(Weight::from_ref_time(187_445_255).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - // Minimum execution time: 606 nanoseconds. - Weight::from_ref_time(850_590) - // Standard Error: 262 - .saturating_add(Weight::from_ref_time(507_721).saturating_mul(r.into())) + // Minimum execution time: 807 nanoseconds. + Weight::from_ref_time(1_064_776) + // Standard Error: 287 + .saturating_add(Weight::from_ref_time(507_278).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - // Minimum execution time: 663 nanoseconds. - Weight::from_ref_time(853_060) - // Standard Error: 250 - .saturating_add(Weight::from_ref_time(514_225).saturating_mul(r.into())) + // Minimum execution time: 776 nanoseconds. + Weight::from_ref_time(1_033_205) + // Standard Error: 443 + .saturating_add(Weight::from_ref_time(512_445).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - // Minimum execution time: 605 nanoseconds. - Weight::from_ref_time(849_563) - // Standard Error: 275 - .saturating_add(Weight::from_ref_time(511_494).saturating_mul(r.into())) + // Minimum execution time: 909 nanoseconds. + Weight::from_ref_time(1_089_083) + // Standard Error: 335 + .saturating_add(Weight::from_ref_time(510_392).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - // Minimum execution time: 618 nanoseconds. - Weight::from_ref_time(839_855) - // Standard Error: 228 - .saturating_add(Weight::from_ref_time(524_614).saturating_mul(r.into())) + // Minimum execution time: 791 nanoseconds. + Weight::from_ref_time(1_063_118) + // Standard Error: 210 + .saturating_add(Weight::from_ref_time(522_817).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - // Minimum execution time: 637 nanoseconds. - Weight::from_ref_time(860_326) + // Minimum execution time: 789 nanoseconds. + Weight::from_ref_time(1_056_006) // Standard Error: 240 - .saturating_add(Weight::from_ref_time(504_847).saturating_mul(r.into())) + .saturating_add(Weight::from_ref_time(505_198).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - // Minimum execution time: 623 nanoseconds. - Weight::from_ref_time(844_585) - // Standard Error: 235 - .saturating_add(Weight::from_ref_time(505_821).saturating_mul(r.into())) + // Minimum execution time: 804 nanoseconds. + Weight::from_ref_time(1_087_882) + // Standard Error: 234 + .saturating_add(Weight::from_ref_time(503_830).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - // Minimum execution time: 672 nanoseconds. - Weight::from_ref_time(826_784) - // Standard Error: 225 - .saturating_add(Weight::from_ref_time(504_632).saturating_mul(r.into())) + // Minimum execution time: 756 nanoseconds. + Weight::from_ref_time(1_050_994) + // Standard Error: 172 + .saturating_add(Weight::from_ref_time(503_343).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - // Minimum execution time: 642 nanoseconds. - Weight::from_ref_time(867_080) - // Standard Error: 231 - .saturating_add(Weight::from_ref_time(732_430).saturating_mul(r.into())) + // Minimum execution time: 775 nanoseconds. + Weight::from_ref_time(1_061_228) + // Standard Error: 232 + .saturating_add(Weight::from_ref_time(730_751).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - // Minimum execution time: 639 nanoseconds. - Weight::from_ref_time(866_094) - // Standard Error: 272 - .saturating_add(Weight::from_ref_time(732_560).saturating_mul(r.into())) + // Minimum execution time: 809 nanoseconds. + Weight::from_ref_time(1_080_957) + // Standard Error: 320 + .saturating_add(Weight::from_ref_time(732_246).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - // Minimum execution time: 619 nanoseconds. - Weight::from_ref_time(928_672) - // Standard Error: 484 - .saturating_add(Weight::from_ref_time(739_523).saturating_mul(r.into())) + // Minimum execution time: 808 nanoseconds. + Weight::from_ref_time(1_055_752) + // Standard Error: 496 + .saturating_add(Weight::from_ref_time(740_084).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - // Minimum execution time: 612 nanoseconds. - Weight::from_ref_time(863_312) - // Standard Error: 328 - .saturating_add(Weight::from_ref_time(743_687).saturating_mul(r.into())) + // Minimum execution time: 792 nanoseconds. + Weight::from_ref_time(1_111_972) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(741_581).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - // Minimum execution time: 648 nanoseconds. - Weight::from_ref_time(931_331) - // Standard Error: 612 - .saturating_add(Weight::from_ref_time(747_653).saturating_mul(r.into())) + // Minimum execution time: 862 nanoseconds. + Weight::from_ref_time(1_111_246) + // Standard Error: 263 + .saturating_add(Weight::from_ref_time(746_026).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - // Minimum execution time: 632 nanoseconds. - Weight::from_ref_time(868_901) - // Standard Error: 276 - .saturating_add(Weight::from_ref_time(744_778).saturating_mul(r.into())) + // Minimum execution time: 810 nanoseconds. + Weight::from_ref_time(1_094_933) + // Standard Error: 271 + .saturating_add(Weight::from_ref_time(743_645).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - // Minimum execution time: 629 nanoseconds. - Weight::from_ref_time(898_516) - // Standard Error: 288 - .saturating_add(Weight::from_ref_time(734_393).saturating_mul(r.into())) + // Minimum execution time: 769 nanoseconds. + Weight::from_ref_time(819_933) + // Standard Error: 4_528 + .saturating_add(Weight::from_ref_time(751_599).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - // Minimum execution time: 603 nanoseconds. - Weight::from_ref_time(853_744) - // Standard Error: 204 - .saturating_add(Weight::from_ref_time(739_499).saturating_mul(r.into())) + // Minimum execution time: 797 nanoseconds. + Weight::from_ref_time(1_107_352) + // Standard Error: 344 + .saturating_add(Weight::from_ref_time(738_684).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - // Minimum execution time: 625 nanoseconds. - Weight::from_ref_time(885_174) - // Standard Error: 238 - .saturating_add(Weight::from_ref_time(734_010).saturating_mul(r.into())) + // Minimum execution time: 784 nanoseconds. + Weight::from_ref_time(1_068_487) + // Standard Error: 3_796 + .saturating_add(Weight::from_ref_time(741_207).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - // Minimum execution time: 602 nanoseconds. - Weight::from_ref_time(915_329) - // Standard Error: 273 - .saturating_add(Weight::from_ref_time(738_209).saturating_mul(r.into())) + // Minimum execution time: 813 nanoseconds. + Weight::from_ref_time(1_067_278) + // Standard Error: 459 + .saturating_add(Weight::from_ref_time(737_841).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - // Minimum execution time: 585 nanoseconds. - Weight::from_ref_time(862_239) - // Standard Error: 294 - .saturating_add(Weight::from_ref_time(719_000).saturating_mul(r.into())) + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_100_254) + // Standard Error: 297 + .saturating_add(Weight::from_ref_time(717_622).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - // Minimum execution time: 633 nanoseconds. - Weight::from_ref_time(881_696) - // Standard Error: 195 - .saturating_add(Weight::from_ref_time(713_153).saturating_mul(r.into())) + // Minimum execution time: 778 nanoseconds. + Weight::from_ref_time(1_063_748) + // Standard Error: 378 + .saturating_add(Weight::from_ref_time(713_577).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - // Minimum execution time: 629 nanoseconds. - Weight::from_ref_time(856_238) - // Standard Error: 269 - .saturating_add(Weight::from_ref_time(715_451).saturating_mul(r.into())) + // Minimum execution time: 780 nanoseconds. + Weight::from_ref_time(1_088_755) + // Standard Error: 316 + .saturating_add(Weight::from_ref_time(714_127).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - // Minimum execution time: 633 nanoseconds. - Weight::from_ref_time(880_804) - // Standard Error: 725 - .saturating_add(Weight::from_ref_time(1_349_577).saturating_mul(r.into())) + // Minimum execution time: 776 nanoseconds. + Weight::from_ref_time(1_062_591) + // Standard Error: 610 + .saturating_add(Weight::from_ref_time(1_355_430).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - // Minimum execution time: 639 nanoseconds. - Weight::from_ref_time(867_528) - // Standard Error: 1_940 - .saturating_add(Weight::from_ref_time(1_287_959).saturating_mul(r.into())) + // Minimum execution time: 801 nanoseconds. + Weight::from_ref_time(1_092_395) + // Standard Error: 423 + .saturating_add(Weight::from_ref_time(1_282_356).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - // Minimum execution time: 595 nanoseconds. - Weight::from_ref_time(851_253) - // Standard Error: 503 - .saturating_add(Weight::from_ref_time(1_398_668).saturating_mul(r.into())) + // Minimum execution time: 822 nanoseconds. + Weight::from_ref_time(1_083_079) + // Standard Error: 562 + .saturating_add(Weight::from_ref_time(1_398_522).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - // Minimum execution time: 604 nanoseconds. - Weight::from_ref_time(804_977) - // Standard Error: 812 - .saturating_add(Weight::from_ref_time(1_288_816).saturating_mul(r.into())) + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_088_997) + // Standard Error: 401 + .saturating_add(Weight::from_ref_time(1_283_442).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - // Minimum execution time: 609 nanoseconds. - Weight::from_ref_time(890_945) - // Standard Error: 1_645 - .saturating_add(Weight::from_ref_time(719_770).saturating_mul(r.into())) + // Minimum execution time: 815 nanoseconds. + Weight::from_ref_time(1_081_903) + // Standard Error: 264 + .saturating_add(Weight::from_ref_time(718_069).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - // Minimum execution time: 628 nanoseconds. - Weight::from_ref_time(897_973) - // Standard Error: 1_641 - .saturating_add(Weight::from_ref_time(718_838).saturating_mul(r.into())) + // Minimum execution time: 813 nanoseconds. + Weight::from_ref_time(1_091_426) + // Standard Error: 296 + .saturating_add(Weight::from_ref_time(717_894).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - // Minimum execution time: 634 nanoseconds. - Weight::from_ref_time(848_440) - // Standard Error: 249 - .saturating_add(Weight::from_ref_time(718_206).saturating_mul(r.into())) + // Minimum execution time: 794 nanoseconds. + Weight::from_ref_time(1_040_144) + // Standard Error: 400 + .saturating_add(Weight::from_ref_time(719_886).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - // Minimum execution time: 625 nanoseconds. - Weight::from_ref_time(881_579) - // Standard Error: 273 - .saturating_add(Weight::from_ref_time(736_934).saturating_mul(r.into())) + // Minimum execution time: 774 nanoseconds. + Weight::from_ref_time(1_092_466) + // Standard Error: 4_173 + .saturating_add(Weight::from_ref_time(739_873).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - // Minimum execution time: 630 nanoseconds. - Weight::from_ref_time(897_813) - // Standard Error: 249 - .saturating_add(Weight::from_ref_time(734_657).saturating_mul(r.into())) + // Minimum execution time: 793 nanoseconds. + Weight::from_ref_time(1_105_611) + // Standard Error: 394 + .saturating_add(Weight::from_ref_time(735_358).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - // Minimum execution time: 607 nanoseconds. - Weight::from_ref_time(871_660) - // Standard Error: 312 - .saturating_add(Weight::from_ref_time(735_377).saturating_mul(r.into())) + // Minimum execution time: 805 nanoseconds. + Weight::from_ref_time(1_130_462) + // Standard Error: 327 + .saturating_add(Weight::from_ref_time(734_198).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - // Minimum execution time: 610 nanoseconds. - Weight::from_ref_time(861_640) - // Standard Error: 293 - .saturating_add(Weight::from_ref_time(735_524).saturating_mul(r.into())) + // Minimum execution time: 831 nanoseconds. + Weight::from_ref_time(1_118_894) + // Standard Error: 389 + .saturating_add(Weight::from_ref_time(733_834).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - // Minimum execution time: 625 nanoseconds. - Weight::from_ref_time(880_203) - // Standard Error: 373 - .saturating_add(Weight::from_ref_time(737_354).saturating_mul(r.into())) + // Minimum execution time: 772 nanoseconds. + Weight::from_ref_time(1_123_733) + // Standard Error: 337 + .saturating_add(Weight::from_ref_time(733_923).saturating_mul(r.into())) } } From 293c1f24e968a8d956250324fb7e91b7df4507df Mon Sep 17 00:00:00 2001 From: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Date: Wed, 11 Jan 2023 15:27:59 +0200 Subject: [PATCH 02/80] [NFTs] Track item's metadata depositor (#13124) * Refactor do_mint() * Track the depositor of item's metadata * Revert back the access control * On collection destroy return the metadata deposit * Clear the metadata on item burn returning the deposit * Address comments * Fix clippy * Don't return Ok on non-existing attribute removal --- frame/nfts/src/features/attributes.rs | 105 +++++++++--------- .../src/features/create_delete_collection.rs | 13 ++- frame/nfts/src/features/create_delete_item.rs | 31 ++++-- frame/nfts/src/features/metadata.rs | 69 ++++++++---- frame/nfts/src/impl_nonfungibles.rs | 6 +- frame/nfts/src/lib.rs | 17 +-- frame/nfts/src/tests.rs | 4 +- frame/nfts/src/types.rs | 22 +++- 8 files changed, 161 insertions(+), 106 deletions(-) diff --git a/frame/nfts/src/features/attributes.rs b/frame/nfts/src/features/attributes.rs index da663d39a4..b25f2a60cd 100644 --- a/frame/nfts/src/features/attributes.rs +++ b/frame/nfts/src/features/attributes.rs @@ -152,65 +152,68 @@ impl, I: 'static> Pallet { namespace: AttributeNamespace, key: BoundedVec, ) -> DispatchResult { - if let Some((_, deposit)) = - Attribute::::take((collection, maybe_item, &namespace, &key)) - { - let mut collection_details = - Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - - if let Some(check_owner) = &maybe_check_owner { - if deposit.account != maybe_check_owner { - ensure!( - Self::is_valid_namespace( - &check_owner, - &namespace, - &collection, - &collection_details.owner, - &maybe_item, - )?, - Error::::NoPermission - ); - } + let (_, deposit) = Attribute::::take((collection, maybe_item, &namespace, &key)) + .ok_or(Error::::AttributeNotFound)?; + let mut collection_details = + Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; - // can't clear `CollectionOwner` type attributes if the collection/item is locked - match namespace { - AttributeNamespace::CollectionOwner => match maybe_item { - None => { - let collection_config = Self::get_collection_config(&collection)?; - ensure!( - collection_config - .is_setting_enabled(CollectionSetting::UnlockedAttributes), - Error::::LockedCollectionAttributes - ) - }, - Some(item) => { - // NOTE: if the item was previously burned, the ItemConfigOf record - // might not exist. In that case, we allow to clear the attribute. - let maybe_is_locked = Self::get_item_config(&collection, &item) - .map_or(false, |c| { - c.has_disabled_setting(ItemSetting::UnlockedAttributes) - }); - ensure!(!maybe_is_locked, Error::::LockedItemAttributes); - }, - }, - _ => (), - }; + if let Some(check_owner) = &maybe_check_owner { + // validate the provided namespace when it's not a root call and the caller is not + // the same as the `deposit.account` (e.g. the deposit was paid by different account) + if deposit.account != maybe_check_owner { + ensure!( + Self::is_valid_namespace( + &check_owner, + &namespace, + &collection, + &collection_details.owner, + &maybe_item, + )?, + Error::::NoPermission + ); } - collection_details.attributes.saturating_dec(); + // can't clear `CollectionOwner` type attributes if the collection/item is locked match namespace { - AttributeNamespace::CollectionOwner => { - collection_details.owner_deposit.saturating_reduce(deposit.amount); - T::Currency::unreserve(&collection_details.owner, deposit.amount); + AttributeNamespace::CollectionOwner => match maybe_item { + None => { + let collection_config = Self::get_collection_config(&collection)?; + ensure!( + collection_config + .is_setting_enabled(CollectionSetting::UnlockedAttributes), + Error::::LockedCollectionAttributes + ) + }, + Some(item) => { + // NOTE: if the item was previously burned, the ItemConfigOf record + // might not exist. In that case, we allow to clear the attribute. + let maybe_is_locked = Self::get_item_config(&collection, &item) + .map_or(false, |c| { + c.has_disabled_setting(ItemSetting::UnlockedAttributes) + }); + ensure!(!maybe_is_locked, Error::::LockedItemAttributes); + }, }, _ => (), }; - if let Some(deposit_account) = deposit.account { - T::Currency::unreserve(&deposit_account, deposit.amount); - } - Collection::::insert(collection, &collection_details); - Self::deposit_event(Event::AttributeCleared { collection, maybe_item, key, namespace }); } + + collection_details.attributes.saturating_dec(); + match namespace { + AttributeNamespace::CollectionOwner => { + collection_details.owner_deposit.saturating_reduce(deposit.amount); + T::Currency::unreserve(&collection_details.owner, deposit.amount); + }, + _ => (), + }; + + if let Some(deposit_account) = deposit.account { + T::Currency::unreserve(&deposit_account, deposit.amount); + } + + Collection::::insert(collection, &collection_details); + Self::deposit_event(Event::AttributeCleared { collection, maybe_item, key, namespace }); + Ok(()) } diff --git a/frame/nfts/src/features/create_delete_collection.rs b/frame/nfts/src/features/create_delete_collection.rs index 86625bf49e..a2caa04bc8 100644 --- a/frame/nfts/src/features/create_delete_collection.rs +++ b/frame/nfts/src/features/create_delete_collection.rs @@ -82,12 +82,13 @@ impl, I: 'static> Pallet { Account::::remove((&details.owner, &collection, &item)); T::Currency::unreserve(&details.deposit.account, details.deposit.amount); } - #[allow(deprecated)] - ItemMetadataOf::::remove_prefix(&collection, None); - #[allow(deprecated)] - ItemPriceOf::::remove_prefix(&collection, None); - #[allow(deprecated)] - PendingSwapOf::::remove_prefix(&collection, None); + for (_, metadata) in ItemMetadataOf::::drain_prefix(&collection) { + if let Some(depositor) = metadata.deposit.account { + T::Currency::unreserve(&depositor, metadata.deposit.amount); + } + } + let _ = ItemPriceOf::::clear_prefix(&collection, witness.items, None); + let _ = PendingSwapOf::::clear_prefix(&collection, witness.items, None); CollectionMetadataOf::::remove(&collection); Self::clear_roles(&collection)?; diff --git a/frame/nfts/src/features/create_delete_item.rs b/frame/nfts/src/features/create_delete_item.rs index 8d6c8a2809..f724fe5c63 100644 --- a/frame/nfts/src/features/create_delete_item.rs +++ b/frame/nfts/src/features/create_delete_item.rs @@ -22,10 +22,9 @@ impl, I: 'static> Pallet { pub fn do_mint( collection: T::CollectionId, item: T::ItemId, - depositor: T::AccountId, + maybe_depositor: Option, mint_to: T::AccountId, item_config: ItemConfig, - deposit_collection_owner: bool, with_details_and_config: impl FnOnce( &CollectionDetailsFor, &CollectionConfigFor, @@ -55,9 +54,9 @@ impl, I: 'static> Pallet { true => T::ItemDeposit::get(), false => Zero::zero(), }; - let deposit_account = match deposit_collection_owner { - true => collection_details.owner.clone(), - false => depositor, + let deposit_account = match maybe_depositor { + None => collection_details.owner.clone(), + Some(depositor) => depositor, }; let item_owner = mint_to.clone(); @@ -92,6 +91,7 @@ impl, I: 'static> Pallet { with_details: impl FnOnce(&ItemDetailsFor) -> DispatchResult, ) -> DispatchResult { ensure!(!T::Locker::is_locked(collection, item), Error::::ItemLocked); + let item_config = Self::get_item_config(&collection, &item)?; let owner = Collection::::try_mutate( &collection, |maybe_collection_details| -> Result { @@ -104,6 +104,24 @@ impl, I: 'static> Pallet { // Return the deposit. T::Currency::unreserve(&details.deposit.account, details.deposit.amount); collection_details.items.saturating_dec(); + + // Clear the metadata if it's not locked. + if item_config.is_setting_enabled(ItemSetting::UnlockedMetadata) { + if let Some(metadata) = ItemMetadataOf::::take(&collection, &item) { + let depositor_account = + metadata.deposit.account.unwrap_or(collection_details.owner.clone()); + + T::Currency::unreserve(&depositor_account, metadata.deposit.amount); + collection_details.item_metadatas.saturating_dec(); + + if depositor_account == collection_details.owner { + collection_details + .owner_deposit + .saturating_reduce(metadata.deposit.amount); + } + } + } + Ok(details.owner) }, )?; @@ -116,8 +134,7 @@ impl, I: 'static> Pallet { // NOTE: if item's settings are not empty (e.g. item's metadata is locked) // then we keep the record and don't remove it - let config = Self::get_item_config(&collection, &item)?; - if !config.has_disabled_settings() { + if !item_config.has_disabled_settings() { ItemConfigOf::::remove(&collection, &item); } diff --git a/frame/nfts/src/features/metadata.rs b/frame/nfts/src/features/metadata.rs index 942f377141..272b224742 100644 --- a/frame/nfts/src/features/metadata.rs +++ b/frame/nfts/src/features/metadata.rs @@ -19,19 +19,21 @@ use crate::*; use frame_support::pallet_prelude::*; impl, I: 'static> Pallet { + /// Note: if `maybe_depositor` is None, that means the depositor will be a collection's owner pub(crate) fn do_set_item_metadata( maybe_check_owner: Option, collection: T::CollectionId, item: T::ItemId, data: BoundedVec, + maybe_depositor: Option, ) -> DispatchResult { + let is_root = maybe_check_owner.is_none(); let mut collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; let item_config = Self::get_item_config(&collection, &item)?; ensure!( - maybe_check_owner.is_none() || - item_config.is_setting_enabled(ItemSetting::UnlockedMetadata), + is_root || item_config.is_setting_enabled(ItemSetting::UnlockedMetadata), Error::::LockedItemMetadata ); @@ -45,24 +47,38 @@ impl, I: 'static> Pallet { if metadata.is_none() { collection_details.item_metadatas.saturating_inc(); } - let old_deposit = metadata.take().map_or(Zero::zero(), |m| m.deposit); - collection_details.owner_deposit.saturating_reduce(old_deposit); + + let old_deposit = metadata + .take() + .map_or(ItemMetadataDeposit { account: None, amount: Zero::zero() }, |m| m.deposit); + let mut deposit = Zero::zero(); - if collection_config.is_setting_enabled(CollectionSetting::DepositRequired) && - maybe_check_owner.is_some() + if collection_config.is_setting_enabled(CollectionSetting::DepositRequired) && !is_root { deposit = T::DepositPerByte::get() .saturating_mul(((data.len()) as u32).into()) .saturating_add(T::MetadataDepositBase::get()); } - if deposit > old_deposit { - T::Currency::reserve(&collection_details.owner, deposit - old_deposit)?; - } else if deposit < old_deposit { - T::Currency::unreserve(&collection_details.owner, old_deposit - deposit); + + // the previous deposit was taken from the item's owner + if old_deposit.account.is_some() && maybe_depositor.is_none() { + T::Currency::unreserve(&old_deposit.account.unwrap(), old_deposit.amount); + T::Currency::reserve(&collection_details.owner, deposit)?; + } else if deposit > old_deposit.amount { + T::Currency::reserve(&collection_details.owner, deposit - old_deposit.amount)?; + } else if deposit < old_deposit.amount { + T::Currency::unreserve(&collection_details.owner, old_deposit.amount - deposit); + } + + if maybe_depositor.is_none() { + collection_details.owner_deposit.saturating_accrue(deposit); + collection_details.owner_deposit.saturating_reduce(old_deposit.amount); } - collection_details.owner_deposit.saturating_accrue(deposit); - *metadata = Some(ItemMetadata { deposit, data: data.clone() }); + *metadata = Some(ItemMetadata { + deposit: ItemMetadataDeposit { account: maybe_depositor, amount: deposit }, + data: data.clone(), + }); Collection::::insert(&collection, &collection_details); Self::deposit_event(Event::ItemMetadataSet { collection, item, data }); @@ -75,8 +91,14 @@ impl, I: 'static> Pallet { collection: T::CollectionId, item: T::ItemId, ) -> DispatchResult { + let is_root = maybe_check_owner.is_none(); + let metadata = ItemMetadataOf::::take(collection, item) + .ok_or(Error::::MetadataNotFound)?; let mut collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; + let depositor_account = + metadata.deposit.account.unwrap_or(collection_details.owner.clone()); + if let Some(check_owner) = &maybe_check_owner { ensure!(check_owner == &collection_details.owner, Error::::NoPermission); } @@ -85,20 +107,19 @@ impl, I: 'static> Pallet { let is_locked = Self::get_item_config(&collection, &item) .map_or(false, |c| c.has_disabled_setting(ItemSetting::UnlockedMetadata)); - ensure!(maybe_check_owner.is_none() || !is_locked, Error::::LockedItemMetadata); + ensure!(is_root || !is_locked, Error::::LockedItemMetadata); - ItemMetadataOf::::try_mutate_exists(collection, item, |metadata| { - if metadata.is_some() { - collection_details.item_metadatas.saturating_dec(); - } - let deposit = metadata.take().ok_or(Error::::UnknownItem)?.deposit; - T::Currency::unreserve(&collection_details.owner, deposit); - collection_details.owner_deposit.saturating_reduce(deposit); + collection_details.item_metadatas.saturating_dec(); + T::Currency::unreserve(&depositor_account, metadata.deposit.amount); - Collection::::insert(&collection, &collection_details); - Self::deposit_event(Event::ItemMetadataCleared { collection, item }); - Ok(()) - }) + if depositor_account == collection_details.owner { + collection_details.owner_deposit.saturating_reduce(metadata.deposit.amount); + } + + Collection::::insert(&collection, &collection_details); + Self::deposit_event(Event::ItemMetadataCleared { collection, item }); + + Ok(()) } pub(crate) fn do_set_collection_metadata( diff --git a/frame/nfts/src/impl_nonfungibles.rs b/frame/nfts/src/impl_nonfungibles.rs index ab4d7a16ec..86d82b4021 100644 --- a/frame/nfts/src/impl_nonfungibles.rs +++ b/frame/nfts/src/impl_nonfungibles.rs @@ -157,10 +157,12 @@ impl, I: 'static> Mutate<::AccountId, ItemConfig Self::do_mint( *collection, *item, - who.clone(), + match deposit_collection_owner { + true => None, + false => Some(who.clone()), + }, who.clone(), *item_config, - deposit_collection_owner, |_, _| Ok(()), ) } diff --git a/frame/nfts/src/lib.rs b/frame/nfts/src/lib.rs index 9a6242143a..8f24c8dcd6 100644 --- a/frame/nfts/src/lib.rs +++ b/frame/nfts/src/lib.rs @@ -263,7 +263,7 @@ pub mod pallet { T::CollectionId, Blake2_128Concat, T::ItemId, - ItemMetadata, T::StringLimit>, + ItemMetadata, T::StringLimit>, OptionQuery, >; @@ -559,6 +559,10 @@ pub mod pallet { UnknownItem, /// Swap doesn't exist. UnknownSwap, + /// The given item has no metadata set. + MetadataNotFound, + /// The provided attribute can't be found. + AttributeNotFound, /// Item is not for sale. NotForSale, /// The provided bid is too low. @@ -746,10 +750,9 @@ pub mod pallet { Self::do_mint( collection, item, - caller.clone(), + Some(caller.clone()), mint_to.clone(), item_config, - false, |collection_details, collection_config| { // Issuer can mint regardless of mint settings if Self::has_role(&collection, &caller, CollectionRole::Issuer) { @@ -849,9 +852,7 @@ pub mod pallet { Error::::NoPermission ); } - Self::do_mint(collection, item, mint_to.clone(), mint_to, item_config, true, |_, _| { - Ok(()) - }) + Self::do_mint(collection, item, None, mint_to, item_config, |_, _| Ok(())) } /// Destroy a single item. @@ -1362,7 +1363,7 @@ pub mod pallet { /// Clear an attribute for a collection or item. /// /// Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the - /// `collection`. + /// attribute. /// /// Any deposit is freed for the collection's owner. /// @@ -1464,7 +1465,7 @@ pub mod pallet { let maybe_check_owner = T::ForceOrigin::try_origin(origin) .map(|_| None) .or_else(|origin| ensure_signed(origin).map(Some).map_err(DispatchError::from))?; - Self::do_set_item_metadata(maybe_check_owner, collection, item, data) + Self::do_set_item_metadata(maybe_check_owner, collection, item, data, None) } /// Clear the metadata for an item. diff --git a/frame/nfts/src/tests.rs b/frame/nfts/src/tests.rs index f8187b3777..ebbba33b04 100644 --- a/frame/nfts/src/tests.rs +++ b/frame/nfts/src/tests.rs @@ -608,7 +608,7 @@ fn set_item_metadata_should_work() { ); assert_noop!( Nfts::clear_metadata(RuntimeOrigin::signed(1), 1, 42), - Error::::UnknownCollection, + Error::::MetadataNotFound, ); assert_ok!(Nfts::clear_metadata(RuntimeOrigin::root(), 0, 42)); assert!(!ItemMetadataOf::::contains_key(0, 42)); @@ -1267,7 +1267,7 @@ fn burn_works() { assert_noop!( Nfts::burn(RuntimeOrigin::signed(5), 0, 42, Some(5)), - Error::::UnknownCollection + Error::::UnknownItem ); assert_ok!(Nfts::force_mint(RuntimeOrigin::signed(2), 0, 42, 5, default_item_config())); diff --git a/frame/nfts/src/types.rs b/frame/nfts/src/types.rs index 9b89fb964b..d8938aab43 100644 --- a/frame/nfts/src/types.rs +++ b/frame/nfts/src/types.rs @@ -43,6 +43,8 @@ pub(super) type ItemDepositOf = ItemDeposit, ::AccountId>; pub(super) type AttributeDepositOf = AttributeDeposit, ::AccountId>; +pub(super) type ItemMetadataDepositOf = + ItemMetadataDeposit, ::AccountId>; pub(super) type ItemDetailsFor = ItemDetails<::AccountId, ItemDepositOf, ApprovalsOf>; pub(super) type BalanceOf = @@ -137,12 +139,12 @@ pub struct ItemDeposit { /// Information about the collection's metadata. #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(StringLimit))] -#[codec(mel_bound(DepositBalance: MaxEncodedLen))] -pub struct CollectionMetadata> { +#[codec(mel_bound(Deposit: MaxEncodedLen))] +pub struct CollectionMetadata> { /// The balance deposited for this metadata. /// /// This pays for the data stored in this struct. - pub(super) deposit: DepositBalance, + pub(super) deposit: Deposit, /// General information concerning this collection. Limited in length by `StringLimit`. This /// will generally be either a JSON dump or the hash of some JSON which can be found on a /// hash-addressable global publication system such as IPFS. @@ -152,12 +154,11 @@ pub struct CollectionMetadata> { /// Information about the item's metadata. #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)] #[scale_info(skip_type_params(StringLimit))] -#[codec(mel_bound(DepositBalance: MaxEncodedLen))] -pub struct ItemMetadata> { +pub struct ItemMetadata> { /// The balance deposited for this metadata. /// /// This pays for the data stored in this struct. - pub(super) deposit: DepositBalance, + pub(super) deposit: Deposit, /// General information concerning this item. Limited in length by `StringLimit`. This will /// generally be either a JSON dump or the hash of some JSON which can be found on a /// hash-addressable global publication system such as IPFS. @@ -199,6 +200,15 @@ pub struct AttributeDeposit { pub(super) amount: DepositBalance, } +/// Information about the reserved item's metadata deposit. +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub struct ItemMetadataDeposit { + /// A depositor account, None means the deposit is collection's owner. + pub(super) account: Option, + /// An amount that gets reserved. + pub(super) amount: DepositBalance, +} + /// Specifies whether the tokens will be sent or received. #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum PriceDirection { From e752af116c0b92e37bb5aeef19d3934cc9347439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 11 Jan 2023 16:40:52 +0100 Subject: [PATCH 03/80] `IntegrityTest` implementation should be feature gated (#13094) * `IntegrityTest` implementation should be feature gated The initial implementation for the old declarative macros is still feature gating the implementation. As we only call this in a test, there is no need to have this compiled for wasm. * Don't assume that all "consumers" have a `std` feature --- .../procedural/src/pallet/expand/hooks.rs | 19 +++++++++++-------- frame/support/src/lib.rs | 3 +++ frame/system/benches/bench.rs | 5 +---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index c2b70c5632..c41a65b57b 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -191,16 +191,19 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { } } - impl<#type_impl_gen> - #frame_support::traits::IntegrityTest + // Integrity tests are only required for when `std` is enabled. + #frame_support::std_enabled! { + impl<#type_impl_gen> + #frame_support::traits::IntegrityTest for #pallet_ident<#type_use_gen> #where_clause - { - fn integrity_test() { - < - Self as #frame_support::traits::Hooks< + { + fn integrity_test() { + < + Self as #frame_support::traits::Hooks< ::BlockNumber - > - >::integrity_test() + > + >::integrity_test() + } } } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index efecbb75f9..902893972f 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2744,3 +2744,6 @@ pub mod pallet_macros { type_value, unbounded, validate_unsigned, weight, whitelist_storage, }; } + +// Generate a macro that will enable/disable code based on `std` feature being active. +sp_core::generate_feature_enabled_macro!(std_enabled, feature = "std", $); diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index a623a17dc4..f2acc319d3 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -16,10 +16,7 @@ // limitations under the License. use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use frame_support::{ - traits::{ConstU32, ConstU64}, - weights::Weight, -}; +use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ testing::Header, From ad58606c403e13cb1819174ec311d82a02e40028 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Jan 2023 15:59:13 +0000 Subject: [PATCH 04/80] Bump git2 from 0.14.4 to 0.16.0 (#13123) Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.14.4 to 0.16.0. - [Release notes](https://github.com/rust-lang/git2-rs/releases) - [Commits](https://github.com/rust-lang/git2-rs/compare/0.14.4...git2-curl-0.16.0) --- updated-dependencies: - dependency-name: git2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- utils/frame/generate-bags/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb644202ae..68c144b3f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2705,9 +2705,9 @@ checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" [[package]] name = "git2" -version = "0.14.4" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0155506aab710a86160ddb504a480d2964d7ab5b9e62419be69e0032bc5931c" +checksum = "be36bc9e0546df253c0cc41fd0af34f5e92845ad8509462ec76672fac6997f5b" dependencies = [ "bitflags", "libc", @@ -3570,9 +3570,9 @@ checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libgit2-sys" -version = "0.13.4+1.4.2" +version = "0.14.1+1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0fa6563431ede25f5cc7f6d803c6afbc1c5d3ad3d4925d12c882bf2b526f5d1" +checksum = "4a07fb2692bc3593bda59de45a502bb3071659f2c515e28c71e728306b038e17" dependencies = [ "cc", "libc", diff --git a/utils/frame/generate-bags/Cargo.toml b/utils/frame/generate-bags/Cargo.toml index 6006cdb5da..a24af6a270 100644 --- a/utils/frame/generate-bags/Cargo.toml +++ b/utils/frame/generate-bags/Cargo.toml @@ -17,5 +17,5 @@ pallet-staking = { version = "4.0.0-dev", path = "../../../frame/staking" } # third party chrono = { version = "0.4.19" } -git2 = { version = "0.14.2", default-features = false } +git2 = { version = "0.16.0", default-features = false } num-format = "0.4.3" From 6d3596f8a04873f965cf401a84e52d4404337424 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 11 Jan 2023 17:16:56 +0100 Subject: [PATCH 05/80] Scheduler is already at V4 (#13105) * Scheduler is already at V4 Signed-off-by: Oliver Tale-Yazdi * Fix Referenda log target Signed-off-by: Oliver Tale-Yazdi * Fix test Signed-off-by: Oliver Tale-Yazdi Signed-off-by: Oliver Tale-Yazdi --- frame/referenda/src/migration.rs | 2 +- frame/scheduler/src/lib.rs | 2 +- frame/scheduler/src/tests.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/referenda/src/migration.rs b/frame/referenda/src/migration.rs index e495090c13..39575556e4 100644 --- a/frame/referenda/src/migration.rs +++ b/frame/referenda/src/migration.rs @@ -88,7 +88,7 @@ pub mod v1 { use super::*; /// The log target. - const TARGET: &'static str = "runtime::democracy::migration::v1"; + const TARGET: &'static str = "runtime::referenda::migration::v1"; /// Transforms a submission deposit of ReferendumInfo(Approved|Rejected|Cancelled|TimedOut) to /// optional value, making it refundable. diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 20e1420676..afc4fd66e7 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -169,7 +169,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; /// The current storage version. - const STORAGE_VERSION: StorageVersion = StorageVersion::new(3); + const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] diff --git a/frame/scheduler/src/tests.rs b/frame/scheduler/src/tests.rs index 7c261fdd74..e5467fc8db 100644 --- a/frame/scheduler/src/tests.rs +++ b/frame/scheduler/src/tests.rs @@ -973,7 +973,7 @@ fn migration_to_v4_works() { } assert_eq_uvec!(x, expected); - assert_eq!(Scheduler::current_storage_version(), 3); + assert_eq!(Scheduler::on_chain_storage_version(), 4); }); } From f9d1dcdfa1f0a2edc2b933a0b11ffd499c22c73a Mon Sep 17 00:00:00 2001 From: David Dunn <26876072+doubledup@users.noreply.github.com> Date: Thu, 12 Jan 2023 07:23:57 +0200 Subject: [PATCH 06/80] Optimize merkle proofs for efficient verification in Solidity (#12857) * Sort hashes when generating & verifying MMR proofs * Remove unused variables * Double-hash leaves in beefy-merkle-tree * Revert "Double-hash leaves in beefy-merkle-tree" This reverts commit f788f5ed85e575a866639316aaef29dffbcd1c8c. * Retry Polkadot companion CI jobs --- frame/beefy-mmr/primitives/src/lib.rs | 46 ++++++++++++++------------ frame/beefy-mmr/src/tests.rs | 10 +++--- frame/merkle-mountain-range/src/lib.rs | 3 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/frame/beefy-mmr/primitives/src/lib.rs b/frame/beefy-mmr/primitives/src/lib.rs index f88fb89aca..e6f8acefb0 100644 --- a/frame/beefy-mmr/primitives/src/lib.rs +++ b/frame/beefy-mmr/primitives/src/lib.rs @@ -27,7 +27,8 @@ //! Merkle Tree is constructed from arbitrary-length leaves, that are initially hashed using the //! same hasher as the inner nodes. //! Inner nodes are created by concatenating child hashes and hashing again. The implementation -//! does not perform any sorting of the input data (leaves) nor when inner nodes are created. +//! sorts each pair of hashes before every hash operation. This makes proof verification more +//! efficient by removing the need to track which side each intermediate hash is concatenated on. //! //! If the number of leaves is not even, last leaf (hash of) is promoted to the upper layer. @@ -45,7 +46,7 @@ use beefy_primitives::mmr::{BeefyAuthoritySet, BeefyNextAuthoritySet}; pub fn merkle_root(leaves: I) -> H::Output where H: HashT, - H::Output: Default + AsRef<[u8]>, + H::Output: Default + AsRef<[u8]> + PartialOrd, I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -56,7 +57,7 @@ where fn merkelize(leaves: I, visitor: &mut V) -> H::Output where H: HashT, - H::Output: Default + AsRef<[u8]>, + H::Output: Default + AsRef<[u8]> + PartialOrd, V: Visitor, I: Iterator, { @@ -141,7 +142,7 @@ impl Visitor for () { pub fn merkle_proof(leaves: I, leaf_index: usize) -> MerkleProof where H: HashT, - H::Output: Default + Copy + AsRef<[u8]>, + H::Output: Default + Copy + AsRef<[u8]> + PartialOrd, I: IntoIterator, I::IntoIter: ExactSizeIterator, T: AsRef<[u8]>, @@ -241,7 +242,7 @@ pub fn verify_proof<'a, H, P, L>( ) -> bool where H: HashT, - H::Output: PartialEq + AsRef<[u8]>, + H::Output: PartialEq + AsRef<[u8]> + PartialOrd, P: IntoIterator, L: Into>, { @@ -256,15 +257,13 @@ where let hash_len = ::LENGTH; let mut combined = vec![0_u8; hash_len * 2]; - let mut position = leaf_index; - let mut width = number_of_leaves; let computed = proof.into_iter().fold(leaf_hash, |a, b| { - if position % 2 == 1 || position + 1 == width { - combined[..hash_len].copy_from_slice(&b.as_ref()); - combined[hash_len..].copy_from_slice(&a.as_ref()); - } else { + if a < b { combined[..hash_len].copy_from_slice(&a.as_ref()); combined[hash_len..].copy_from_slice(&b.as_ref()); + } else { + combined[..hash_len].copy_from_slice(&b.as_ref()); + combined[hash_len..].copy_from_slice(&a.as_ref()); } let hash = ::hash(&combined); #[cfg(feature = "debug")] @@ -275,8 +274,6 @@ where array_bytes::bytes2hex("", &hash.as_ref()), array_bytes::bytes2hex("", &combined.as_ref()) ); - position /= 2; - width = ((width - 1) / 2) + 1; hash }); @@ -295,7 +292,7 @@ fn merkelize_row( ) -> Result> where H: HashT, - H::Output: AsRef<[u8]>, + H::Output: AsRef<[u8]> + PartialOrd, V: Visitor, I: Iterator, { @@ -321,8 +318,13 @@ where index += 2; match (a, b) { (Some(a), Some(b)) => { - combined[..hash_len].copy_from_slice(a.as_ref()); - combined[hash_len..].copy_from_slice(b.as_ref()); + if a < b { + combined[..hash_len].copy_from_slice(a.as_ref()); + combined[hash_len..].copy_from_slice(b.as_ref()); + } else { + combined[..hash_len].copy_from_slice(b.as_ref()); + combined[hash_len..].copy_from_slice(a.as_ref()); + } next.push(::hash(&combined)); }, @@ -428,12 +430,12 @@ mod tests { }; test( - "aff1208e69c9e8be9b584b07ebac4e48a1ee9d15ce3afe20b77a4d29e4175aa3", + "5842148bc6ebeb52af882a317c765fccd3ae80589b21a9b8cbf21abb630e46a7", vec!["a", "b", "c"], ); test( - "b8912f7269068901f231a965adfefbc10f0eedcfa61852b103efd54dac7db3d7", + "7b84bec68b13c39798c6c50e9e40a0b268e3c1634db8f4cb97314eb243d4c514", vec!["a", "b", "a"], ); @@ -443,7 +445,7 @@ mod tests { ); test( - "fb3b3be94be9e983ba5e094c9c51a7d96a4fa2e5d8e891df00ca89ba05bb1239", + "cc50382cfd3c9a617741e9a85efee8752b8feb95a2cbecd6365fb21366ce0c8c", vec!["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"], ); } @@ -761,7 +763,7 @@ mod tests { "0xc26B34D375533fFc4c5276282Fa5D660F3d8cbcB", ]; let root: H256 = array_bytes::hex2array_unchecked( - "72b0acd7c302a84f1f6b6cefe0ba7194b7398afb440e1b44a9dbbe270394ca53", + "7b2c6eebec6e85b2e272325a11c31af71df52bc0534d2d4f903e0ced191f022e", ) .into(); @@ -806,11 +808,11 @@ mod tests { ) .into(), array_bytes::hex2array_unchecked( - "d02609d2bbdb28aa25f58b85afec937d5a4c85d37925bce6d0cf802f9d76ba79" + "1fad92ed8d0504ef6c0231bbbeeda960a40693f297c64e87b582beb92ecfb00f" ) .into(), array_bytes::hex2array_unchecked( - "ae3f8991955ed884613b0a5f40295902eea0e0abe5858fc520b72959bc016d4e" + "0b84c852cbcf839d562d826fd935e1b37975ccaa419e1def8d219df4b83dcbf4" ) .into(), ], diff --git a/frame/beefy-mmr/src/tests.rs b/frame/beefy-mmr/src/tests.rs index 1826331f59..0f7804e544 100644 --- a/frame/beefy-mmr/src/tests.rs +++ b/frame/beefy-mmr/src/tests.rs @@ -70,7 +70,7 @@ fn should_contain_mmr_digest() { ValidatorSet::new(vec![mock_beefy_id(1), mock_beefy_id(2)], 1).unwrap() )), beefy_log(ConsensusLog::MmrRoot(array_bytes::hex_n_into_unchecked( - "95803defe6ea9f41e7ec6afa497064f21bfded027d8812efacbdf984e630cbdc" + "200e73880940ac0b66735ffb560fa0a3989292463d262deac6ad61e78a3e46a4" ))) ] ); @@ -85,13 +85,13 @@ fn should_contain_mmr_digest() { ValidatorSet::new(vec![mock_beefy_id(1), mock_beefy_id(2)], 1).unwrap() )), beefy_log(ConsensusLog::MmrRoot(array_bytes::hex_n_into_unchecked( - "95803defe6ea9f41e7ec6afa497064f21bfded027d8812efacbdf984e630cbdc" + "200e73880940ac0b66735ffb560fa0a3989292463d262deac6ad61e78a3e46a4" ))), beefy_log(ConsensusLog::AuthoritiesChange( ValidatorSet::new(vec![mock_beefy_id(3), mock_beefy_id(4)], 2).unwrap() )), beefy_log(ConsensusLog::MmrRoot(array_bytes::hex_n_into_unchecked( - "a73271a0974f1e67d6e9b8dd58e506177a2e556519a330796721e98279a753e2" + "ba37d8d5d195ac8caec391da35472f9ecf1116ff1642409148b62e08896d3884" ))), ] ); @@ -124,7 +124,7 @@ fn should_contain_valid_leaf_data() { ) }, leaf_extra: array_bytes::hex2bytes_unchecked( - "55b8e9e1cc9f0db7776fac0ca66318ef8acfb8ec26db11e373120583e07ee648" + "5572d58c82bddf323f4fc7aecab8a8f0ad6ed2f06ab2bfb8ade36a77a45fcc68" ) } ); @@ -149,7 +149,7 @@ fn should_contain_valid_leaf_data() { ) }, leaf_extra: array_bytes::hex2bytes_unchecked( - "55b8e9e1cc9f0db7776fac0ca66318ef8acfb8ec26db11e373120583e07ee648" + "5572d58c82bddf323f4fc7aecab8a8f0ad6ed2f06ab2bfb8ade36a77a45fcc68" ) } ); diff --git a/frame/merkle-mountain-range/src/lib.rs b/frame/merkle-mountain-range/src/lib.rs index 46af84d218..170c1d724f 100644 --- a/frame/merkle-mountain-range/src/lib.rs +++ b/frame/merkle-mountain-range/src/lib.rs @@ -164,7 +164,8 @@ pub mod pallet { + codec::Codec + codec::EncodeLike + scale_info::TypeInfo - + MaxEncodedLen; + + MaxEncodedLen + + PartialOrd; /// Data stored in the leaf nodes. /// From e9b0facf70eeb08032cc7e83548c62f0b4a24bb1 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Thu, 12 Jan 2023 15:49:01 +0200 Subject: [PATCH 07/80] client/beefy: fix logs (#13130) Minor change to logs but required to minimize spamming during initial BEEFY deployment. --- client/beefy/src/worker.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/beefy/src/worker.rs b/client/beefy/src/worker.rs index b48dfa369e..8ec1403bb3 100644 --- a/client/beefy/src/worker.rs +++ b/client/beefy/src/worker.rs @@ -498,7 +498,7 @@ where warn!(target: "beefy", "🥩 Buffer vote dropped for round: {:?}", block_num) } } else { - error!(target: "beefy", "🥩 Buffer justification dropped for round: {:?}.", block_num); + warn!(target: "beefy", "🥩 Buffer vote dropped for round: {:?}.", block_num); } }, RoundAction::Drop => (), @@ -528,7 +528,7 @@ where if self.pending_justifications.len() < MAX_BUFFERED_JUSTIFICATIONS { self.pending_justifications.entry(block_num).or_insert(justification); } else { - error!(target: "beefy", "🥩 Buffer justification dropped for round: {:?}.", block_num); + warn!(target: "beefy", "🥩 Buffer justification dropped for round: {:?}.", block_num); } }, RoundAction::Drop => (), From 2bfc1dd66ef32cf8beb90007dfb544a9d28f1b2f Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Thu, 12 Jan 2023 20:36:31 +0100 Subject: [PATCH 08/80] Stop keeping track of epoch changes for the sync gap (#13127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Stop keeping track of epoch changes data within the sync gap * Fix docs * Apply suggestions from code review Co-authored-by: Bastian Köcher * Fix typo Co-authored-by: Bastian Köcher --- client/consensus/babe/src/lib.rs | 51 +-- client/consensus/epochs/src/lib.rs | 432 +---------------------- client/consensus/epochs/src/migration.rs | 4 +- 3 files changed, 33 insertions(+), 454 deletions(-) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 41c00169e5..c9e171dbed 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -111,7 +111,7 @@ use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_application_crypto::AppKey; use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_blockchain::{ - Backend as _, Error as ClientError, ForkBackend, HeaderBackend, HeaderMetadata, + Backend as _, BlockStatus, Error as ClientError, ForkBackend, HeaderBackend, HeaderMetadata, Result as ClientResult, }; use sp_consensus::{ @@ -1133,11 +1133,17 @@ where let hash = block.header.hash(); let parent_hash = *block.header.parent_hash(); - if block.with_state() { - // When importing whole state we don't calculate epoch descriptor, but rather - // read it from the state after import. We also skip all verifications - // because there's no parent state and we trust the sync module to verify - // that the state is correct and finalized. + let info = self.client.info(); + let number = *block.header.number(); + + if info.block_gap.map_or(false, |(s, e)| s <= number && number <= e) || block.with_state() { + // Verification for imported blocks is skipped in two cases: + // 1. When importing blocks below the last finalized block during network initial + // synchronization. + // 2. When importing whole state we don't calculate epoch descriptor, but rather + // read it from the state after import. We also skip all verifications + // because there's no parent state and we trust the sync module to verify + // that the state is correct and finalized. return Ok((block, Default::default())) } @@ -1399,18 +1405,24 @@ where ) -> Result { let hash = block.post_hash(); let number = *block.header.number(); + let info = self.client.info(); - // early exit if block already in chain, otherwise the check for - // epoch changes will error when trying to re-import an epoch change - match self.client.status(hash) { - Ok(sp_blockchain::BlockStatus::InChain) => { - // When re-importing existing block strip away intermediates. - let _ = block.remove_intermediate::>(INTERMEDIATE_KEY); - block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); - return self.inner.import_block(block, new_cache).await.map_err(Into::into) - }, - Ok(sp_blockchain::BlockStatus::Unknown) => {}, - Err(e) => return Err(ConsensusError::ClientImport(e.to_string())), + let block_status = self + .client + .status(hash) + .map_err(|e| ConsensusError::ClientImport(e.to_string()))?; + + // Skip babe logic if block already in chain or importing blocks during initial sync, + // otherwise the check for epoch changes will error because trying to re-import an + // epoch change or because of missing epoch data in the tree, respectivelly. + if info.block_gap.map_or(false, |(s, e)| s <= number && number <= e) || + block_status == BlockStatus::InChain + { + // When re-importing existing block strip away intermediates. + // In case of initial sync intermediates should not be present... + let _ = block.remove_intermediate::>(INTERMEDIATE_KEY); + block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); + return self.inner.import_block(block, new_cache).await.map_err(Into::into) } if block.with_state() { @@ -1506,8 +1518,6 @@ where )), } - let info = self.client.info(); - if let Some(next_epoch_descriptor) = next_epoch_digest { old_epoch_changes = Some((*epoch_changes).clone()); @@ -1701,9 +1711,6 @@ where Client: HeaderBackend + HeaderMetadata, { let info = client.info(); - if info.block_gap.is_none() { - epoch_changes.clear_gap(); - } let finalized_slot = { let finalized_header = client diff --git a/client/consensus/epochs/src/lib.rs b/client/consensus/epochs/src/lib.rs index c213a49b8e..7784a99437 100644 --- a/client/consensus/epochs/src/lib.rs +++ b/client/consensus/epochs/src/lib.rs @@ -320,106 +320,6 @@ impl AsRef for IncrementedEpoch { } } -/// A pair of epochs for the gap block download validation. -/// Block gap is created after the warp sync is complete. Blocks -/// are imported both at the tip of the chain and at the start of the gap. -/// This holds a pair of epochs that are required to validate headers -/// at the start of the gap. Since gap download does not allow forks we don't -/// need to keep a tree of epochs. -#[derive(Clone, Encode, Decode, Debug)] -pub struct GapEpochs { - current: (Hash, Number, PersistedEpoch), - next: Option<(Hash, Number, E)>, -} - -impl GapEpochs -where - Hash: Copy + PartialEq + std::fmt::Debug, - Number: Copy + PartialEq + std::fmt::Debug, - E: Epoch, -{ - /// Check if given slot matches one of the gap epochs. - /// Returns epoch identifier if it does. - fn matches( - &self, - slot: E::Slot, - ) -> Option<(Hash, Number, EpochHeader, EpochIdentifierPosition)> { - match &self.current { - (_, _, PersistedEpoch::Genesis(epoch_0, _)) - if slot >= epoch_0.start_slot() && slot < epoch_0.end_slot() => - return Some(( - self.current.0, - self.current.1, - epoch_0.into(), - EpochIdentifierPosition::Genesis0, - )), - (_, _, PersistedEpoch::Genesis(_, epoch_1)) - if slot >= epoch_1.start_slot() && slot < epoch_1.end_slot() => - return Some(( - self.current.0, - self.current.1, - epoch_1.into(), - EpochIdentifierPosition::Genesis1, - )), - (_, _, PersistedEpoch::Regular(epoch_n)) - if slot >= epoch_n.start_slot() && slot < epoch_n.end_slot() => - return Some(( - self.current.0, - self.current.1, - epoch_n.into(), - EpochIdentifierPosition::Regular, - )), - _ => {}, - }; - match &self.next { - Some((h, n, epoch_n)) if slot >= epoch_n.start_slot() && slot < epoch_n.end_slot() => - Some((*h, *n, epoch_n.into(), EpochIdentifierPosition::Regular)), - _ => None, - } - } - - /// Returns epoch data if it matches given identifier. - pub fn epoch(&self, id: &EpochIdentifier) -> Option<&E> { - match (&self.current, &self.next) { - ((h, n, e), _) if h == &id.hash && n == &id.number => match e { - PersistedEpoch::Genesis(ref epoch_0, _) - if id.position == EpochIdentifierPosition::Genesis0 => - Some(epoch_0), - PersistedEpoch::Genesis(_, ref epoch_1) - if id.position == EpochIdentifierPosition::Genesis1 => - Some(epoch_1), - PersistedEpoch::Regular(ref epoch_n) - if id.position == EpochIdentifierPosition::Regular => - Some(epoch_n), - _ => None, - }, - (_, Some((h, n, e))) - if h == &id.hash && - n == &id.number && id.position == EpochIdentifierPosition::Regular => - Some(e), - _ => None, - } - } - - /// Import a new gap epoch, potentially replacing an old epoch. - fn import(&mut self, slot: E::Slot, hash: Hash, number: Number, epoch: E) -> Result<(), E> { - match (&mut self.current, &mut self.next) { - ((_, _, PersistedEpoch::Genesis(_, epoch_1)), _) if slot == epoch_1.end_slot() => { - self.next = Some((hash, number, epoch)); - Ok(()) - }, - (_, Some((_, _, epoch_n))) if slot == epoch_n.end_slot() => { - let (cur_h, cur_n, cur_epoch) = - self.next.take().expect("Already matched as `Some`"); - self.current = (cur_h, cur_n, PersistedEpoch::Regular(cur_epoch)); - self.next = Some((hash, number, epoch)); - Ok(()) - }, - _ => Err(epoch), - } - } -} - /// Tree of all epoch changes across all *seen* forks. Data stored in tree is /// the hash and block number of the block signaling the epoch change, and the /// epoch that was signalled at that block. @@ -435,14 +335,10 @@ where /// same DAG entry, pinned to a specific block #1. /// /// Further epochs (epoch_2, ..., epoch_n) each get their own entry. -/// -/// Also maintains a pair of epochs for the start of the gap, -/// as long as there's an active gap download after a warp sync. #[derive(Clone, Encode, Decode, Debug)] pub struct EpochChanges { inner: ForkTree>, epochs: BTreeMap<(Hash, Number), PersistedEpoch>, - gap: Option>, } // create a fake header hash which hasn't been included in the chain. @@ -460,7 +356,7 @@ where Number: Ord, { fn default() -> Self { - EpochChanges { inner: ForkTree::new(), epochs: BTreeMap::new(), gap: None } + EpochChanges { inner: ForkTree::new(), epochs: BTreeMap::new() } } } @@ -480,11 +376,6 @@ where self.inner.rebalance() } - /// Clear gap epochs if any. - pub fn clear_gap(&mut self) { - self.gap = None; - } - /// Map the epoch changes from one storing data to a different one. pub fn map(self, mut f: F) -> EpochChanges where @@ -493,10 +384,6 @@ where { EpochChanges { inner: self.inner.map(&mut |_, _, header: PersistedEpochHeader| header.map()), - gap: self.gap.map(|GapEpochs { current: (h, n, header), next }| GapEpochs { - current: (h, n, header.map(&h, &n, &mut f)), - next: next.map(|(h, n, e)| (h, n, f(&h, &n, e))), - }), epochs: self .epochs .into_iter() @@ -536,9 +423,6 @@ where /// Get a reference to an epoch with given identifier. pub fn epoch(&self, id: &EpochIdentifier) -> Option<&E> { - if let Some(e) = &self.gap.as_ref().and_then(|gap| gap.epoch(id)) { - return Some(e) - } self.epochs.get(&(id.hash, id.number)).and_then(|v| match v { PersistedEpoch::Genesis(ref epoch_0, _) if id.position == EpochIdentifierPosition::Genesis0 => @@ -665,15 +549,6 @@ where return Ok(Some(ViableEpochDescriptor::UnimportedGenesis(slot))) } - if let Some(gap) = &self.gap { - if let Some((hash, number, hdr, position)) = gap.matches(slot) { - return Ok(Some(ViableEpochDescriptor::Signaled( - EpochIdentifier { position, hash, number }, - hdr, - ))) - } - } - // find_node_where will give you the node in the fork-tree which is an ancestor // of the `parent_hash` by default. if the last epoch was signalled at the parent_hash, // then it won't be returned. we need to create a new fake chain head hash which @@ -744,28 +619,9 @@ where ) -> Result<(), fork_tree::Error> { let is_descendent_of = descendent_of_builder.build_is_descendent_of(Some((hash, parent_hash))); - let slot = epoch.as_ref().start_slot(); - let IncrementedEpoch(mut epoch) = epoch; + let IncrementedEpoch(epoch) = epoch; let header = PersistedEpochHeader::::from(&epoch); - if let Some(gap) = &mut self.gap { - if let PersistedEpoch::Regular(e) = epoch { - epoch = match gap.import(slot, hash, number, e) { - Ok(()) => return Ok(()), - Err(e) => PersistedEpoch::Regular(e), - } - } - } else if epoch.is_genesis() && - !self.epochs.is_empty() && - !self.epochs.values().any(|e| e.is_genesis()) - { - // There's a genesis epoch imported when we already have an active epoch. - // This happens after the warp sync as the ancient blocks download start. - // We need to start tracking gap epochs here. - self.gap = Some(GapEpochs { current: (hash, number, epoch), next: None }); - return Ok(()) - } - let res = self.inner.import(hash, number, header, &is_descendent_of); match res { @@ -1278,288 +1134,4 @@ mod tests { list.sort(); assert_eq!(list, vec![b"A", b"G", b"L"]); } - - /// Test that ensures that the gap is not enabled when we import multiple genesis blocks. - #[test] - fn gap_is_not_enabled_when_multiple_genesis_epochs_are_imported() { - // X - // / - // 0 - A - // - let is_descendent_of = |base: &Hash, block: &Hash| -> Result { - match (base, *block) { - (b"0", _) => Ok(true), - _ => Ok(false), - } - }; - - let duration = 100; - - let make_genesis = |slot| Epoch { start_slot: slot, duration }; - - let mut epoch_changes = EpochChanges::new(); - let next_descriptor = (); - - // insert genesis epoch for A - { - let genesis_epoch_a_descriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"0", 0, 100) - .unwrap() - .unwrap(); - - let incremented_epoch = epoch_changes - .viable_epoch(&genesis_epoch_a_descriptor, &make_genesis) - .unwrap() - .increment(next_descriptor); - - epoch_changes - .import(&is_descendent_of, *b"A", 1, *b"0", incremented_epoch) - .unwrap(); - } - - // insert genesis epoch for X - { - let genesis_epoch_x_descriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"0", 0, 1000) - .unwrap() - .unwrap(); - - let incremented_epoch = epoch_changes - .viable_epoch(&genesis_epoch_x_descriptor, &make_genesis) - .unwrap() - .increment(next_descriptor); - - epoch_changes - .import(&is_descendent_of, *b"X", 1, *b"0", incremented_epoch) - .unwrap(); - } - - // Clearing the gap should be a no-op. - epoch_changes.clear_gap(); - - // Check that both epochs are available. - let epoch_a = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"A", 1, 101, &make_genesis) - .unwrap() - .unwrap(); - - let epoch_x = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"X", 1, 1001, &make_genesis) - .unwrap() - .unwrap(); - - assert!(epoch_a != epoch_x) - } - - #[test] - fn gap_epochs_advance() { - // 0 - 1 - 2 - 3 - .... 42 - 43 - let is_descendent_of = |base: &Hash, block: &Hash| -> Result { - match (base, *block) { - (b"0", _) => Ok(true), - (b"1", b) => Ok(b == *b"0"), - (b"2", b) => Ok(b == *b"1"), - (b"3", b) => Ok(b == *b"2"), - _ => Ok(false), - } - }; - - let duration = 100; - - let make_genesis = |slot| Epoch { start_slot: slot, duration }; - - let mut epoch_changes = EpochChanges::new(); - let next_descriptor = (); - - let epoch42 = Epoch { start_slot: 42, duration: 100 }; - let epoch43 = Epoch { start_slot: 43, duration: 100 }; - epoch_changes.reset(*b"0", *b"1", 4200, epoch42, epoch43); - assert!(epoch_changes.gap.is_none()); - - // Import a new genesis epoch, this should crate the gap. - let genesis_epoch_a_descriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"0", 0, 100) - .unwrap() - .unwrap(); - - let incremented_epoch = epoch_changes - .viable_epoch(&genesis_epoch_a_descriptor, &make_genesis) - .unwrap() - .increment(next_descriptor); - - epoch_changes - .import(&is_descendent_of, *b"1", 1, *b"0", incremented_epoch) - .unwrap(); - assert!(epoch_changes.gap.is_some()); - - let genesis_epoch = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"0", 0, 100) - .unwrap() - .unwrap(); - - assert_eq!(genesis_epoch, ViableEpochDescriptor::UnimportedGenesis(100)); - - // Import more epochs and check that gap advances. - let import_epoch_1 = - epoch_changes.viable_epoch(&genesis_epoch, &make_genesis).unwrap().increment(()); - - let epoch_1 = import_epoch_1.as_ref().clone(); - epoch_changes - .import(&is_descendent_of, *b"1", 1, *b"0", import_epoch_1) - .unwrap(); - let genesis_epoch_data = epoch_changes.epoch_data(&genesis_epoch, &make_genesis).unwrap(); - let end_slot = genesis_epoch_data.end_slot(); - let x = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"1", 1, end_slot, &make_genesis) - .unwrap() - .unwrap(); - - assert_eq!(x, epoch_1); - assert_eq!(epoch_changes.gap.as_ref().unwrap().current.0, *b"1"); - assert!(epoch_changes.gap.as_ref().unwrap().next.is_none()); - - let epoch_1_desriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"1", 1, end_slot) - .unwrap() - .unwrap(); - let epoch_1 = epoch_changes.epoch_data(&epoch_1_desriptor, &make_genesis).unwrap(); - let import_epoch_2 = epoch_changes - .viable_epoch(&epoch_1_desriptor, &make_genesis) - .unwrap() - .increment(()); - let epoch_2 = import_epoch_2.as_ref().clone(); - epoch_changes - .import(&is_descendent_of, *b"2", 2, *b"1", import_epoch_2) - .unwrap(); - - let end_slot = epoch_1.end_slot(); - let x = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"2", 2, end_slot, &make_genesis) - .unwrap() - .unwrap(); - assert_eq!(epoch_changes.gap.as_ref().unwrap().current.0, *b"1"); - assert_eq!(epoch_changes.gap.as_ref().unwrap().next.as_ref().unwrap().0, *b"2"); - assert_eq!(x, epoch_2); - - let epoch_2_desriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"2", 2, end_slot) - .unwrap() - .unwrap(); - let import_epoch_3 = epoch_changes - .viable_epoch(&epoch_2_desriptor, &make_genesis) - .unwrap() - .increment(()); - epoch_changes - .import(&is_descendent_of, *b"3", 3, *b"2", import_epoch_3) - .unwrap(); - - assert_eq!(epoch_changes.gap.as_ref().unwrap().current.0, *b"2"); - - epoch_changes.clear_gap(); - assert!(epoch_changes.gap.is_none()); - } - - /// Test that ensures that the gap is not enabled when there's still genesis - /// epochs imported, regardless of whether there are already other further - /// epochs imported descending from such genesis epochs. - #[test] - fn gap_is_not_enabled_when_at_least_one_genesis_epoch_is_still_imported() { - // A (#1) - B (#201) - // / - // 0 - C (#1) - // - // The epoch duration is 100 slots, each of these blocks represents - // an epoch change block. block B starts a new epoch at #201 since the - // genesis epoch spans two epochs. - - let is_descendent_of = |base: &Hash, block: &Hash| -> Result { - match (base, block) { - (b"0", _) => Ok(true), - (b"A", b"B") => Ok(true), - _ => Ok(false), - } - }; - - let duration = 100; - let make_genesis = |slot| Epoch { start_slot: slot, duration }; - let mut epoch_changes = EpochChanges::new(); - let next_descriptor = (); - - // insert genesis epoch for A at slot 1 - { - let genesis_epoch_a_descriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"0", 0, 1) - .unwrap() - .unwrap(); - - let incremented_epoch = epoch_changes - .viable_epoch(&genesis_epoch_a_descriptor, &make_genesis) - .unwrap() - .increment(next_descriptor); - - epoch_changes - .import(&is_descendent_of, *b"A", 1, *b"0", incremented_epoch) - .unwrap(); - } - - // insert regular epoch for B at slot 201, descending from A - { - let epoch_b_descriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"A", 1, 201) - .unwrap() - .unwrap(); - - let incremented_epoch = epoch_changes - .viable_epoch(&epoch_b_descriptor, &make_genesis) - .unwrap() - .increment(next_descriptor); - - epoch_changes - .import(&is_descendent_of, *b"B", 201, *b"A", incremented_epoch) - .unwrap(); - } - - // insert genesis epoch for C at slot 1000 - { - let genesis_epoch_x_descriptor = epoch_changes - .epoch_descriptor_for_child_of(&is_descendent_of, b"0", 0, 1000) - .unwrap() - .unwrap(); - - let incremented_epoch = epoch_changes - .viable_epoch(&genesis_epoch_x_descriptor, &make_genesis) - .unwrap() - .increment(next_descriptor); - - epoch_changes - .import(&is_descendent_of, *b"C", 1, *b"0", incremented_epoch) - .unwrap(); - } - - // Clearing the gap should be a no-op. - epoch_changes.clear_gap(); - - // Check that all three epochs are available. - let epoch_a = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"A", 1, 10, &make_genesis) - .unwrap() - .unwrap(); - - let epoch_b = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"B", 201, 201, &make_genesis) - .unwrap() - .unwrap(); - - assert!(epoch_a != epoch_b); - - // the genesis epoch A will span slots [1, 200] with epoch B starting at slot 201 - assert_eq!(epoch_b.start_slot(), 201); - - let epoch_c = epoch_changes - .epoch_data_for_child_of(&is_descendent_of, b"C", 1, 1001, &make_genesis) - .unwrap() - .unwrap(); - - assert!(epoch_a != epoch_c); - } } diff --git a/client/consensus/epochs/src/migration.rs b/client/consensus/epochs/src/migration.rs index c4ed47e9c1..052d0b7be4 100644 --- a/client/consensus/epochs/src/migration.rs +++ b/client/consensus/epochs/src/migration.rs @@ -64,7 +64,7 @@ where header }); - EpochChanges { inner, epochs, gap: None } + EpochChanges { inner, epochs } } } @@ -75,6 +75,6 @@ where { /// Migrate the type into current epoch changes definition. pub fn migrate(self) -> EpochChanges { - EpochChanges { inner: self.inner, epochs: self.epochs, gap: None } + EpochChanges { inner: self.inner, epochs: self.epochs } } } From d92281a5634baf55a3dab058b904a3932b4ed340 Mon Sep 17 00:00:00 2001 From: Vladimir Istyufeev Date: Fri, 13 Jan 2023 14:32:29 +0400 Subject: [PATCH 09/80] CI: Unpin `ci-linux` and use Rust 1.66.1 (#13134) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 90298297a8..ecc27d016a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ variables: CARGO_INCREMENTAL: 0 DOCKER_OS: "debian:stretch" ARCH: "x86_64" - CI_IMAGE: "paritytech/ci-linux@sha256:9140bc3c843a8b12a3bcf6f5886346536092795bbadfd7f1836362cb28dfcc71" + CI_IMAGE: "paritytech/ci-linux:production" BUILDAH_IMAGE: "quay.io/buildah/stable:v1.27" RUSTY_CACHIER_SINGLE_BRANCH: master RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true" From 88be4b64df842daf2dd5473a45eb9f8b85f466c4 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 13 Jan 2023 14:52:18 +0200 Subject: [PATCH 10/80] sp-beefy: align authority id key type with its signature type (#13131) Still allows custom message hasher, but ties together the crypto types used for private+public keys and the signature. Signed-off-by: acatangiu --- client/beefy/src/keystore.rs | 4 +-- primitives/beefy/src/lib.rs | 52 +++++++++++++++++------------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/client/beefy/src/keystore.rs b/client/beefy/src/keystore.rs index 886c00fc5d..8d77410746 100644 --- a/client/beefy/src/keystore.rs +++ b/client/beefy/src/keystore.rs @@ -25,7 +25,7 @@ use log::warn; use beefy_primitives::{ crypto::{Public, Signature}, - BeefyVerify, KEY_TYPE, + BeefyAuthorityId, KEY_TYPE, }; use crate::error; @@ -99,7 +99,7 @@ impl BeefyKeystore { /// /// Return `true` if the signature is authentic, `false` otherwise. pub fn verify(public: &Public, sig: &Signature, message: &[u8]) -> bool { - BeefyVerify::::verify(sig, message, public) + BeefyAuthorityId::::verify(public, sig, message) } } diff --git a/primitives/beefy/src/lib.rs b/primitives/beefy/src/lib.rs index d7ac091491..eb7b8db89b 100644 --- a/primitives/beefy/src/lib.rs +++ b/primitives/beefy/src/lib.rs @@ -49,20 +49,14 @@ use sp_std::prelude::*; /// Key type for BEEFY module. pub const KEY_TYPE: sp_application_crypto::KeyTypeId = sp_application_crypto::KeyTypeId(*b"beef"); -/// Trait representing BEEFY authority id. -pub trait BeefyAuthorityId: RuntimeAppPublic {} - -/// Means of verification for a BEEFY authority signature. +/// Trait representing BEEFY authority id, including custom signature verification. /// /// Accepts custom hashing fn for the message and custom convertor fn for the signer. -pub trait BeefyVerify { - /// Type of the signer. - type Signer: BeefyAuthorityId; - +pub trait BeefyAuthorityId: RuntimeAppPublic { /// Verify a signature. /// - /// Return `true` if signature is valid for the value. - fn verify(&self, msg: &[u8], signer: &Self::Signer) -> bool; + /// Return `true` if signature over `msg` is valid for this id. + fn verify(&self, signature: &::Signature, msg: &[u8]) -> bool; } /// BEEFY cryptographic types @@ -78,7 +72,7 @@ pub trait BeefyVerify { /// The current underlying crypto scheme used is ECDSA. This can be changed, /// without affecting code restricted against the above listed crypto types. pub mod crypto { - use super::{BeefyAuthorityId, BeefyVerify, Hash}; + use super::{BeefyAuthorityId, Hash, RuntimeAppPublic}; use sp_application_crypto::{app_crypto, ecdsa}; use sp_core::crypto::Wraps; app_crypto!(ecdsa, crate::KEY_TYPE); @@ -89,21 +83,17 @@ pub mod crypto { /// Signature for a BEEFY authority using ECDSA as its crypto. pub type AuthoritySignature = Signature; - impl BeefyAuthorityId for AuthorityId {} - - impl BeefyVerify for AuthoritySignature + impl BeefyAuthorityId for AuthorityId where ::Output: Into<[u8; 32]>, { - type Signer = AuthorityId; - - fn verify(&self, msg: &[u8], signer: &Self::Signer) -> bool { + fn verify(&self, signature: &::Signature, msg: &[u8]) -> bool { let msg_hash = ::hash(msg).into(); match sp_io::crypto::secp256k1_ecdsa_recover_compressed( - self.as_inner_ref().as_ref(), + signature.as_inner_ref().as_ref(), &msg_hash, ) { - Ok(raw_pubkey) => raw_pubkey.as_ref() == AsRef::<[u8]>::as_ref(signer), + Ok(raw_pubkey) => raw_pubkey.as_ref() == AsRef::<[u8]>::as_ref(self), _ => false, } } @@ -248,23 +238,31 @@ mod tests { pair.as_inner_ref().sign_prehashed(&blake2_256(msg)).into(); // Verification works if same hashing function is used when signing and verifying. - assert!(BeefyVerify::::verify(&keccak_256_signature, msg, &pair.public())); - assert!(BeefyVerify::::verify(&blake2_256_signature, msg, &pair.public())); + assert!(BeefyAuthorityId::::verify(&pair.public(), &keccak_256_signature, msg)); + assert!(BeefyAuthorityId::::verify( + &pair.public(), + &blake2_256_signature, + msg + )); // Verification fails if distinct hashing functions are used when signing and verifying. - assert!(!BeefyVerify::::verify(&blake2_256_signature, msg, &pair.public())); - assert!(!BeefyVerify::::verify(&keccak_256_signature, msg, &pair.public())); + assert!(!BeefyAuthorityId::::verify(&pair.public(), &blake2_256_signature, msg)); + assert!(!BeefyAuthorityId::::verify( + &pair.public(), + &keccak_256_signature, + msg + )); // Other public key doesn't work let (other_pair, _) = crypto::Pair::generate(); - assert!(!BeefyVerify::::verify( + assert!(!BeefyAuthorityId::::verify( + &other_pair.public(), &keccak_256_signature, msg, - &other_pair.public() )); - assert!(!BeefyVerify::::verify( + assert!(!BeefyAuthorityId::::verify( + &other_pair.public(), &blake2_256_signature, msg, - &other_pair.public() )); } } From cbc525f271146ba9c684736bfc5c26f77e849dae Mon Sep 17 00:00:00 2001 From: Squirrel Date: Fri, 13 Jan 2023 13:47:18 +0000 Subject: [PATCH 11/80] Use the balance trait as we have one (#13136) --- .../asset-tx-payment/src/payment.rs | 14 +++----------- frame/transaction-payment/src/payment.rs | 17 ++++------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/frame/transaction-payment/asset-tx-payment/src/payment.rs b/frame/transaction-payment/asset-tx-payment/src/payment.rs index 80ff4e40dc..85d1bec4b2 100644 --- a/frame/transaction-payment/asset-tx-payment/src/payment.rs +++ b/frame/transaction-payment/asset-tx-payment/src/payment.rs @@ -21,15 +21,13 @@ use codec::FullCodec; use frame_support::{ traits::{ fungibles::{Balanced, CreditOf, Inspect}, - tokens::BalanceConversion, + tokens::{Balance, BalanceConversion}, }, unsigned::TransactionValidityError, }; use scale_info::TypeInfo; use sp_runtime::{ - traits::{ - AtLeast32BitUnsigned, DispatchInfoOf, MaybeSerializeDeserialize, One, PostDispatchInfoOf, - }, + traits::{DispatchInfoOf, MaybeSerializeDeserialize, One, PostDispatchInfoOf}, transaction_validity::InvalidTransaction, }; use sp_std::{fmt::Debug, marker::PhantomData}; @@ -37,13 +35,7 @@ use sp_std::{fmt::Debug, marker::PhantomData}; /// Handle withdrawing, refunding and depositing of transaction fees. pub trait OnChargeAssetTransaction { /// The underlying integer type in which fees are calculated. - type Balance: AtLeast32BitUnsigned - + FullCodec - + Copy - + MaybeSerializeDeserialize - + Debug - + Default - + TypeInfo; + type Balance: Balance; /// The type used to identify the assets used for transaction payment. type AssetId: FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default + Eq + TypeInfo; /// The type used to store the intermediate values between pre- and post-dispatch. diff --git a/frame/transaction-payment/src/payment.rs b/frame/transaction-payment/src/payment.rs index ebc9c5c5af..bc871deafd 100644 --- a/frame/transaction-payment/src/payment.rs +++ b/frame/transaction-payment/src/payment.rs @@ -1,15 +1,11 @@ /// ! Traits and default implementation for paying transaction fees. use crate::Config; -use codec::FullCodec; use sp_runtime::{ - traits::{ - AtLeast32BitUnsigned, DispatchInfoOf, MaybeSerializeDeserialize, PostDispatchInfoOf, - Saturating, Zero, - }, + traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating, Zero}, transaction_validity::InvalidTransaction, }; -use sp_std::{fmt::Debug, marker::PhantomData}; +use sp_std::marker::PhantomData; use frame_support::{ traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReasons}, @@ -22,13 +18,8 @@ type NegativeImbalanceOf = /// Handle withdrawing, refunding and depositing of transaction fees. pub trait OnChargeTransaction { /// The underlying integer type in which fees are calculated. - type Balance: AtLeast32BitUnsigned - + FullCodec - + Copy - + MaybeSerializeDeserialize - + Debug - + Default - + scale_info::TypeInfo; + type Balance: frame_support::traits::tokens::Balance; + type LiquidityInfo: Default; /// Before the transaction is executed the payment of the transaction fees From 30641eed4763cc1ef466a0f447f2a1b2456910eb Mon Sep 17 00:00:00 2001 From: Vladimir Istyufeev Date: Fri, 13 Jan 2023 20:21:44 +0400 Subject: [PATCH 12/80] CI: Code mark to request a pipeline failure (#13139) --- scripts/ci/gitlab/pipeline/test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index a468a7b04c..466019e42e 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -1,6 +1,27 @@ # This file is part of .gitlab-ci.yml # Here are all jobs that are executed during "test" stage + +# It's more like a check and it belongs to the previous stage, but we want to run this job with real tests in parallel +find-fail-ci-phrase: + stage: test + variables: + CI_IMAGE: "paritytech/tools:latest" + ASSERT_REGEX: "FAIL-CI" + GIT_DEPTH: 1 + extends: + - .kubernetes-env + script: + - set +e + - rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$? + - if [ $exit_status -eq 0 ]; then + echo "$ASSERT_REGEX was found, exiting with 1"; + exit 1; + else + echo "No $ASSERT_REGEX was found, exiting with 0"; + exit 0; + fi + cargo-deny: stage: test extends: From 49962f76ad9a1cc45086a80188f3d751ac15eb82 Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Sun, 15 Jan 2023 21:31:14 +0800 Subject: [PATCH 13/80] Annotate thiserror for sp_core::crypto::SecretStringError (#13144) --- primitives/core/src/crypto.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 06703acea7..52c805bb61 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -84,20 +84,27 @@ impl> UncheckedInto for S { } /// An error with the interpretation of a secret. +#[cfg_attr(feature = "std", derive(thiserror::Error))] #[derive(Debug, Clone, PartialEq, Eq)] #[cfg(feature = "full_crypto")] pub enum SecretStringError { /// The overall format was invalid (e.g. the seed phrase contained symbols). + #[cfg_attr(feature = "std", error("Invalid format"))] InvalidFormat, /// The seed phrase provided is not a valid BIP39 phrase. + #[cfg_attr(feature = "std", error("Invalid phrase"))] InvalidPhrase, /// The supplied password was invalid. + #[cfg_attr(feature = "std", error("Invalid password"))] InvalidPassword, /// The seed is invalid (bad content). + #[cfg_attr(feature = "std", error("Invalid seed"))] InvalidSeed, /// The seed has an invalid length. + #[cfg_attr(feature = "std", error("Invalid seed length"))] InvalidSeedLength, /// The derivation path was invalid (e.g. contains soft junctions when they are not supported). + #[cfg_attr(feature = "std", error("Invalid path"))] InvalidPath, } From 70f2e364ab1ad57ce8d3abe228222b299393c5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 16 Jan 2023 13:39:13 +0100 Subject: [PATCH 14/80] pallet-offences-benchmarking: Box events in verify (#13151) * pallet-offences-benchmarking: Box events in verify Events in frame are represented by an enum in the pallet and the runtime. The size of an enum in Rust depends on the size of biggest variant. This means we always need to allocate memory for the biggest variant when allocating memory for an event. The offences benchmarking is verifying the benchmarking results by checking the events. To check the events it is generating all the expected events. With the recent changes in Polkadot the events are too big and lead to issues when running this verify functions. The solution is to box each event, as the vector holding all the events will then only need to hold fat pointers * expected events, instead of size_of(event) * expected events. This issue isn't a problem in production, as we never read the events on chain. When we are reading the events, it is done in an offchain context and they are only decoded one by one. Besides that this also enables the benchmarking verification for everyone running these benchmarks. * FMT * Disable checking again --- Cargo.lock | 1 + frame/offences/benchmarking/Cargo.toml | 2 + frame/offences/benchmarking/src/lib.rs | 189 +++++++++++++------------ 3 files changed, 104 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68c144b3f1..e4e3e1b846 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6079,6 +6079,7 @@ dependencies = [ "frame-election-provider-support", "frame-support", "frame-system", + "log", "pallet-babe", "pallet-balances", "pallet-grandpa", diff --git a/frame/offences/benchmarking/Cargo.toml b/frame/offences/benchmarking/Cargo.toml index e20aefd69a..e31e8bbed9 100644 --- a/frame/offences/benchmarking/Cargo.toml +++ b/frame/offences/benchmarking/Cargo.toml @@ -29,6 +29,7 @@ pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../. sp-runtime = { version = "7.0.0", default-features = false, path = "../../../primitives/runtime" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/staking" } sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } +log = { version = "0.4.17", default-features = false } [dev-dependencies] pallet-staking-reward-curve = { version = "4.0.0-dev", path = "../../staking/reward-curve" } @@ -55,6 +56,7 @@ std = [ "sp-runtime/std", "sp-staking/std", "sp-std/std", + "log/std", ] runtime-benchmarks = [ diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index e5ec2952f8..7e586a96bb 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -28,8 +28,10 @@ use frame_benchmarking::{account, benchmarks}; use frame_support::traits::{Currency, Get, ValidatorSet, ValidatorSetWithIdentification}; use frame_system::{Config as SystemConfig, Pallet as System, RawOrigin}; +#[cfg(test)] +use sp_runtime::traits::UniqueSaturatedInto; use sp_runtime::{ - traits::{Convert, Saturating, StaticLookup, UniqueSaturatedInto}, + traits::{Convert, Saturating, StaticLookup}, Perbill, }; use sp_staking::offence::{Offence, ReportOffence}; @@ -43,9 +45,11 @@ use pallet_session::{ historical::{Config as HistoricalConfig, IdentificationTuple}, Config as SessionConfig, SessionManager, }; +#[cfg(test)] +use pallet_staking::Event as StakingEvent; use pallet_staking::{ - Config as StakingConfig, Event as StakingEvent, Exposure, IndividualExposure, - Pallet as Staking, RewardDestination, ValidatorPrefs, + Config as StakingConfig, Exposure, IndividualExposure, Pallet as Staking, RewardDestination, + ValidatorPrefs, }; const SEED: u32 = 0; @@ -89,7 +93,9 @@ type BalanceOf = struct Offender { pub controller: T::AccountId, + #[allow(dead_code)] pub stash: T::AccountId, + #[allow(dead_code)] pub nominator_stashes: Vec, } @@ -217,55 +223,63 @@ fn make_offenders_im_online( } #[cfg(test)] -fn check_events::RuntimeEvent>>(expected: I) { +fn check_events< + T: Config, + I: Iterator, + Item: sp_std::borrow::Borrow<::RuntimeEvent> + sp_std::fmt::Debug, +>( + expected: I, +) { let events = System::::events() .into_iter() .map(|frame_system::EventRecord { event, .. }| event) .collect::>(); let expected = expected.collect::>(); - fn pretty(header: &str, ev: &[D], offset: usize) { - println!("{}", header); + fn pretty(header: &str, ev: &[D], offset: usize) { + log::info!("{}", header); for (idx, ev) in ev.iter().enumerate() { - println!("\t[{:04}] {:?}", idx + offset, ev); + log::info!("\t[{:04}] {:?}", idx + offset, ev); } } - fn print_events(idx: usize, events: &[D], expected: &[D]) { + fn print_events( + idx: usize, + events: &[D], + expected: &[E], + ) { let window = 10; let start = idx.saturating_sub(window / 2); let end_got = (idx + window / 2).min(events.len()); pretty("Got(window):", &events[start..end_got], start); let end_expected = (idx + window / 2).min(expected.len()); pretty("Expected(window):", &expected[start..end_expected], start); - println!("---------------"); + log::info!("---------------"); let start_got = events.len().saturating_sub(window); pretty("Got(end):", &events[start_got..], start_got); let start_expected = expected.len().saturating_sub(window); pretty("Expected(end):", &expected[start_expected..], start_expected); } - let events_copy = events.clone(); - let expected_copy = expected.clone(); - - for (idx, (a, b)) in events.into_iter().zip(expected).enumerate() { - if a != b { - print_events(idx, &events_copy, &expected_copy); - println!("Mismatch at: {}", idx); - println!(" Got: {:?}", b); - println!("Expected: {:?}", a); - if events_copy.len() != expected_copy.len() { - println!( + + for (idx, (a, b)) in events.iter().zip(expected.iter()).enumerate() { + if a != sp_std::borrow::Borrow::borrow(b) { + print_events(idx, &events, &expected); + log::info!("Mismatch at: {}", idx); + log::info!(" Got: {:?}", b); + log::info!("Expected: {:?}", a); + if events.len() != expected.len() { + log::info!( "Mismatching lengths. Got: {}, Expected: {}", - events_copy.len(), - expected_copy.len() + events.len(), + expected.len() ) } panic!("Mismatching events."); } } - if events_copy.len() != expected_copy.len() { - print_events(0, &events_copy, &expected_copy); - panic!("Mismatching lengths. Got: {}, Expected: {}", events_copy.len(), expected_copy.len()) + if events.len() != expected.len() { + print_events(0, &events, &expected); + panic!("Mismatching lengths. Got: {}, Expected: {}", events.len(), expected.len(),) } } @@ -304,79 +318,78 @@ benchmarks! { ); } verify { - let bond_amount: u32 = UniqueSaturatedInto::::unique_saturated_into(bond_amount::()); - let slash_amount = slash_fraction * bond_amount; - let reward_amount = slash_amount.saturating_mul(1 + n) / 2; - let reward = reward_amount / r; - let slash_report = |id| core::iter::once( - ::RuntimeEvent::from(StakingEvent::::SlashReported{ validator: id, fraction: slash_fraction, slash_era: 0}) - ); - let slash = |id| core::iter::once( - ::RuntimeEvent::from(StakingEvent::::Slashed{ staker: id, amount: BalanceOf::::from(slash_amount) }) - ); - let balance_slash = |id| core::iter::once( - ::RuntimeEvent::from(pallet_balances::Event::::Slashed{ who: id, amount: slash_amount.into() }) - ); - let chill = |id| core::iter::once( - ::RuntimeEvent::from(StakingEvent::::Chilled{ stash: id }) - ); - let balance_deposit = |id, amount: u32| + #[cfg(test)] + { + let bond_amount: u32 = UniqueSaturatedInto::::unique_saturated_into(bond_amount::()); + let slash_amount = slash_fraction * bond_amount; + let reward_amount = slash_amount.saturating_mul(1 + n) / 2; + let reward = reward_amount / r; + let slash_report = |id| core::iter::once( + ::RuntimeEvent::from(StakingEvent::::SlashReported{ validator: id, fraction: slash_fraction, slash_era: 0}) + ); + let slash = |id| core::iter::once( + ::RuntimeEvent::from(StakingEvent::::Slashed{ staker: id, amount: BalanceOf::::from(slash_amount) }) + ); + let balance_slash = |id| core::iter::once( + ::RuntimeEvent::from(pallet_balances::Event::::Slashed{ who: id, amount: slash_amount.into() }) + ); + let chill = |id| core::iter::once( + ::RuntimeEvent::from(StakingEvent::::Chilled{ stash: id }) + ); + let balance_deposit = |id, amount: u32| ::RuntimeEvent::from(pallet_balances::Event::::Deposit{ who: id, amount: amount.into() }); - let mut first = true; - let slash_events = raw_offenders.into_iter() - .flat_map(|offender| { - let nom_slashes = offender.nominator_stashes.into_iter().flat_map(|nom| { - balance_slash(nom.clone()).map(Into::into) - .chain(slash(nom).map(Into::into)) - }); - - let mut events = chill(offender.stash.clone()).map(Into::into) - .chain(slash_report(offender.stash.clone()).map(Into::into)) - .chain(balance_slash(offender.stash.clone()).map(Into::into)) - .chain(slash(offender.stash).map(Into::into)) - .chain(nom_slashes) - .collect::>(); - - // the first deposit creates endowed events, see `endowed_reward_events` - if first { - first = false; - let mut reward_events = reporters.clone().into_iter() - .flat_map(|reporter| vec![ - balance_deposit(reporter.clone(), reward).into(), - frame_system::Event::::NewAccount { account: reporter.clone() }.into(), - ::RuntimeEvent::from( - pallet_balances::Event::::Endowed{account: reporter, free_balance: reward.into()} - ).into(), - ]) + let mut first = true; + + // We need to box all events to prevent running into too big allocations in wasm. + // The event in FRAME is represented as an enum and the size of the enum depends on the biggest variant. + // So, instead of requiring `size_of() * expected_events` we only need to + // allocate `size_of>() * expected_events`. + let slash_events = raw_offenders.into_iter() + .flat_map(|offender| { + let nom_slashes = offender.nominator_stashes.into_iter().flat_map(|nom| { + balance_slash(nom.clone()).map(Into::into).chain(slash(nom).map(Into::into)).map(Box::new) + }); + + let events = chill(offender.stash.clone()).map(Into::into).map(Box::new) + .chain(slash_report(offender.stash.clone()).map(Into::into).map(Box::new)) + .chain(balance_slash(offender.stash.clone()).map(Into::into).map(Box::new)) + .chain(slash(offender.stash).map(Into::into).map(Box::new)) + .chain(nom_slashes) .collect::>(); - events.append(&mut reward_events); - events.into_iter() - } else { - let mut reward_events = reporters.clone().into_iter() - .map(|reporter| balance_deposit(reporter, reward).into()) - .collect::>(); - events.append(&mut reward_events); - events.into_iter() - } - }) - .collect::>(); - + // the first deposit creates endowed events, see `endowed_reward_events` + if first { + first = false; + let reward_events = reporters.iter() + .flat_map(|reporter| vec![ + Box::new(balance_deposit(reporter.clone(), reward).into()), + Box::new(frame_system::Event::::NewAccount { account: reporter.clone() }.into()), + Box::new(::RuntimeEvent::from( + pallet_balances::Event::::Endowed{ account: reporter.clone(), free_balance: reward.into() } + ).into()), + ]) + .collect::>(); + events.into_iter().chain(reward_events) + } else { + let reward_events = reporters.iter() + .map(|reporter| Box::new(balance_deposit(reporter.clone(), reward).into())) + .collect::>(); + events.into_iter().chain(reward_events) + } + }); - #[cfg(test)] - { // In case of error it's useful to see the inputs - println!("Inputs: r: {}, o: {}, n: {}", r, o, n); + log::info!("Inputs: r: {}, o: {}, n: {}", r, o, n); // make sure that all slashes have been applied - check_events::( - std::iter::empty() - .chain(slash_events.into_iter().map(Into::into)) - .chain(std::iter::once(::RuntimeEvent::from( + check_events::( + sp_std::iter::empty() + .chain(slash_events) + .chain(sp_std::iter::once(Box::new(::RuntimeEvent::from( pallet_offences::Event::Offence{ kind: UnresponsivenessOffence::::ID, timeslot: 0_u32.to_le_bytes().to_vec(), } - ).into())) + ).into()))) ); } } From ea002409d10af3fb7a402b6948303233c6f46549 Mon Sep 17 00:00:00 2001 From: JP <77391175+joao-paulo-parity@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:03:46 -0300 Subject: [PATCH 15/80] More improvements for the crate publishing pipeline (#13153) * more improvements for the crate publishing pipeline * move default definitions to the publish-crates script * add script to check the crate publishing pipeline at the start * fix yaml references * move more variables to .crates-publishing-pipeline * separate .crates-publishing-pipeline from .crates-publishing-variables * clean up redundant and unused code --- .gitlab-ci.yml | 39 ++++++++++++++++---------- scripts/ci/gitlab/pipeline/publish.yml | 28 ++++++++---------- scripts/ci/gitlab/pipeline/test.yml | 7 ++++- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ecc27d016a..ae25a2c595 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -229,19 +229,21 @@ variables: # this job runs only on nightly pipeline with the mentioned variable, against `master` branch - if: $CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "nightly" -.crate-publishing-pipeline: - rules: - - if: $CI_COMMIT_REF_NAME != "master" - when: never +.crates-publishing-variables: + variables: + CRATESIO_CRATES_OWNER: parity-crate-owner + REPO: substrate + REPO_OWNER: paritytech -.scheduled-crate-publishing-pipeline: +.crates-publishing-pipeline: + extends: .crates-publishing-variables rules: - - !reference [.crate-publishing-pipeline, rules] - - if: $CI_PIPELINE_SOURCE == "schedule" && $PIPELINE == "automatic-crate-publishing" + - if: $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_REF_NAME == "master" && $PIPELINE == "automatic-crate-publishing" .crates-publishing-template: - stage: test - extends: .docker-env + extends: + - .docker-env + - .crates-publishing-variables # collect artifacts even on failure so that we know how the crates were generated (they'll be # generated to the artifacts folder according to SPUB_TMP further down) artifacts: @@ -251,12 +253,7 @@ variables: paths: - artifacts/ variables: - CRATESIO_API: https://crates.io/api - CRATESIO_CRATES_OWNER: parity-crate-owner - GH_API: https://api.github.com - REPO: substrate - REPO_OWNER: paritytech - SPUB_TMP: artifacts + SPUB_TMP: artifacts #### stage: .pre @@ -274,6 +271,18 @@ skip-if-draft: - ./scripts/ci/gitlab/skip_if_draft.sh allow_failure: true +check-crates-publishing-pipeline: + stage: .pre + extends: + - .kubernetes-env + - .crates-publishing-pipeline + script: + - git clone + --depth 1 + --branch "$RELENG_SCRIPTS_BRANCH" + https://github.com/paritytech/releng-scripts.git + - ONLY_CHECK_PIPELINE=true ./releng-scripts/publish-crates + include: # check jobs - scripts/ci/gitlab/pipeline/check.yml diff --git a/scripts/ci/gitlab/pipeline/publish.yml b/scripts/ci/gitlab/pipeline/publish.yml index d1a7514d17..4eafb0a055 100644 --- a/scripts/ci/gitlab/pipeline/publish.yml +++ b/scripts/ci/gitlab/pipeline/publish.yml @@ -184,19 +184,19 @@ publish-draft-release: .publish-crates-template: stage: publish - extends: .crates-publishing-template + extends: + - .crates-publishing-template + - .crates-publishing-pipeline # We don't want multiple jobs racing to publish crates as it's redundant and they might overwrite # the releases of one another. Use resource_group to ensure that at most one instance of this job # is running at any given time. resource_group: crates-publishing - variables: - # crates.io rate limits crates publishing by 1 per minute, so a delay needs to be inserted - # slightly higher than that after publishing each crate. The value is specified in seconds. - SPUB_AFTER_PUBLISH_DELAY: 64 - # We might have to publish lots of crates at a time. Given the 1 minute delay introduced above and - # taking into account the 202 (as of Dec 07, 2022) publishable Substrate crates, that would equate - # to roughly 202 minutes of delay, or 3h and 22 minutes. As such, the job needs to have a much - # higher timeout than average. + # crates.io currently rate limits crate publishing at 1 per minute: + # https://github.com/paritytech/release-engineering/issues/123#issuecomment-1335509748 + # Taking into account the 202 (as of Dec 07, 2022) publishable Substrate crates, in the worst + # case, due to the rate limits alone, we'd have to wait through at least 202 minutes of delay. + # Taking into account also the verification steps and extra synchronization delays after + # publishing the crate, the job needs to have a much higher timeout than average. timeout: 9h # A custom publishing environment is used for us to be able to set up protected secrets # specifically for it @@ -211,15 +211,9 @@ publish-draft-release: - rusty-cachier cache upload publish-crates: - extends: - - .publish-crates-template - - .scheduled-crate-publishing-pipeline - needs: - - job: publish-crates-locally - artifacts: false + extends: .publish-crates-template publish-crates-manual: extends: .publish-crates-template - rules: !reference [.crate-publishing-pipeline, rules] when: manual - allow_failure: true + interruptible: false diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 466019e42e..f00857ffa9 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -14,7 +14,7 @@ find-fail-ci-phrase: script: - set +e - rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$? - - if [ $exit_status -eq 0 ]; then + - if [ $exit_status -eq 0 ]; then echo "$ASSERT_REGEX was found, exiting with 1"; exit 1; else @@ -417,9 +417,14 @@ cargo-check-each-crate: parallel: 2 publish-crates-locally: + stage: test extends: - .test-refs - .crates-publishing-template + # When lots of crates are taken into account (for example on master where all crates are tested) + # the job might take a long time, as evidenced by: + # https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2269364 + timeout: 4h script: - rusty-cachier snapshot create - git clone From 7ff6fa2bfa47f288216fdc6e1585f69756c5ec75 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Mon, 16 Jan 2023 23:15:22 +0100 Subject: [PATCH 16/80] txpool: don't maintain the pool during major sync (#13004) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * txpool: don't maintain the pool during major sync Fix shall prevent from wasting the CPU during the major sync. No actions are actually required in transaction pool during the major sync. Fixes: #12903 * passing sync_oracle to maintain method * fixed: builder, txpool tests * do not maintain tx-pool if node gone out of sync * EnactmentAction: all logic moved to EnactmentState Tests to be done. * maintain guard logic moved directly to MaintainedTransactionPool * minor fixes * EnactmentAction: all logic moved to EnactmentState (again) * SyncOracle fixes here and there * Update client/transaction-pool/src/enactment_state.rs Co-authored-by: Bastian Köcher * Update client/transaction-pool/src/enactment_state.rs Co-authored-by: Bastian Köcher * sync_oracle removed * spelling + fmt + doc * Review suggestions applied * log::info -> debug * Update client/transaction-pool/src/enactment_state.rs Co-authored-by: Bastian Köcher * ".git/.scripts/commands/fmt/fmt.sh" Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher --- Cargo.lock | 1 + client/transaction-pool/Cargo.toml | 1 + .../transaction-pool/src/enactment_state.rs | 185 +++++++++++++----- client/transaction-pool/src/lib.rs | 14 +- 4 files changed, 145 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4e3e1b846..4466382772 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9046,6 +9046,7 @@ dependencies = [ "futures-timer", "linked-hash-map", "log", + "num-traits", "parity-scale-codec", "parking_lot 0.12.1", "sc-block-builder", diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 7a3ab042d5..4b69b6d0f2 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -19,6 +19,7 @@ futures = "0.3.21" futures-timer = "3.0.2" linked-hash-map = "0.5.4" log = "0.4.17" +num-traits = "0.2.8" parking_lot = "0.12.1" serde = { version = "1.0.136", features = ["derive"] } thiserror = "1.0.30" diff --git a/client/transaction-pool/src/enactment_state.rs b/client/transaction-pool/src/enactment_state.rs index 6aac98641c..382b268315 100644 --- a/client/transaction-pool/src/enactment_state.rs +++ b/client/transaction-pool/src/enactment_state.rs @@ -18,13 +18,21 @@ //! Substrate transaction pool implementation. +use num_traits::CheckedSub; use sc_transaction_pool_api::ChainEvent; use sp_blockchain::TreeRoute; -use sp_runtime::traits::Block as BlockT; +use sp_runtime::traits::{Block as BlockT, NumberFor}; + +/// The threshold since the last update where we will skip any maintenance for blocks. +/// +/// This includes tracking re-orgs and sending out certain notifications. In general this shouldn't +/// happen and may only happen when the node is doing a full sync. +const SKIP_MAINTENANCE_THRESHOLD: u16 = 20; /// Helper struct for keeping track of the current state of processed new best /// block and finalized events. The main purpose of keeping track of this state -/// is to figure out if a transaction pool enactment is needed or not. +/// is to figure out which phases (enactment / finalization) of transaction pool +/// maintenance are needed. /// /// Given the following chain: /// @@ -54,6 +62,17 @@ where recent_finalized_block: Block::Hash, } +/// Enactment action that should be performed after processing the `ChainEvent` +#[derive(Debug)] +pub enum EnactmentAction { + /// Both phases of maintenance shall be skipped + Skip, + /// Both phases of maintenance shall be performed + HandleEnactment(TreeRoute), + /// Enactment phase of maintenance shall be skipped + HandleFinalization, +} + impl EnactmentState where Block: BlockT, @@ -71,23 +90,38 @@ where /// Updates the state according to the given `ChainEvent`, returning /// `Some(tree_route)` with a tree route including the blocks that need to /// be enacted/retracted. If no enactment is needed then `None` is returned. - pub fn update( + pub fn update( &mut self, event: &ChainEvent, - tree_route: &F, - ) -> Result>, String> + tree_route: &TreeRouteF, + hash_to_number: &BlockNumberF, + ) -> Result, String> where - F: Fn(Block::Hash, Block::Hash) -> Result, String>, + TreeRouteF: Fn(Block::Hash, Block::Hash) -> Result, String>, + BlockNumberF: Fn(Block::Hash) -> Result>, String>, { - let (new_hash, finalized) = match event { - ChainEvent::NewBestBlock { hash, .. } => (*hash, false), - ChainEvent::Finalized { hash, .. } => (*hash, true), + let (new_hash, current_hash, finalized) = match event { + ChainEvent::NewBestBlock { hash, .. } => (*hash, self.recent_best_block, false), + ChainEvent::Finalized { hash, .. } => (*hash, self.recent_finalized_block, true), }; + // do not proceed with txpool maintain if block distance is to high + let skip_maintenance = match (hash_to_number(new_hash), hash_to_number(current_hash)) { + (Ok(Some(new)), Ok(Some(current))) => + new.checked_sub(¤t) > Some(SKIP_MAINTENANCE_THRESHOLD.into()), + _ => true, + }; + + if skip_maintenance { + log::debug!(target: "txpool", "skip maintain: tree_route would be too long"); + self.force_update(event); + return Ok(EnactmentAction::Skip) + } + // block was already finalized if self.recent_finalized_block == new_hash { log::debug!(target: "txpool", "handle_enactment: block already finalized"); - return Ok(None) + return Ok(EnactmentAction::Skip) } // compute actual tree route from best_block to notified block, and use @@ -109,7 +143,7 @@ where "Recently finalized block {} would be retracted by ChainEvent {}, skipping", self.recent_finalized_block, new_hash ); - return Ok(None) + return Ok(EnactmentAction::Skip) } if finalized { @@ -124,7 +158,7 @@ where target: "txpool", "handle_enactment: no newly enacted blocks since recent best block" ); - return Ok(None) + return Ok(EnactmentAction::HandleFinalization) } // otherwise enacted finalized block becomes best block... @@ -132,7 +166,7 @@ where self.recent_best_block = new_hash; - Ok(Some(tree_route)) + Ok(EnactmentAction::HandleEnactment(tree_route)) } /// Forces update of the state according to the given `ChainEvent`. Intended to be used as a @@ -148,9 +182,10 @@ where #[cfg(test)] mod enactment_state_tests { - use super::EnactmentState; + use super::{EnactmentAction, EnactmentState}; use sc_transaction_pool_api::ChainEvent; use sp_blockchain::{HashAndNumber, TreeRoute}; + use sp_runtime::traits::NumberFor; use std::sync::Arc; use substrate_test_runtime_client::runtime::{Block, Hash}; @@ -170,6 +205,9 @@ mod enactment_state_tests { fn e1() -> HashAndNumber { HashAndNumber { number: 5, hash: Hash::from([0xE1; 32]) } } + fn x1() -> HashAndNumber { + HashAndNumber { number: 22, hash: Hash::from([0x1E; 32]) } + } fn b2() -> HashAndNumber { HashAndNumber { number: 2, hash: Hash::from([0xB2; 32]) } } @@ -182,11 +220,22 @@ mod enactment_state_tests { fn e2() -> HashAndNumber { HashAndNumber { number: 5, hash: Hash::from([0xE2; 32]) } } + fn x2() -> HashAndNumber { + HashAndNumber { number: 22, hash: Hash::from([0x2E; 32]) } + } + + fn test_chain() -> Vec> { + vec![x1(), e1(), d1(), c1(), b1(), a(), b2(), c2(), d2(), e2(), x2()] + } + + fn block_hash_to_block_number(hash: Hash) -> Result>, String> { + Ok(test_chain().iter().find(|x| x.hash == hash).map(|x| x.number)) + } /// mock tree_route computing function for simple two-forks chain fn tree_route(from: Hash, to: Hash) -> Result, String> { - let chain = vec![e1(), d1(), c1(), b1(), a(), b2(), c2(), d2(), e2()]; - let pivot = 4_usize; + let chain = test_chain(); + let pivot = chain.iter().position(|x| x.number == a().number).unwrap(); let from = chain .iter() @@ -197,13 +246,13 @@ mod enactment_state_tests { .position(|bn| bn.hash == to) .ok_or("existing block should be given")?; - // B1-C1-D1-E1 + // B1-C1-D1-E1-..-X1 // / // A // \ - // B2-C2-D2-E2 + // B2-C2-D2-E2-..-X2 // - // [E1 D1 C1 B1 A B2 C2 D2 E2] + // [X1 E1 D1 C1 B1 A B2 C2 D2 E2 X2] let vec: Vec> = if from < to { chain.into_iter().skip(from).take(to - from + 1).collect() @@ -373,13 +422,20 @@ mod enactment_state_tests { let expected = TreeRoute::new(vec![a()], 0); assert_treeroute_eq(result, expected); } + + #[test] + fn tree_route_mock_test_17() { + let result = tree_route(x2().hash, b1().hash); + let expected = TreeRoute::new(vec![x2(), e2(), d2(), c2(), b2(), a(), b1()], 5); + assert_treeroute_eq(result, expected); + } } fn trigger_new_best_block( state: &mut EnactmentState, from: HashAndNumber, acted_on: HashAndNumber, - ) -> bool { + ) -> EnactmentAction { let (from, acted_on) = (from.hash, acted_on.hash); let event_tree_route = tree_route(from, acted_on).expect("Tree route exists"); @@ -391,16 +447,16 @@ mod enactment_state_tests { tree_route: Some(Arc::new(event_tree_route)), }, &tree_route, + &block_hash_to_block_number, ) .unwrap() - .is_some() } fn trigger_finalized( state: &mut EnactmentState, from: HashAndNumber, acted_on: HashAndNumber, - ) -> bool { + ) -> EnactmentAction { let (from, acted_on) = (from.hash, acted_on.hash); let v = tree_route(from, acted_on) @@ -411,9 +467,12 @@ mod enactment_state_tests { .collect::>(); state - .update(&ChainEvent::Finalized { hash: acted_on, tree_route: v.into() }, &tree_route) + .update( + &ChainEvent::Finalized { hash: acted_on, tree_route: v.into() }, + &tree_route, + &block_hash_to_block_number, + ) .unwrap() - .is_some() } fn assert_es_eq( @@ -437,51 +496,51 @@ mod enactment_state_tests { // B2-C2-D2-E2 let result = trigger_new_best_block(&mut es, a(), d1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, d1(), a()); let result = trigger_new_best_block(&mut es, d1(), e1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e1(), a()); let result = trigger_finalized(&mut es, a(), d2()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, d2(), d2()); let result = trigger_new_best_block(&mut es, d2(), e1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_finalized(&mut es, a(), b2()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_finalized(&mut es, a(), b1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_new_best_block(&mut es, a(), d2()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_finalized(&mut es, a(), d2()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_new_best_block(&mut es, a(), c2()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_new_best_block(&mut es, a(), c1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, d2(), d2()); let result = trigger_new_best_block(&mut es, d2(), e2()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e2(), d2()); let result = trigger_finalized(&mut es, d2(), e2()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::HandleFinalization)); assert_es_eq(&es, e2(), e2()); } @@ -493,27 +552,27 @@ mod enactment_state_tests { // A-B1-C1-D1-E1 let result = trigger_new_best_block(&mut es, a(), b1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, b1(), a()); let result = trigger_new_best_block(&mut es, b1(), c1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, c1(), a()); let result = trigger_new_best_block(&mut es, c1(), d1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, d1(), a()); let result = trigger_new_best_block(&mut es, d1(), e1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e1(), a()); let result = trigger_finalized(&mut es, a(), c1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::HandleFinalization)); assert_es_eq(&es, e1(), c1()); let result = trigger_finalized(&mut es, c1(), e1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::HandleFinalization)); assert_es_eq(&es, e1(), e1()); } @@ -525,11 +584,11 @@ mod enactment_state_tests { // A-B1-C1-D1-E1 let result = trigger_new_best_block(&mut es, a(), e1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e1(), a()); let result = trigger_finalized(&mut es, a(), b1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::HandleFinalization)); assert_es_eq(&es, e1(), b1()); } @@ -541,11 +600,11 @@ mod enactment_state_tests { // A-B1-C1-D1-E1 let result = trigger_finalized(&mut es, a(), e1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e1(), e1()); let result = trigger_finalized(&mut es, e1(), b1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, e1(), e1()); } @@ -561,11 +620,11 @@ mod enactment_state_tests { // B2-C2-D2-E2 let result = trigger_finalized(&mut es, a(), e1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e1(), e1()); let result = trigger_finalized(&mut es, e1(), e2()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, e1(), e1()); } @@ -577,19 +636,19 @@ mod enactment_state_tests { // A-B1-C1-D1-E1 let result = trigger_new_best_block(&mut es, a(), b1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, b1(), a()); let result = trigger_finalized(&mut es, a(), d1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, d1(), d1()); let result = trigger_new_best_block(&mut es, a(), e1()); - assert!(result); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); assert_es_eq(&es, e1(), d1()); let result = trigger_new_best_block(&mut es, a(), c1()); - assert_eq!(result, false); + assert!(matches!(result, EnactmentAction::Skip)); assert_es_eq(&es, e1(), d1()); } @@ -610,4 +669,26 @@ mod enactment_state_tests { es.force_update(&ChainEvent::Finalized { hash: b1().hash, tree_route: Arc::from([]) }); assert_es_eq(&es, a(), b1()); } + + #[test] + fn test_enactment_skip_long_enacted_path() { + sp_tracing::try_init_simple(); + let mut es = EnactmentState::new(a().hash, a().hash); + + // A-B1-C1-..-X1 + let result = trigger_new_best_block(&mut es, a(), x1()); + assert!(matches!(result, EnactmentAction::Skip)); + assert_es_eq(&es, x1(), a()); + } + + #[test] + fn test_enactment_proceed_with_enacted_path_at_threshold() { + sp_tracing::try_init_simple(); + let mut es = EnactmentState::new(b1().hash, b1().hash); + + // A-B1-C1-..-X1 + let result = trigger_new_best_block(&mut es, b1(), x1()); + assert!(matches!(result, EnactmentAction::HandleEnactment { .. })); + assert_es_eq(&es, x1(), b1()); + } } diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index f3797b180f..1cd9bef77b 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -33,7 +33,7 @@ mod tests; pub use crate::api::FullChainApi; use async_trait::async_trait; -use enactment_state::EnactmentState; +use enactment_state::{EnactmentAction, EnactmentState}; use futures::{ channel::oneshot, future::{self, ready}, @@ -732,16 +732,22 @@ where )), } }; + let block_id_to_number = + |hash| self.api.block_id_to_number(&BlockId::Hash(hash)).map_err(|e| format!("{}", e)); - let result = self.enactment_state.lock().update(&event, &compute_tree_route); + let result = + self.enactment_state + .lock() + .update(&event, &compute_tree_route, &block_id_to_number); match result { Err(msg) => { log::debug!(target: "txpool", "{msg}"); self.enactment_state.lock().force_update(&event); }, - Ok(None) => {}, - Ok(Some(tree_route)) => { + Ok(EnactmentAction::Skip) => return, + Ok(EnactmentAction::HandleFinalization) => {}, + Ok(EnactmentAction::HandleEnactment(tree_route)) => { self.handle_enactment(tree_route).await; }, }; From 28937302694787cd1e6dbd846ff2ba4b1cf82025 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 17 Jan 2023 14:28:17 +0400 Subject: [PATCH 17/80] [client/network] Add support for `/wss` addresses (#13152) * join dns with another instance of WS transport Secure Websocket transport needs unresolved addresses, so we join DNS transport with yet another instance of Websocket transport. Closes #12024 * WSS transport itself need to wrap DNS transport in order to resolve addresses before passing them down to TCP transport Refs https://github.com/libp2p/rust-libp2p/issues/3330 * reverse order * simplify code: remove WS from WSS inner DNS transport * remove the 2nd instance of WS transport --- client/network/src/transport.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/client/network/src/transport.rs b/client/network/src/transport.rs index 6c792a0c38..51a8483e0e 100644 --- a/client/network/src/transport.rs +++ b/client/network/src/transport.rs @@ -54,18 +54,27 @@ pub fn build_transport( ) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc) { // Build the base layer of the transport. let transport = if !memory_only { + // Main transport: DNS(TCP) let tcp_config = tcp::Config::new().nodelay(true); - let desktop_trans = tcp::tokio::Transport::new(tcp_config.clone()); - let desktop_trans = websocket::WsConfig::new(desktop_trans) - .or_transport(tcp::tokio::Transport::new(tcp_config.clone())); - let dns_init = dns::TokioDnsConfig::system(desktop_trans); + let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); + let dns_init = dns::TokioDnsConfig::system(tcp_trans); + EitherTransport::Left(if let Ok(dns) = dns_init { - EitherTransport::Left(dns) + // WS + WSS transport + // + // Main transport can't be used for `/wss` addresses because WSS transport needs + // unresolved addresses (BUT WSS transport itself needs an instance of DNS transport to + // resolve and dial addresses). + let tcp_trans = tcp::tokio::Transport::new(tcp_config); + let dns_for_wss = dns::TokioDnsConfig::system(tcp_trans) + .expect("same system_conf & resolver to work"); + EitherTransport::Left(websocket::WsConfig::new(dns_for_wss).or_transport(dns)) } else { - let desktop_trans = tcp::tokio::Transport::new(tcp_config.clone()); - let desktop_trans = websocket::WsConfig::new(desktop_trans) + // In case DNS can't be constructed, fallback to TCP + WS (WSS won't work) + let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); + let desktop_trans = websocket::WsConfig::new(tcp_trans) .or_transport(tcp::tokio::Transport::new(tcp_config)); - EitherTransport::Right(desktop_trans.map_err(dns::DnsErr::Transport)) + EitherTransport::Right(desktop_trans) }) } else { EitherTransport::Right(OptionalTransport::some( From 6bac243eec55cb17ac598e2bb689b5303e633b01 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 17 Jan 2023 11:37:59 -0300 Subject: [PATCH 18/80] NIS should retain funds in reserve (#12928) * Keep funds with receipt holder * Counterpart is optional * Use named reserves * Tests * Benchmarks * Fixes * Update frame/nis/src/lib.rs Co-authored-by: Keith Yeung * Update frame/nis/src/lib.rs Co-authored-by: Keith Yeung * Update frame/nis/src/lib.rs * Update frame/nis/src/lib.rs * Update frame/nis/src/tests.rs * Update frame/nis/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/nis/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/nis/src/lib.rs Co-authored-by: Oliver Tale-Yazdi * Update frame/nis/src/lib.rs * Update frame/nis/src/lib.rs * Update frame/nis/src/lib.rs * Update frame/nis/src/lib.rs * Formatting Co-authored-by: Keith Yeung Co-authored-by: Oliver Tale-Yazdi --- bin/node/runtime/src/lib.rs | 2 + frame/nis/src/benchmarking.rs | 41 +- frame/nis/src/lib.rs | 312 +++++++++++--- frame/nis/src/mock.rs | 4 +- frame/nis/src/tests.rs | 453 ++++++++++++++------ frame/nis/src/weights.rs | 320 ++++++++------ frame/support/src/traits/tokens/fungible.rs | 5 + 7 files changed, 828 insertions(+), 309 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index a9e93a16f0..d34c04fcb5 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1499,6 +1499,7 @@ parameter_types! { pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5); pub Target: Perquintill = Perquintill::zero(); pub const NisPalletId: PalletId = PalletId(*b"py/nis "); + pub const NisReserveId: [u8; 8] = *b"py/nis "; } impl pallet_nis::Config for Runtime { @@ -1522,6 +1523,7 @@ impl pallet_nis::Config for Runtime { type IntakePeriod = IntakePeriod; type MaxIntakeWeight = MaxIntakeWeight; type ThawThrottle = ThawThrottle; + type ReserveId = NisReserveId; } parameter_types! { diff --git a/frame/nis/src/benchmarking.rs b/frame/nis/src/benchmarking.rs index 606b1c484b..b45c982bd1 100644 --- a/frame/nis/src/benchmarking.rs +++ b/frame/nis/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; -use frame_support::traits::{Currency, EnsureOrigin, Get}; +use frame_support::traits::{nonfungible::Inspect, Currency, EnsureOrigin, Get}; use frame_system::RawOrigin; use sp_arithmetic::Perquintill; use sp_runtime::{ @@ -106,6 +106,7 @@ benchmarks! { T::Currency::make_free_balance_be(&caller, bid); Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), bid, 1)?; Nis::::process_queues(Perquintill::one(), 1, 1, &mut WeightCounter::unlimited()); + Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; let original = T::Currency::free_balance(&Nis::::account_id()); T::Currency::make_free_balance_be(&Nis::::account_id(), BalanceOf::::min_value()); }: _(origin) @@ -116,7 +117,7 @@ benchmarks! { assert!(missing <= Perquintill::one() / 100_000); } - thaw { + thaw_private { let caller: T::AccountId = whitelisted_caller(); T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; @@ -128,6 +129,42 @@ benchmarks! { assert!(Receipts::::get(0).is_none()); } + thaw_communal { + let caller: T::AccountId = whitelisted_caller(); + T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); + Receipts::::mutate(0, |m_g| if let Some(ref mut g) = m_g { g.expiry = Zero::zero() }); + Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; + }: _(RawOrigin::Signed(caller.clone()), 0) + verify { + assert!(Receipts::::get(0).is_none()); + } + + privatize { + let caller: T::AccountId = whitelisted_caller(); + T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); + Nis::::communify(RawOrigin::Signed(caller.clone()).into(), 0)?; + }: _(RawOrigin::Signed(caller.clone()), 0) + verify { + assert_eq!(Nis::::owner(&0), Some(caller)); + } + + communify { + let caller: T::AccountId = whitelisted_caller(); + T::Currency::make_free_balance_be(&caller, T::MinBid::get() * BalanceOf::::from(3u32)); + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + Nis::::place_bid(RawOrigin::Signed(caller.clone()).into(), T::MinBid::get(), 1)?; + Nis::::process_queues(Perquintill::one(), 1, 2, &mut WeightCounter::unlimited()); + }: _(RawOrigin::Signed(caller.clone()), 0) + verify { + assert_eq!(Nis::::owner(&0), None); + } + process_queues { fill_queues::()?; }: { diff --git a/frame/nis/src/lib.rs b/frame/nis/src/lib.rs index dff64625a3..fa0163fb60 100644 --- a/frame/nis/src/lib.rs +++ b/frame/nis/src/lib.rs @@ -169,7 +169,7 @@ pub mod pallet { nonfungible::{Inspect as NonfungibleInspect, Transfer as NonfungibleTransfer}, Currency, Defensive, DefensiveSaturating, ExistenceRequirement::AllowDeath, - OnUnbalanced, ReservableCurrency, + NamedReservableCurrency, OnUnbalanced, }, PalletId, }; @@ -189,9 +189,10 @@ pub mod pallet { type ReceiptRecordOf = ReceiptRecord< ::AccountId, ::BlockNumber, + BalanceOf, >; type IssuanceInfoOf = IssuanceInfo>; - type SummaryRecordOf = SummaryRecord<::BlockNumber>; + type SummaryRecordOf = SummaryRecord<::BlockNumber, BalanceOf>; type BidOf = Bid, ::AccountId>; type QueueTotalsTypeOf = BoundedVec<(u32, BalanceOf), ::QueueCount>; @@ -208,7 +209,7 @@ pub mod pallet { type PalletId: Get; /// Currency type that this works on. - type Currency: ReservableCurrency; + type Currency: NamedReservableCurrency; /// Just the `Currency::Balance` type; we have this item to allow us to constrain it to /// `From`. @@ -300,6 +301,12 @@ pub mod pallet { /// The maximum proportion which may be thawed and the period over which it is reset. #[pallet::constant] type ThawThrottle: Get<(Perquintill, Self::BlockNumber)>; + + /// The name for the reserve ID. + #[pallet::constant] + type ReserveId: Get< + >::ReserveIdentifier, + >; } #[pallet::pallet] @@ -321,11 +328,13 @@ pub mod pallet { #[derive( Clone, Eq, PartialEq, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen, )] - pub struct ReceiptRecord { + pub struct ReceiptRecord { /// The proportion of the effective total issuance. pub proportion: Perquintill, - /// The account to whom this receipt belongs. - pub who: AccountId, + /// The account to whom this receipt belongs and the amount of funds on hold in their + /// account for servicing this receipt. If `None`, then it is a communal receipt and + /// fungible counterparts have been issued. + pub owner: Option<(AccountId, Balance)>, /// The time after which this receipt can be thawed. pub expiry: BlockNumber, } @@ -344,7 +353,7 @@ pub mod pallet { #[derive( Clone, Eq, PartialEq, Default, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen, )] - pub struct SummaryRecord { + pub struct SummaryRecord { /// The total proportion over all outstanding receipts. pub proportion_owed: Perquintill, /// The total number of receipts created so far. @@ -353,6 +362,9 @@ pub mod pallet { pub thawed: Perquintill, /// The current thaw period's beginning. pub last_period: BlockNumber, + /// The total amount of funds on hold for receipts. This doesn't include the pot or funds + /// on hold for bids. + pub receipts_on_hold: Balance, } pub struct OnEmptyQueueTotals(sp_std::marker::PhantomData); @@ -440,24 +452,28 @@ pub mod pallet { /// The queue for the bid's duration is full and the amount bid is too low to get in /// through replacing an existing bid. BidTooLow, - /// Bond index is unknown. - Unknown, + /// Receipt index is unknown. + UnknownReceipt, /// Not the owner of the receipt. NotOwner, /// Bond not yet at expiry date. NotExpired, /// The given bid for retraction is not found. - NotFound, + UnknownBid, /// The portion supplied is beyond the value of the receipt. - TooMuch, + PortionTooBig, /// Not enough funds are held to pay out. Unfunded, /// There are enough funds for what is required. - Funded, + AlreadyFunded, /// The thaw throttle has been reached for this period. Throttled, /// The operation would result in a receipt worth an insignficant value. MakesDust, + /// The receipt is already communal. + AlreadyCommunal, + /// The receipt is already private. + AlreadyPrivate, } pub(crate) struct WeightCounter { @@ -539,13 +555,17 @@ pub mod pallet { |q| -> Result<(u32, BalanceOf), DispatchError> { let queue_full = q.len() == T::MaxQueueLen::get() as usize; ensure!(!queue_full || q[0].amount < amount, Error::::BidTooLow); - T::Currency::reserve(&who, amount)?; + T::Currency::reserve_named(&T::ReserveId::get(), &who, amount)?; // queue is let mut bid = Bid { amount, who: who.clone() }; let net = if queue_full { sp_std::mem::swap(&mut q[0], &mut bid); - let _ = T::Currency::unreserve(&bid.who, bid.amount); + let _ = T::Currency::unreserve_named( + &T::ReserveId::get(), + &bid.who, + bid.amount, + ); Self::deposit_event(Event::::BidDropped { who: bid.who, amount: bid.amount, @@ -597,7 +617,7 @@ pub mod pallet { let bid = Bid { amount, who }; let new_len = Queues::::try_mutate(duration, |q| -> Result { - let pos = q.iter().position(|i| i == &bid).ok_or(Error::::NotFound)?; + let pos = q.iter().position(|i| i == &bid).ok_or(Error::::UnknownBid)?; q.remove(pos); Ok(q.len() as u32) })?; @@ -608,7 +628,7 @@ pub mod pallet { qs[queue_index].1.saturating_reduce(bid.amount); }); - T::Currency::unreserve(&bid.who, bid.amount); + T::Currency::unreserve_named(&T::ReserveId::get(), &bid.who, bid.amount); Self::deposit_event(Event::BidRetracted { who: bid.who, amount: bid.amount, duration }); Ok(()) @@ -625,7 +645,7 @@ pub mod pallet { let our_account = Self::account_id(); let issuance = Self::issuance_with(&our_account, &summary); let deficit = issuance.required.saturating_sub(issuance.holdings); - ensure!(!deficit.is_zero(), Error::::Funded); + ensure!(!deficit.is_zero(), Error::::AlreadyFunded); T::Deficit::on_unbalanced(T::Currency::deposit_creating(&our_account, deficit)); Self::deposit_event(Event::::Funded { deficit }); Ok(()) @@ -640,27 +660,28 @@ pub mod pallet { /// - `portion`: If `Some`, then only the given portion of the receipt should be thawed. If /// `None`, then all of it should be. #[pallet::call_index(3)] - #[pallet::weight(T::WeightInfo::thaw())] - pub fn thaw( + #[pallet::weight(T::WeightInfo::thaw_private())] + pub fn thaw_private( origin: OriginFor, #[pallet::compact] index: ReceiptIndex, - portion: Option<>::Balance>, + maybe_proportion: Option, ) -> DispatchResult { let who = ensure_signed(origin)?; // Look for `index` let mut receipt: ReceiptRecordOf = - Receipts::::get(index).ok_or(Error::::Unknown)?; + Receipts::::get(index).ok_or(Error::::UnknownReceipt)?; // If found, check the owner is `who`. - ensure!(receipt.who == who, Error::::NotOwner); + let (owner, mut on_hold) = receipt.owner.ok_or(Error::::AlreadyCommunal)?; + ensure!(owner == who, Error::::NotOwner); + let now = frame_system::Pallet::::block_number(); ensure!(now >= receipt.expiry, Error::::NotExpired); let mut summary: SummaryRecordOf = Summary::::get(); - let proportion = if let Some(counterpart) = portion { - let proportion = T::CounterpartAmount::convert_back(counterpart); - ensure!(proportion <= receipt.proportion, Error::::TooMuch); + let proportion = if let Some(proportion) = maybe_proportion { + ensure!(proportion <= receipt.proportion, Error::::PortionTooBig); let remaining = receipt.proportion.saturating_sub(proportion); ensure!( remaining.is_zero() || remaining >= T::MinReceipt::get(), @@ -679,8 +700,6 @@ pub mod pallet { summary.thawed.saturating_accrue(proportion); ensure!(summary.thawed <= throttle, Error::::Throttled); - T::Counterpart::burn_from(&who, T::CounterpartAmount::convert(proportion))?; - // Multiply the proportion it is by the total issued. let our_account = Self::account_id(); let effective_issuance = Self::issuance_with(&our_account, &summary).effective; @@ -689,13 +708,55 @@ pub mod pallet { receipt.proportion.saturating_reduce(proportion); summary.proportion_owed.saturating_reduce(proportion); - T::Currency::transfer(&our_account, &who, amount, AllowDeath) - .map_err(|_| Error::::Unfunded)?; - let dropped = receipt.proportion.is_zero(); + + if amount > on_hold { + T::Currency::unreserve_named(&T::ReserveId::get(), &who, on_hold); + let deficit = amount - on_hold; + // Try to transfer deficit from pot to receipt owner. + summary.receipts_on_hold.saturating_reduce(on_hold); + on_hold = Zero::zero(); + T::Currency::transfer(&our_account, &who, deficit, AllowDeath) + .map_err(|_| Error::::Unfunded)?; + } else { + T::Currency::unreserve_named(&T::ReserveId::get(), &who, amount); + on_hold.saturating_reduce(amount); + summary.receipts_on_hold.saturating_reduce(amount); + if dropped && !on_hold.is_zero() { + // Reclaim any remainder: + // Transfer `excess` to the pot if we have now fully compensated for the + // receipt. + // + // This will legitimately fail if there is no pot account in existance. + // There's nothing we can do about this so we just swallow the error. + // This code is not ideal and could fail in the second phase leaving + // the system in an invalid state. It can be fixed properly with the + // new API in https://github.com/paritytech/substrate/pull/12951 + // + // Below is what it should look like then: + // let _ = T::Currency::repatriate_reserved_named( + // &T::ReserveId::get(), + // &who, + // &our_account, + // excess, + // BalanceStatus::Free, + // ).defensive(); + T::Currency::unreserve_named(&T::ReserveId::get(), &who, on_hold); + // It could theoretically be locked, so really we should be using a more + // forceful variant. But the alternative `repatriate_reserved_named` will + // fail if the destination account doesn't exist. This should be fixed when + // we move to the `fungible::*` traits, which should include a force + // transfer function to transfer the reserved balance into free balance in + // the destination regardless of locks and create it if it doesn't exist. + let _ = T::Currency::transfer(&who, &Self::account_id(), on_hold, AllowDeath); + summary.receipts_on_hold.saturating_reduce(on_hold); + } + } + if dropped { Receipts::::remove(index); } else { + receipt.owner = Some((owner, on_hold)); Receipts::::insert(index, &receipt); } Summary::::put(&summary); @@ -704,20 +765,159 @@ pub mod pallet { Ok(()) } + + /// Reduce or remove an outstanding receipt, placing the according proportion of funds into + /// the account of the owner. + /// + /// - `origin`: Must be Signed and the account must be the owner of the fungible counterpart + /// for receipt `index`. + /// - `index`: The index of the receipt. + #[pallet::call_index(4)] + #[pallet::weight(T::WeightInfo::thaw_communal())] + pub fn thaw_communal( + origin: OriginFor, + #[pallet::compact] index: ReceiptIndex, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + + // Look for `index` + let receipt: ReceiptRecordOf = + Receipts::::get(index).ok_or(Error::::UnknownReceipt)?; + // If found, check it is actually communal. + ensure!(receipt.owner.is_none(), Error::::NotOwner); + let now = frame_system::Pallet::::block_number(); + ensure!(now >= receipt.expiry, Error::::NotExpired); + + let mut summary: SummaryRecordOf = Summary::::get(); + + let (throttle, throttle_period) = T::ThawThrottle::get(); + if now.saturating_sub(summary.last_period) >= throttle_period { + summary.thawed = Zero::zero(); + summary.last_period = now; + } + summary.thawed.saturating_accrue(receipt.proportion); + ensure!(summary.thawed <= throttle, Error::::Throttled); + + T::Counterpart::burn_from(&who, T::CounterpartAmount::convert(receipt.proportion))?; + + // Multiply the proportion it is by the total issued. + let our_account = Self::account_id(); + let effective_issuance = Self::issuance_with(&our_account, &summary).effective; + let amount = receipt.proportion * effective_issuance; + + summary.proportion_owed.saturating_reduce(receipt.proportion); + + // Try to transfer amount owed from pot to receipt owner. + T::Currency::transfer(&our_account, &who, amount, AllowDeath) + .map_err(|_| Error::::Unfunded)?; + + Receipts::::remove(index); + Summary::::put(&summary); + + let e = + Event::Thawed { index, who, amount, proportion: receipt.proportion, dropped: true }; + Self::deposit_event(e); + + Ok(()) + } + + /// Make a private receipt communal and create fungible counterparts for its owner. + #[pallet::call_index(5)] + #[pallet::weight(T::WeightInfo::communify())] + pub fn communify( + origin: OriginFor, + #[pallet::compact] index: ReceiptIndex, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + + // Look for `index` + let mut receipt: ReceiptRecordOf = + Receipts::::get(index).ok_or(Error::::UnknownReceipt)?; + + // Check it's not already communal and make it so. + let (owner, on_hold) = receipt.owner.take().ok_or(Error::::AlreadyCommunal)?; + + // If found, check the owner is `who`. + ensure!(owner == who, Error::::NotOwner); + + // Unreserve and transfer the funds to the pot. + T::Currency::unreserve_named(&T::ReserveId::get(), &who, on_hold); + // Transfer `excess` to the pot if we have now fully compensated for the receipt. + T::Currency::transfer(&who, &Self::account_id(), on_hold, AllowDeath) + .map_err(|_| Error::::Unfunded)?; + // TODO #12951: ^^^ The above should be done in a single operation `transfer_on_hold`. + + // Record that we've moved the amount reserved. + let mut summary: SummaryRecordOf = Summary::::get(); + summary.receipts_on_hold.saturating_reduce(on_hold); + Summary::::put(&summary); + Receipts::::insert(index, &receipt); + + // Mint fungibles. + let fung_eq = T::CounterpartAmount::convert(receipt.proportion); + let _ = T::Counterpart::mint_into(&who, fung_eq).defensive(); + + Ok(()) + } + + /// Make a communal receipt private and burn fungible counterparts from its owner. + #[pallet::call_index(6)] + #[pallet::weight(T::WeightInfo::privatize())] + pub fn privatize( + origin: OriginFor, + #[pallet::compact] index: ReceiptIndex, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + + // Look for `index` + let mut receipt: ReceiptRecordOf = + Receipts::::get(index).ok_or(Error::::UnknownReceipt)?; + + // If found, check there is no owner. + ensure!(receipt.owner.is_none(), Error::::AlreadyPrivate); + + // Multiply the proportion it is by the total issued. + let mut summary: SummaryRecordOf = Summary::::get(); + let our_account = Self::account_id(); + let effective_issuance = Self::issuance_with(&our_account, &summary).effective; + let max_amount = receipt.proportion * effective_issuance; + // Avoid trying to place more in the account's reserve than we have available in the pot + let amount = max_amount.min(T::Currency::free_balance(&our_account)); + + // Burn fungible counterparts. + T::Counterpart::burn_from(&who, T::CounterpartAmount::convert(receipt.proportion))?; + + // Transfer the funds from the pot to the owner and reserve + T::Currency::transfer(&Self::account_id(), &who, amount, AllowDeath) + .map_err(|_| Error::::Unfunded)?; + T::Currency::reserve_named(&T::ReserveId::get(), &who, amount)?; + // TODO: ^^^ The above should be done in a single operation `transfer_and_hold`. + + // Record that we've moved the amount reserved. + summary.receipts_on_hold.saturating_accrue(amount); + + receipt.owner = Some((who, amount)); + + Summary::::put(&summary); + Receipts::::insert(index, &receipt); + + Ok(()) + } } /// Issuance information returned by `issuance()`. - #[derive(RuntimeDebug)] + #[derive(Debug)] pub struct IssuanceInfo { - /// The balance held in reserve by this pallet instance. + /// The balance held by this pallet instance together with the balances on hold across + /// all receipt-owning accounts. pub holdings: Balance, /// The (non-ignored) issuance in the system, not including this pallet's account. pub other: Balance, /// The effective total issuance, hypothetically if all outstanding receipts were thawed at /// present. pub effective: Balance, - /// The amount needed to be the pallet instance's account in case all outstanding receipts - /// were thawed at present. + /// The amount needed to be accessible to this pallet in case all outstanding receipts were + /// thawed at present. If it is more than `holdings`, then the pallet will need funding. pub required: Balance, } @@ -725,7 +925,7 @@ pub mod pallet { type ItemId = ReceiptIndex; fn owner(item: &ReceiptIndex) -> Option { - Receipts::::get(item).map(|r| r.who) + Receipts::::get(item).and_then(|r| r.owner).map(|(who, _)| who) } fn attribute(item: &Self::ItemId, key: &[u8]) -> Option> { @@ -733,6 +933,8 @@ pub mod pallet { match key { b"proportion" => Some(item.proportion.encode()), b"expiry" => Some(item.expiry.encode()), + b"owner" => item.owner.as_ref().map(|x| x.0.encode()), + b"on_hold" => item.owner.as_ref().map(|x| x.1.encode()), _ => None, } } @@ -741,12 +943,28 @@ pub mod pallet { impl NonfungibleTransfer for Pallet { fn transfer(index: &ReceiptIndex, destination: &T::AccountId) -> DispatchResult { let mut item = Receipts::::get(index).ok_or(TokenError::UnknownAsset)?; - let from = item.who; - item.who = destination.clone(); + let (owner, on_hold) = item.owner.take().ok_or(Error::::AlreadyCommunal)?; + + // TODO: This should all be replaced by a single call `transfer_held`. + let shortfall = T::Currency::unreserve_named(&T::ReserveId::get(), &owner, on_hold); + if !shortfall.is_zero() { + let _ = + T::Currency::reserve_named(&T::ReserveId::get(), &owner, on_hold - shortfall); + return Err(TokenError::NoFunds.into()) + } + if let Err(e) = T::Currency::transfer(&owner, destination, on_hold, AllowDeath) { + let _ = T::Currency::reserve_named(&T::ReserveId::get(), &owner, on_hold); + return Err(e) + } + // This can never fail, and if it somehow does, then we can't handle this gracefully. + let _ = + T::Currency::reserve_named(&T::ReserveId::get(), destination, on_hold).defensive(); + + item.owner = Some((destination.clone(), on_hold)); Receipts::::insert(&index, &item); Pallet::::deposit_event(Event::::Transferred { - from, - to: item.who, + from: owner, + to: destination.clone(), index: *index, }); Ok(()) @@ -781,7 +999,8 @@ pub mod pallet { ) -> IssuanceInfo> { let total_issuance = T::Currency::total_issuance().saturating_sub(T::IgnoredIssuance::get()); - let holdings = T::Currency::free_balance(our_account); + let holdings = + T::Currency::free_balance(our_account).saturating_add(summary.receipts_on_hold); let other = total_issuance.saturating_sub(holdings); let effective = summary.proportion_owed.left_from_one().saturating_reciprocal_mul(other); @@ -893,7 +1112,7 @@ pub mod pallet { pub(crate) fn process_bid( mut bid: BidOf, expiry: T::BlockNumber, - our_account: &T::AccountId, + _our_account: &T::AccountId, issuance: &IssuanceInfo>, remaining: &mut BalanceOf, queue_amount: &mut BalanceOf, @@ -906,10 +1125,8 @@ pub mod pallet { } else { None }; - let amount = bid.amount.saturating_sub(T::Currency::unreserve(&bid.who, bid.amount)); - if T::Currency::transfer(&bid.who, &our_account, amount, AllowDeath).is_err() { - return result - } + let amount = bid.amount; + summary.receipts_on_hold.saturating_accrue(amount); // Can never overflow due to block above. remaining.saturating_reduce(amount); @@ -928,12 +1145,9 @@ pub mod pallet { let e = Event::Issued { index, expiry, who: who.clone(), amount, proportion }; Self::deposit_event(e); - let receipt = ReceiptRecord { proportion, who: who.clone(), expiry }; + let receipt = ReceiptRecord { proportion, owner: Some((who, amount)), expiry }; Receipts::::insert(index, receipt); - // issue the fungible counterpart - let fung_eq = T::CounterpartAmount::convert(proportion); - let _ = T::Counterpart::mint_into(&who, fung_eq).defensive(); result } } diff --git a/frame/nis/src/mock.rs b/frame/nis/src/mock.rs index ebe073d683..585ed2d8b2 100644 --- a/frame/nis/src/mock.rs +++ b/frame/nis/src/mock.rs @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type WeightInfo = (); type MaxLocks = (); - type MaxReserves = (); + type MaxReserves = ConstU32<1>; type ReserveIdentifier = [u8; 8]; } @@ -112,6 +112,7 @@ parameter_types! { pub const MinReceipt: Perquintill = Perquintill::from_percent(1); pub const ThawThrottle: (Perquintill, u64) = (Perquintill::from_percent(25), 5); pub static MaxIntakeWeight: Weight = Weight::from_ref_time(2_000_000_000_000); + pub const ReserveId: [u8; 8] = *b"py/nis "; } ord_parameter_types! { @@ -139,6 +140,7 @@ impl pallet_nis::Config for Test { type MaxIntakeWeight = MaxIntakeWeight; type MinReceipt = MinReceipt; type ThawThrottle = ThawThrottle; + type ReserveId = ReserveId; } // This function basically just builds a genesis storage key/value store according to diff --git a/frame/nis/src/tests.rs b/frame/nis/src/tests.rs index f0c45cc80b..b5feb4df16 100644 --- a/frame/nis/src/tests.rs +++ b/frame/nis/src/tests.rs @@ -34,8 +34,16 @@ fn pot() -> u64 { Balances::free_balance(&Nis::account_id()) } +fn holdings() -> u64 { + Nis::issuance().holdings +} + +fn signed(who: u64) -> RuntimeOrigin { + RuntimeOrigin::signed(who) +} + fn enlarge(amount: u64, max_bids: u32) { - let summary: SummaryRecord = Summary::::get(); + let summary: SummaryRecord = Summary::::get(); let increase_in_proportion_owed = Perquintill::from_rational(amount, Nis::issuance().effective); let target = summary.proportion_owed.saturating_add(increase_in_proportion_owed); Nis::process_queues(target, u32::max_value(), max_bids, &mut WeightCounter::unlimited()); @@ -55,7 +63,8 @@ fn basic_setup_works() { proportion_owed: Perquintill::zero(), index: 0, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 0, } ); }); @@ -65,16 +74,13 @@ fn basic_setup_works() { fn place_bid_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_noop!(Nis::place_bid(RuntimeOrigin::signed(1), 1, 2), Error::::AmountTooSmall); + assert_noop!(Nis::place_bid(signed(1), 1, 2), Error::::AmountTooSmall); assert_noop!( - Nis::place_bid(RuntimeOrigin::signed(1), 101, 2), + Nis::place_bid(signed(1), 101, 2), BalancesError::::InsufficientBalance ); - assert_noop!( - Nis::place_bid(RuntimeOrigin::signed(1), 10, 4), - Error::::DurationTooBig - ); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); + assert_noop!(Nis::place_bid(signed(1), 10, 4), Error::::DurationTooBig); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); assert_eq!(Balances::reserved_balance(1), 10); assert_eq!(Queues::::get(2), vec![Bid { amount: 10, who: 1 }]); assert_eq!(QueueTotals::::get(), vec![(0, 0), (1, 10), (0, 0)]); @@ -85,16 +91,16 @@ fn place_bid_works() { fn place_bid_queuing_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 20, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 5, 2)); - assert_noop!(Nis::place_bid(RuntimeOrigin::signed(1), 5, 2), Error::::BidTooLow); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 15, 2)); + assert_ok!(Nis::place_bid(signed(1), 20, 2)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::place_bid(signed(1), 5, 2)); + assert_noop!(Nis::place_bid(signed(1), 5, 2), Error::::BidTooLow); + assert_ok!(Nis::place_bid(signed(1), 15, 2)); assert_eq!(Balances::reserved_balance(1), 45); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 25, 2)); + assert_ok!(Nis::place_bid(signed(1), 25, 2)); assert_eq!(Balances::reserved_balance(1), 60); - assert_noop!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2), Error::::BidTooLow); + assert_noop!(Nis::place_bid(signed(1), 10, 2), Error::::BidTooLow); assert_eq!( Queues::::get(2), vec![ @@ -111,11 +117,11 @@ fn place_bid_queuing_works() { fn place_bid_fails_when_queue_full() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(3), 10, 2)); - assert_noop!(Nis::place_bid(RuntimeOrigin::signed(4), 10, 2), Error::::BidTooLow); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(4), 10, 3)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::place_bid(signed(2), 10, 2)); + assert_ok!(Nis::place_bid(signed(3), 10, 2)); + assert_noop!(Nis::place_bid(signed(4), 10, 2), Error::::BidTooLow); + assert_ok!(Nis::place_bid(signed(4), 10, 3)); }); } @@ -123,11 +129,11 @@ fn place_bid_fails_when_queue_full() { fn multiple_place_bids_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 3)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 10, 2)); + assert_ok!(Nis::place_bid(signed(1), 10, 1)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::place_bid(signed(1), 10, 3)); + assert_ok!(Nis::place_bid(signed(2), 10, 2)); assert_eq!(Balances::reserved_balance(1), 40); assert_eq!(Balances::reserved_balance(2), 10); @@ -149,9 +155,9 @@ fn multiple_place_bids_works() { fn retract_single_item_queue_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::retract_bid(RuntimeOrigin::signed(1), 10, 1)); + assert_ok!(Nis::place_bid(signed(1), 10, 1)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::retract_bid(signed(1), 10, 1)); assert_eq!(Balances::reserved_balance(1), 10); assert_eq!(Queues::::get(1), vec![]); @@ -164,12 +170,12 @@ fn retract_single_item_queue_works() { fn retract_with_other_and_duplicate_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 10, 2)); + assert_ok!(Nis::place_bid(signed(1), 10, 1)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::place_bid(signed(1), 10, 2)); + assert_ok!(Nis::place_bid(signed(2), 10, 2)); - assert_ok!(Nis::retract_bid(RuntimeOrigin::signed(1), 10, 2)); + assert_ok!(Nis::retract_bid(signed(1), 10, 2)); assert_eq!(Balances::reserved_balance(1), 20); assert_eq!(Balances::reserved_balance(2), 10); assert_eq!(Queues::::get(1), vec![Bid { amount: 10, who: 1 },]); @@ -185,11 +191,11 @@ fn retract_with_other_and_duplicate_works() { fn retract_non_existent_item_fails() { new_test_ext().execute_with(|| { run_to_block(1); - assert_noop!(Nis::retract_bid(RuntimeOrigin::signed(1), 10, 1), Error::::NotFound); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 10, 1)); - assert_noop!(Nis::retract_bid(RuntimeOrigin::signed(1), 20, 1), Error::::NotFound); - assert_noop!(Nis::retract_bid(RuntimeOrigin::signed(1), 10, 2), Error::::NotFound); - assert_noop!(Nis::retract_bid(RuntimeOrigin::signed(2), 10, 1), Error::::NotFound); + assert_noop!(Nis::retract_bid(signed(1), 10, 1), Error::::UnknownBid); + assert_ok!(Nis::place_bid(signed(1), 10, 1)); + assert_noop!(Nis::retract_bid(signed(1), 20, 1), Error::::UnknownBid); + assert_noop!(Nis::retract_bid(signed(1), 10, 2), Error::::UnknownBid); + assert_noop!(Nis::retract_bid(signed(2), 10, 1), Error::::UnknownBid); }); } @@ -197,14 +203,14 @@ fn retract_non_existent_item_fails() { fn basic_enlarge_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 40, 2)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(2), 40, 2)); enlarge(40, 2); // Takes 2/2, then stopped because it reaches its max amount assert_eq!(Balances::reserved_balance(1), 40); - assert_eq!(Balances::reserved_balance(2), 0); - assert_eq!(pot(), 40); + assert_eq!(Balances::reserved_balance(2), 40); + assert_eq!(holdings(), 40); assert_eq!(Queues::::get(1), vec![Bid { amount: 40, who: 1 }]); assert_eq!(Queues::::get(2), vec![]); @@ -216,12 +222,17 @@ fn basic_enlarge_works() { proportion_owed: Perquintill::from_percent(10), index: 1, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 40, } ); assert_eq!( Receipts::::get(0).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 2, expiry: 7 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((2, 40)), + expiry: 7 + } ); }); } @@ -230,10 +241,10 @@ fn basic_enlarge_works() { fn enlarge_respects_bids_limit() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 40, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(3), 40, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(4), 40, 3)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(2), 40, 2)); + assert_ok!(Nis::place_bid(signed(3), 40, 2)); + assert_ok!(Nis::place_bid(signed(4), 40, 3)); enlarge(100, 2); // Should have taken 4/3 and 2/2, then stopped because it's only allowed 2. @@ -244,11 +255,19 @@ fn enlarge_respects_bids_limit() { assert_eq!( Receipts::::get(0).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 4, expiry: 10 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((4, 40)), + expiry: 10 + } ); assert_eq!( Receipts::::get(1).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 2, expiry: 7 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((2, 40)), + expiry: 7 + } ); assert_eq!( Summary::::get(), @@ -256,7 +275,8 @@ fn enlarge_respects_bids_limit() { proportion_owed: Perquintill::from_percent(20), index: 2, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 80, } ); }); @@ -266,7 +286,7 @@ fn enlarge_respects_bids_limit() { fn enlarge_respects_amount_limit_and_will_split() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 80, 1)); + assert_ok!(Nis::place_bid(signed(1), 80, 1)); enlarge(40, 2); // Takes 2/2, then stopped because it reaches its max amount @@ -275,7 +295,11 @@ fn enlarge_respects_amount_limit_and_will_split() { assert_eq!( Receipts::::get(0).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 1, expiry: 4 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((1, 40)), + expiry: 4 + } ); assert_eq!( Summary::::get(), @@ -283,7 +307,8 @@ fn enlarge_respects_amount_limit_and_will_split() { proportion_owed: Perquintill::from_percent(10), index: 1, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 40, } ); }); @@ -293,25 +318,25 @@ fn enlarge_respects_amount_limit_and_will_split() { fn basic_thaw_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); assert_eq!(Nis::issuance().effective, 400); assert_eq!(Balances::free_balance(1), 60); assert_eq!(Balances::reserved_balance(1), 40); - assert_eq!(pot(), 0); + assert_eq!(holdings(), 0); enlarge(40, 1); assert_eq!(Nis::issuance().effective, 400); assert_eq!(Balances::free_balance(1), 60); - assert_eq!(Balances::reserved_balance(1), 0); - assert_eq!(pot(), 40); + assert_eq!(Balances::reserved_balance(1), 40); + assert_eq!(holdings(), 40); run_to_block(3); - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 0, None), Error::::NotExpired); + assert_noop!(Nis::thaw_private(signed(1), 0, None), Error::::NotExpired); run_to_block(4); - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 1, None), Error::::Unknown); - assert_noop!(Nis::thaw(RuntimeOrigin::signed(2), 0, None), Error::::NotOwner); + assert_noop!(Nis::thaw_private(signed(1), 1, None), Error::::UnknownReceipt); + assert_noop!(Nis::thaw_private(signed(2), 0, None), Error::::NotOwner); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); + assert_ok!(Nis::thaw_private(signed(1), 0, None)); assert_eq!(NisBalances::free_balance(1), 0); assert_eq!(Nis::typed_attribute::<_, Perquintill>(&0, b"proportion"), None); assert_eq!(Nis::issuance().effective, 400); @@ -323,7 +348,8 @@ fn basic_thaw_works() { proportion_owed: Perquintill::zero(), index: 1, last_period: 0, - thawed: Perquintill::from_percent(10) + thawed: Perquintill::from_percent(10), + receipts_on_hold: 0, } ); assert_eq!(Receipts::::get(0), None); @@ -334,18 +360,16 @@ fn basic_thaw_works() { fn partial_thaw_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 80, 1)); + assert_ok!(Nis::place_bid(signed(1), 80, 1)); enlarge(80, 1); - assert_eq!(pot(), 80); + assert_eq!(holdings(), 80); run_to_block(4); - assert_noop!( - Nis::thaw(RuntimeOrigin::signed(1), 0, Some(4_100_000)), - Error::::MakesDust - ); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, Some(1_050_000))); + let prop = Perquintill::from_rational(4_100_000, 21_000_000u64); + assert_noop!(Nis::thaw_private(signed(1), 0, Some(prop)), Error::::MakesDust); + let prop = Perquintill::from_rational(1_050_000, 21_000_000u64); + assert_ok!(Nis::thaw_private(signed(1), 0, Some(prop))); - assert_eq!(NisBalances::free_balance(1), 3_150_000); assert_eq!( Nis::typed_attribute::<_, Perquintill>(&0, b"proportion"), Some(Perquintill::from_rational(3_150_000u64, 21_000_000u64)), @@ -353,9 +377,9 @@ fn partial_thaw_works() { assert_eq!(Nis::issuance().effective, 400); assert_eq!(Balances::free_balance(1), 40); - assert_eq!(pot(), 60); + assert_eq!(holdings(), 60); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); + assert_ok!(Nis::thaw_private(signed(1), 0, None)); assert_eq!(Nis::issuance().effective, 400); assert_eq!(Balances::free_balance(1), 100); @@ -367,7 +391,8 @@ fn partial_thaw_works() { proportion_owed: Perquintill::zero(), index: 1, last_period: 0, - thawed: Perquintill::from_percent(20) + thawed: Perquintill::from_percent(20), + receipts_on_hold: 0, } ); assert_eq!(Receipts::::get(0), None); @@ -378,35 +403,144 @@ fn partial_thaw_works() { fn thaw_respects_transfers() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); enlarge(40, 1); run_to_block(4); assert_eq!(Nis::owner(&0), Some(1)); + assert_eq!(Balances::reserved_balance(&1), 40); + assert_eq!(Balances::reserved_balance(&2), 0); assert_ok!(Nis::transfer(&0, &2)); + assert_eq!(Balances::reserved_balance(&1), 0); + assert_eq!(Balances::reserved_balance(&2), 40); // Transfering the receipt... - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 0, None), Error::::NotOwner); - // ...can't be thawed due to missing counterpart - assert_noop!(Nis::thaw(RuntimeOrigin::signed(2), 0, None), TokenError::NoFunds); + assert_noop!(Nis::thaw_private(signed(1), 0, None), Error::::NotOwner); - // Transfer the counterpart also... - assert_ok!(NisBalances::transfer(RuntimeOrigin::signed(1), 2, 2100000)); // ...and thawing is possible. - assert_ok!(Nis::thaw(RuntimeOrigin::signed(2), 0, None)); + assert_ok!(Nis::thaw_private(signed(2), 0, None)); - assert_eq!(Balances::free_balance(2), 140); - assert_eq!(Balances::free_balance(1), 60); + assert_eq!(Balances::total_balance(&2), 140); + assert_eq!(Balances::total_balance(&1), 60); + }); +} + +#[test] +fn communify_works() { + new_test_ext().execute_with(|| { + run_to_block(1); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + enlarge(40, 1); + run_to_block(4); + + assert_eq!(Nis::owner(&0), Some(1)); + assert_eq!(Balances::reserved_balance(&1), 40); + assert_eq!(pot(), 0); + assert_eq!(NisBalances::free_balance(&1), 0); + assert_ok!(Nis::communify(signed(1), 0)); + assert_eq!(Nis::owner(&0), None); + assert_eq!(Balances::reserved_balance(&1), 0); + assert_eq!(pot(), 40); + // We now have fungibles. + assert_eq!(NisBalances::free_balance(&1), 2_100_000); + + // Can't transfer the NFT or thaw it as a private. + assert_noop!(Nis::thaw_private(signed(1), 0, None), Error::::AlreadyCommunal); + assert_noop!(Nis::transfer(&0, &2), Error::::AlreadyCommunal); + // Communal thawing would be possible, except it's the wrong receipt. + assert_noop!(Nis::thaw_communal(signed(1), 1), Error::::UnknownReceipt); + + // Transfer some of the fungibles away. + assert_ok!(NisBalances::transfer(signed(1), 2, 100_000)); + assert_eq!(NisBalances::free_balance(&1), 2_000_000); + assert_eq!(NisBalances::free_balance(&2), 100_000); + + // Communal thawing with the correct index is not possible now. + assert_noop!(Nis::thaw_communal(signed(1), 0), TokenError::NoFunds); + assert_noop!(Nis::thaw_communal(signed(2), 0), TokenError::NoFunds); + + // Transfer the rest to 2... + assert_ok!(NisBalances::transfer(signed(1), 2, 2_000_000)); + assert_eq!(NisBalances::free_balance(&1), 0); + assert_eq!(NisBalances::free_balance(&2), 2_100_000); + + // ...and thawing becomes possible. + assert_ok!(Nis::thaw_communal(signed(2), 0)); + assert_eq!(NisBalances::free_balance(&1), 0); + assert_eq!(NisBalances::free_balance(&2), 0); + assert_eq!(pot(), 0); + assert_eq!(Balances::total_balance(&1), 60); + assert_eq!(Balances::total_balance(&2), 140); + + assert_noop!(Nis::thaw_communal(signed(2), 0), Error::::UnknownReceipt); + }); +} + +#[test] +fn privatize_works() { + new_test_ext().execute_with(|| { + run_to_block(1); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + enlarge(40, 1); + run_to_block(4); + assert_noop!(Nis::privatize(signed(2), 0), Error::::AlreadyPrivate); + assert_ok!(Nis::communify(signed(1), 0)); + + // Transfer the fungibles to #2 + assert_ok!(NisBalances::transfer(signed(1), 2, 2_100_000)); + assert_noop!(Nis::privatize(signed(1), 0), TokenError::NoFunds); + + // Privatize + assert_ok!(Nis::privatize(signed(2), 0)); + assert_noop!(Nis::privatize(signed(2), 0), Error::::AlreadyPrivate); + assert_eq!(NisBalances::free_balance(&2), 0); + assert_eq!(Nis::owner(&0), Some(2)); + assert_eq!(Balances::reserved_balance(&2), 40); + assert_eq!(pot(), 0); }); } #[test] -fn thaw_when_issuance_higher_works() { +fn privatize_and_thaw_with_another_receipt_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 100, 1)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(2), 40, 1)); + enlarge(80, 2); + run_to_block(4); + + assert_ok!(Nis::communify(signed(1), 0)); + assert_ok!(Nis::communify(signed(2), 1)); + + // Transfer half of fungibles to #3 from each of #1 and #2, and the other half from #2 to #4 + assert_ok!(NisBalances::transfer(signed(1), 3, 1_050_000)); + assert_ok!(NisBalances::transfer(signed(2), 3, 1_050_000)); + assert_ok!(NisBalances::transfer(signed(2), 4, 1_050_000)); + + // #3 privatizes, partially thaws, then re-communifies with #0, then transfers the fungibles + // to #2 + assert_ok!(Nis::privatize(signed(3), 0)); + assert_ok!(Nis::thaw_private(signed(3), 0, Some(Perquintill::from_percent(5)))); + assert_ok!(Nis::communify(signed(3), 0)); + assert_ok!(NisBalances::transfer(signed(3), 1, 1_050_000)); + + // #1 now has enough to thaw using receipt 1 + assert_ok!(Nis::thaw_communal(signed(1), 1)); + + // #4 now has enough to thaw using receipt 0 + assert_ok!(Nis::thaw_communal(signed(4), 0)); + }); +} + +#[test] +fn communal_thaw_when_issuance_higher_works() { + new_test_ext().execute_with(|| { + run_to_block(1); + assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); + assert_ok!(Nis::communify(signed(1), 0)); + assert_eq!(NisBalances::free_balance(1), 5_250_000); // (25% of 21m) // Everybody else's balances goes up by 50% @@ -417,19 +551,45 @@ fn thaw_when_issuance_higher_works() { run_to_block(4); // Unfunded initially... - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 0, None), Error::::Unfunded); + assert_noop!(Nis::thaw_communal(signed(1), 0), Error::::Unfunded); // ...so we fund. - assert_ok!(Nis::fund_deficit(RuntimeOrigin::signed(1))); + assert_ok!(Nis::fund_deficit(signed(1))); - // Transfer counterpart away... - assert_ok!(NisBalances::transfer(RuntimeOrigin::signed(1), 2, 250_000)); + // Transfer counterparts away... + assert_ok!(NisBalances::transfer(signed(1), 2, 250_000)); // ...and it's not thawable. - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 0, None), TokenError::NoFunds); + assert_noop!(Nis::thaw_communal(signed(1), 0), TokenError::NoFunds); - // Transfer counterpart back... - assert_ok!(NisBalances::transfer(RuntimeOrigin::signed(2), 1, 250_000)); + // Transfer counterparts back... + assert_ok!(NisBalances::transfer(signed(2), 1, 250_000)); // ...and it is. - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); + assert_ok!(Nis::thaw_communal(signed(1), 0)); + + assert_eq!(Balances::free_balance(1), 150); + assert_eq!(Balances::reserved_balance(1), 0); + }); +} + +#[test] +fn private_thaw_when_issuance_higher_works() { + new_test_ext().execute_with(|| { + run_to_block(1); + assert_ok!(Nis::place_bid(signed(1), 100, 1)); + enlarge(100, 1); + + // Everybody else's balances goes up by 50% + Balances::make_free_balance_be(&2, 150); + Balances::make_free_balance_be(&3, 150); + Balances::make_free_balance_be(&4, 150); + + run_to_block(4); + + // Unfunded initially... + assert_noop!(Nis::thaw_private(signed(1), 0, None), Error::::Unfunded); + // ...so we fund. + assert_ok!(Nis::fund_deficit(signed(1))); + + assert_ok!(Nis::thaw_private(signed(1), 0, None)); assert_eq!(Balances::free_balance(1), 150); assert_eq!(Balances::reserved_balance(1), 0); @@ -443,21 +603,21 @@ fn thaw_with_ignored_issuance_works() { // Give account zero some balance. Balances::make_free_balance_be(&0, 200); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 100, 1)); + assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); // Account zero transfers 50 into everyone else's accounts. - assert_ok!(Balances::transfer(RuntimeOrigin::signed(0), 2, 50)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(0), 3, 50)); - assert_ok!(Balances::transfer(RuntimeOrigin::signed(0), 4, 50)); + assert_ok!(Balances::transfer(signed(0), 2, 50)); + assert_ok!(Balances::transfer(signed(0), 3, 50)); + assert_ok!(Balances::transfer(signed(0), 4, 50)); run_to_block(4); // Unfunded initially... - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 0, None), Error::::Unfunded); + assert_noop!(Nis::thaw_private(signed(1), 0, None), Error::::Unfunded); // ...so we fund... - assert_ok!(Nis::fund_deficit(RuntimeOrigin::signed(1))); + assert_ok!(Nis::fund_deficit(signed(1))); // ...and then it's ok. - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); + assert_ok!(Nis::thaw_private(signed(1), 0, None)); // Account zero changes have been ignored. assert_eq!(Balances::free_balance(1), 150); @@ -469,7 +629,7 @@ fn thaw_with_ignored_issuance_works() { fn thaw_when_issuance_lower_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 100, 1)); + assert_ok!(Nis::place_bid(signed(1), 100, 1)); enlarge(100, 1); // Everybody else's balances goes down by 25% @@ -478,7 +638,7 @@ fn thaw_when_issuance_lower_works() { Balances::make_free_balance_be(&4, 75); run_to_block(4); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); + assert_ok!(Nis::thaw_private(signed(1), 0, None)); assert_eq!(Balances::free_balance(1), 75); assert_eq!(Balances::reserved_balance(1), 0); @@ -489,23 +649,23 @@ fn thaw_when_issuance_lower_works() { fn multiple_thaws_works() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 60, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 50, 1)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(1), 60, 1)); + assert_ok!(Nis::place_bid(signed(2), 50, 1)); enlarge(200, 3); // Double everyone's free balances. Balances::make_free_balance_be(&2, 100); Balances::make_free_balance_be(&3, 200); Balances::make_free_balance_be(&4, 200); - assert_ok!(Nis::fund_deficit(RuntimeOrigin::signed(1))); + assert_ok!(Nis::fund_deficit(signed(1))); run_to_block(4); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 1, None)); - assert_noop!(Nis::thaw(RuntimeOrigin::signed(2), 2, None), Error::::Throttled); + assert_ok!(Nis::thaw_private(signed(1), 0, None)); + assert_ok!(Nis::thaw_private(signed(1), 1, None)); + assert_noop!(Nis::thaw_private(signed(2), 2, None), Error::::Throttled); run_to_block(5); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(2), 2, None)); + assert_ok!(Nis::thaw_private(signed(2), 2, None)); assert_eq!(Balances::free_balance(1), 200); assert_eq!(Balances::free_balance(2), 200); @@ -516,24 +676,24 @@ fn multiple_thaws_works() { fn multiple_thaws_works_in_alternative_thaw_order() { new_test_ext().execute_with(|| { run_to_block(1); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 60, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 50, 1)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(1), 60, 1)); + assert_ok!(Nis::place_bid(signed(2), 50, 1)); enlarge(200, 3); // Double everyone's free balances. Balances::make_free_balance_be(&2, 100); Balances::make_free_balance_be(&3, 200); Balances::make_free_balance_be(&4, 200); - assert_ok!(Nis::fund_deficit(RuntimeOrigin::signed(1))); + assert_ok!(Nis::fund_deficit(signed(1))); run_to_block(4); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(2), 2, None)); - assert_noop!(Nis::thaw(RuntimeOrigin::signed(1), 1, None), Error::::Throttled); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 0, None)); + assert_ok!(Nis::thaw_private(signed(2), 2, None)); + assert_noop!(Nis::thaw_private(signed(1), 1, None), Error::::Throttled); + assert_ok!(Nis::thaw_private(signed(1), 0, None)); run_to_block(5); - assert_ok!(Nis::thaw(RuntimeOrigin::signed(1), 1, None)); + assert_ok!(Nis::thaw_private(signed(1), 1, None)); assert_eq!(Balances::free_balance(1), 200); assert_eq!(Balances::free_balance(2), 200); @@ -548,11 +708,11 @@ fn enlargement_to_target_works() { <() as WeightInfo>::process_queue() + (<() as WeightInfo>::process_bid() * 2); super::mock::MaxIntakeWeight::set(w); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 1)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(1), 40, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 40, 2)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(2), 40, 3)); - assert_ok!(Nis::place_bid(RuntimeOrigin::signed(3), 40, 3)); + assert_ok!(Nis::place_bid(signed(1), 40, 1)); + assert_ok!(Nis::place_bid(signed(1), 40, 2)); + assert_ok!(Nis::place_bid(signed(2), 40, 2)); + assert_ok!(Nis::place_bid(signed(2), 40, 3)); + assert_ok!(Nis::place_bid(signed(3), 40, 3)); Target::set(Perquintill::from_percent(40)); run_to_block(3); @@ -571,11 +731,19 @@ fn enlargement_to_target_works() { // Two new items should have been issued to 2 & 3 for 40 each & duration of 3. assert_eq!( Receipts::::get(0).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 2, expiry: 13 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((2, 40)), + expiry: 13 + } ); assert_eq!( Receipts::::get(1).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 3, expiry: 13 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((3, 40)), + expiry: 13 + } ); assert_eq!( Summary::::get(), @@ -584,6 +752,7 @@ fn enlargement_to_target_works() { index: 2, last_period: 0, thawed: Perquintill::zero(), + receipts_on_hold: 80, } ); @@ -595,7 +764,8 @@ fn enlargement_to_target_works() { proportion_owed: Perquintill::from_percent(20), index: 2, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 80, } ); @@ -603,11 +773,19 @@ fn enlargement_to_target_works() { // Two new items should have been issued to 1 & 2 for 40 each & duration of 2. assert_eq!( Receipts::::get(2).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 1, expiry: 12 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((1, 40)), + expiry: 12 + } ); assert_eq!( Receipts::::get(3).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 2, expiry: 12 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((2, 40)), + expiry: 12 + } ); assert_eq!( Summary::::get(), @@ -615,7 +793,8 @@ fn enlargement_to_target_works() { proportion_owed: Perquintill::from_percent(40), index: 4, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 160, } ); @@ -627,7 +806,8 @@ fn enlargement_to_target_works() { proportion_owed: Perquintill::from_percent(40), index: 4, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 160, } ); @@ -635,10 +815,14 @@ fn enlargement_to_target_works() { Target::set(Perquintill::from_percent(60)); run_to_block(10); - // Two new items should have been issued to 1 & 2 for 40 each & duration of 2. + // One new item should have been issued to 1 for 40 each & duration of 2. assert_eq!( Receipts::::get(4).unwrap(), - ReceiptRecord { proportion: Perquintill::from_percent(10), who: 1, expiry: 13 } + ReceiptRecord { + proportion: Perquintill::from_percent(10), + owner: Some((1, 40)), + expiry: 13 + } ); assert_eq!( @@ -647,7 +831,8 @@ fn enlargement_to_target_works() { proportion_owed: Perquintill::from_percent(50), index: 5, last_period: 0, - thawed: Perquintill::zero() + thawed: Perquintill::zero(), + receipts_on_hold: 200, } ); }); diff --git a/frame/nis/src/weights.rs b/frame/nis/src/weights.rs index 71577075ad..769ff79551 100644 --- a/frame/nis/src/weights.rs +++ b/frame/nis/src/weights.rs @@ -1,40 +1,31 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. //! Autogenerated weights for pallet_nis //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2022-12-15, STEPS: `5`, REPEAT: 2, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `Workhorse.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// ../../../target/release/substrate // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_nis -// --extrinsic=* +// --chain +// dev +// --steps +// 5 +// --repeat +// 2 +// --pallet +// pallet_nis +// --extrinsic +// * // --execution=wasm // --wasm-execution=compiled -// --template=./.maintain/frame-weight-template.hbs -// --output=./frame/nis/src/weights.rs +// --output +// ../../../frame/nis/src/weights.rs +// --template +// ../../../.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,8 +39,11 @@ pub trait WeightInfo { fn place_bid(l: u32, ) -> Weight; fn place_bid_max() -> Weight; fn retract_bid(l: u32, ) -> Weight; - fn thaw() -> Weight; fn fund_deficit() -> Weight; + fn thaw_private() -> Weight; + fn thaw_communal() -> Weight; + fn privatize() -> Weight; + fn communify() -> Weight; fn process_queues() -> Weight; fn process_queue() -> Weight; fn process_bid() -> Weight; @@ -59,143 +53,223 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Nis Queues (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) // Storage: Nis QueueTotals (r:1 w:1) + /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { - // Minimum execution time: 42_332 nanoseconds. - Weight::from_ref_time(45_584_514 as u64) - // Standard Error: 129 - .saturating_add(Weight::from_ref_time(45_727 as u64).saturating_mul(l as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 47_000 nanoseconds. + Weight::from_ref_time(53_822_030) + // Standard Error: 4_869 + .saturating_add(Weight::from_ref_time(47_431).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Nis Queues (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) // Storage: Nis QueueTotals (r:1 w:1) fn place_bid_max() -> Weight { - // Minimum execution time: 85_866 nanoseconds. - Weight::from_ref_time(87_171_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 109_000 nanoseconds. + Weight::from_ref_time(109_000_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Nis Queues (r:1 w:1) // Storage: Nis QueueTotals (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) + /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { - // Minimum execution time: 44_605 nanoseconds. - Weight::from_ref_time(46_850_108 as u64) - // Standard Error: 135 - .saturating_add(Weight::from_ref_time(34_178 as u64).saturating_mul(l as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Nis Active (r:1 w:1) - // Storage: Nis ActiveTotal (r:1 w:1) - fn thaw() -> Weight { - // Minimum execution time: 55_143 nanoseconds. - Weight::from_ref_time(55_845_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Nis Active (r:1 w:1) - // Storage: Nis ActiveTotal (r:1 w:1) + // Minimum execution time: 50_000 nanoseconds. + Weight::from_ref_time(54_479_879) + // Standard Error: 4_891 + .saturating_add(Weight::from_ref_time(38_224).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Nis Summary (r:1 w:0) + // Storage: System Account (r:1 w:1) fn fund_deficit() -> Weight { - Weight::from_ref_time(47_753_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 57_000 nanoseconds. + Weight::from_ref_time(62_000_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Nis ActiveTotal (r:1 w:0) - fn process_queues() -> Weight { - Weight::from_ref_time(1_663_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) + // Storage: Nis Receipts (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: System Account (r:1 w:0) + // Storage: Balances Reserves (r:1 w:1) + fn thaw_private() -> Weight { + // Minimum execution time: 84_000 nanoseconds. + Weight::from_ref_time(85_000_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + // Storage: Nis Receipts (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: Assets Asset (r:1 w:1) + // Storage: Assets Account (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn thaw_communal() -> Weight { + // Minimum execution time: 108_000 nanoseconds. + Weight::from_ref_time(115_000_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } - // Storage: Nis ActiveTotal (r:1 w:1) + // Storage: Nis Receipts (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Assets Asset (r:1 w:1) + // Storage: Assets Account (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) + fn privatize() -> Weight { + // Minimum execution time: 107_000 nanoseconds. + Weight::from_ref_time(110_000_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) + } + // Storage: Nis Receipts (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: Assets Asset (r:1 w:1) + // Storage: Assets Account (r:1 w:1) + fn communify() -> Weight { + // Minimum execution time: 89_000 nanoseconds. + Weight::from_ref_time(89_000_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) + } + // Storage: Nis Summary (r:1 w:1) + // Storage: System Account (r:1 w:0) // Storage: Nis QueueTotals (r:1 w:1) + fn process_queues() -> Weight { + // Minimum execution time: 34_000 nanoseconds. + Weight::from_ref_time(38_000_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } // Storage: Nis Queues (r:1 w:1) - // Storage: Nis Active (r:0 w:1) fn process_queue() -> Weight { - Weight::from_ref_time(40_797_000 as u64) - // Standard Error: 1_000 - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 6_000 nanoseconds. + Weight::from_ref_time(7_000_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Nis ActiveTotal (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) - // Storage: Nis Queues (r:1 w:1) - // Storage: Nis Active (r:0 w:1) + // Storage: Nis Receipts (r:0 w:1) fn process_bid() -> Weight { - Weight::from_ref_time(14_944_000 as u64) - // Standard Error: 6_000 - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 14_000 nanoseconds. + Weight::from_ref_time(15_000_000) + .saturating_add(T::DbWeight::get().writes(1)) } } // For backwards compatibility and tests impl WeightInfo for () { // Storage: Nis Queues (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) // Storage: Nis QueueTotals (r:1 w:1) + /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { - // Minimum execution time: 42_332 nanoseconds. - Weight::from_ref_time(45_584_514 as u64) - // Standard Error: 129 - .saturating_add(Weight::from_ref_time(45_727 as u64).saturating_mul(l as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 47_000 nanoseconds. + Weight::from_ref_time(53_822_030) + // Standard Error: 4_869 + .saturating_add(Weight::from_ref_time(47_431).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: Nis Queues (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) // Storage: Nis QueueTotals (r:1 w:1) fn place_bid_max() -> Weight { - // Minimum execution time: 85_866 nanoseconds. - Weight::from_ref_time(87_171_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 109_000 nanoseconds. + Weight::from_ref_time(109_000_000) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: Nis Queues (r:1 w:1) // Storage: Nis QueueTotals (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) + /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { - // Minimum execution time: 44_605 nanoseconds. - Weight::from_ref_time(46_850_108 as u64) - // Standard Error: 135 - .saturating_add(Weight::from_ref_time(34_178 as u64).saturating_mul(l as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Nis Active (r:1 w:1) - // Storage: Nis ActiveTotal (r:1 w:1) - fn thaw() -> Weight { - // Minimum execution time: 55_143 nanoseconds. - Weight::from_ref_time(55_845_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Nis Active (r:1 w:1) - // Storage: Nis ActiveTotal (r:1 w:1) + // Minimum execution time: 50_000 nanoseconds. + Weight::from_ref_time(54_479_879) + // Standard Error: 4_891 + .saturating_add(Weight::from_ref_time(38_224).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + // Storage: Nis Summary (r:1 w:0) + // Storage: System Account (r:1 w:1) fn fund_deficit() -> Weight { - Weight::from_ref_time(47_753_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 57_000 nanoseconds. + Weight::from_ref_time(62_000_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) } - // Storage: Nis ActiveTotal (r:1 w:0) - fn process_queues() -> Weight { - Weight::from_ref_time(1_663_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) + // Storage: Nis Receipts (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: System Account (r:1 w:0) + // Storage: Balances Reserves (r:1 w:1) + fn thaw_private() -> Weight { + // Minimum execution time: 84_000 nanoseconds. + Weight::from_ref_time(85_000_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + // Storage: Nis Receipts (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: Assets Asset (r:1 w:1) + // Storage: Assets Account (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn thaw_communal() -> Weight { + // Minimum execution time: 108_000 nanoseconds. + Weight::from_ref_time(115_000_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + // Storage: Nis Receipts (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Assets Asset (r:1 w:1) + // Storage: Assets Account (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) + fn privatize() -> Weight { + // Minimum execution time: 107_000 nanoseconds. + Weight::from_ref_time(110_000_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(6)) } - // Storage: Nis ActiveTotal (r:1 w:1) + // Storage: Nis Receipts (r:1 w:1) + // Storage: Balances Reserves (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: Nis Summary (r:1 w:1) + // Storage: Assets Asset (r:1 w:1) + // Storage: Assets Account (r:1 w:1) + fn communify() -> Weight { + // Minimum execution time: 89_000 nanoseconds. + Weight::from_ref_time(89_000_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(6)) + } + // Storage: Nis Summary (r:1 w:1) + // Storage: System Account (r:1 w:0) // Storage: Nis QueueTotals (r:1 w:1) + fn process_queues() -> Weight { + // Minimum execution time: 34_000 nanoseconds. + Weight::from_ref_time(38_000_000) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(2)) + } // Storage: Nis Queues (r:1 w:1) - // Storage: Nis Active (r:0 w:1) fn process_queue() -> Weight { - Weight::from_ref_time(40_797_000 as u64) - // Standard Error: 1_000 - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Minimum execution time: 6_000 nanoseconds. + Weight::from_ref_time(7_000_000) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) } - // Storage: Nis ActiveTotal (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) - // Storage: Nis Queues (r:1 w:1) - // Storage: Nis Active (r:0 w:1) + // Storage: Nis Receipts (r:0 w:1) fn process_bid() -> Weight { - Weight::from_ref_time(14_944_000 as u64) - // Standard Error: 6_000 - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 14_000 nanoseconds. + Weight::from_ref_time(15_000_000) + .saturating_add(RocksDbWeight::get().writes(1)) } } diff --git a/frame/support/src/traits/tokens/fungible.rs b/frame/support/src/traits/tokens/fungible.rs index 05e109b870..a36e63e717 100644 --- a/frame/support/src/traits/tokens/fungible.rs +++ b/frame/support/src/traits/tokens/fungible.rs @@ -78,6 +78,7 @@ pub trait Mutate: Inspect { /// returned and nothing is changed. If successful, the amount of tokens reduced is returned. fn burn_from(who: &AccountId, amount: Self::Balance) -> Result; + // TODO: Remove. /// Attempt to reduce the balance of `who` by as much as possible up to `amount`, and possibly /// slightly more due to minimum_balance requirements. If no decrease is possible then an `Err` /// is returned and nothing is changed. If successful, the amount of tokens reduced is returned. @@ -143,6 +144,7 @@ pub trait InspectHold: Inspect { fn can_hold(who: &AccountId, amount: Self::Balance) -> bool; } +// TODO: Introduce `HoldReason`. /// Trait for mutating a fungible asset which can be reserved. pub trait MutateHold: InspectHold + Transfer { /// Hold some funds in an account. @@ -160,6 +162,8 @@ pub trait MutateHold: InspectHold + Transfer { best_effort: bool, ) -> Result; + // TODO: Introduce repatriate_held + /// Transfer held funds into a destination account. /// /// If `on_hold` is `true`, then the destination account must already exist and the assets @@ -195,6 +199,7 @@ pub trait BalancedHold: Balanced + MutateHold { } impl + MutateHold> BalancedHold for T { + // TODO: This should be implemented properly, and `slash` should be removed. fn slash_held( who: &AccountId, amount: Self::Balance, From 414caffad1ce634352676d1884942282a8ec6ebb Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Tue, 17 Jan 2023 16:55:11 +0100 Subject: [PATCH 19/80] Refactory of `next_slot` method (#13155) Refactory of `next_slot` method * Prevents slot worker exit if inherent data provider creation fails * Failure is not possible anymore * Fix potential failure after warp-sync where block headers of not already downloaded blocks are used by the inherent data provider --- client/consensus/slots/src/lib.rs | 8 +--- client/consensus/slots/src/slots.rs | 59 ++++++++++++++++------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 6126647e61..30d2c1761c 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -524,13 +524,7 @@ pub async fn start_slot_worker( let mut slots = Slots::new(slot_duration.as_duration(), create_inherent_data_providers, client); loop { - let slot_info = match slots.next_slot().await { - Ok(r) => r, - Err(e) => { - warn!(target: LOG_TARGET, "Error while polling for next slot: {}", e); - return - }, - }; + let slot_info = slots.next_slot().await; if sync_oracle.is_major_syncing() { debug!(target: LOG_TARGET, "Skipping proposal slot due to sync."); diff --git a/client/consensus/slots/src/slots.rs b/client/consensus/slots/src/slots.rs index 9bb5650b31..7bb263b2bd 100644 --- a/client/consensus/slots/src/slots.rs +++ b/client/consensus/slots/src/slots.rs @@ -21,7 +21,7 @@ //! This is used instead of `futures_timer::Interval` because it was unreliable. use super::{InherentDataProviderExt, Slot, LOG_TARGET}; -use sp_consensus::{Error, SelectChain}; +use sp_consensus::SelectChain; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; @@ -90,7 +90,7 @@ impl SlotInfo { pub(crate) struct Slots { last_slot: Slot, slot_duration: Duration, - inner_delay: Option, + until_next_slot: Option, create_inherent_data_providers: IDP, select_chain: SC, _phantom: std::marker::PhantomData, @@ -106,7 +106,7 @@ impl Slots { Slots { last_slot: 0.into(), slot_duration, - inner_delay: None, + until_next_slot: None, create_inherent_data_providers, select_chain, _phantom: Default::default(), @@ -122,26 +122,22 @@ where IDP::InherentDataProviders: crate::InherentDataProviderExt, { /// Returns a future that fires when the next slot starts. - pub async fn next_slot(&mut self) -> Result, Error> { + pub async fn next_slot(&mut self) -> SlotInfo { loop { - self.inner_delay = match self.inner_delay.take() { - None => { - // schedule wait. + // Wait for slot timeout + self.until_next_slot + .take() + .unwrap_or_else(|| { + // Schedule first timeout. let wait_dur = time_until_next_slot(self.slot_duration); - Some(Delay::new(wait_dur)) - }, - Some(d) => Some(d), - }; - - if let Some(inner_delay) = self.inner_delay.take() { - inner_delay.await; - } - // timeout has fired. + Delay::new(wait_dur) + }) + .await; - let ends_in = time_until_next_slot(self.slot_duration); + // Schedule delay for next slot. + let wait_dur = time_until_next_slot(self.slot_duration); + self.until_next_slot = Some(Delay::new(wait_dur)); - // reschedule delay for next slot. - self.inner_delay = Some(Delay::new(ends_in)); let chain_head = match self.select_chain.best_chain().await { Ok(x) => x, Err(e) => { @@ -150,30 +146,41 @@ where "Unable to author block in slot. No best block header: {}", e, ); - // Let's try at the next slot.. - self.inner_delay.take(); + // Let's retry at the next slot. continue }, }; - let inherent_data_providers = self + let inherent_data_providers = match self .create_inherent_data_providers .create_inherent_data_providers(chain_head.hash(), ()) - .await?; + .await + { + Ok(x) => x, + Err(e) => { + log::warn!( + target: LOG_TARGET, + "Unable to author block in slot. Failure creating inherent data provider: {}", + e, + ); + // Let's retry at the next slot. + continue + }, + }; let slot = inherent_data_providers.slot(); - // never yield the same slot twice. + // Never yield the same slot twice. if slot > self.last_slot { self.last_slot = slot; - break Ok(SlotInfo::new( + break SlotInfo::new( slot, Box::new(inherent_data_providers), self.slot_duration, chain_head, None, - )) + ) } } } From f7e53fe1a8c0e15604cc30177c312241624831bf Mon Sep 17 00:00:00 2001 From: Squirrel Date: Tue, 17 Jan 2023 16:26:10 +0000 Subject: [PATCH 20/80] Breakout mock runtimes to separate files (#13150) * break out moch runtimes to separate files * tranaction-payment: break out tests & mock runtime to separate files --- .../asset-tx-payment/src/lib.rs | 2 + .../asset-tx-payment/src/mock.rs | 213 ++++ .../asset-tx-payment/src/tests.rs | 197 +--- frame/transaction-payment/src/lib.rs | 961 +----------------- frame/transaction-payment/src/mock.rs | 162 +++ frame/transaction-payment/src/tests.rs | 836 +++++++++++++++ 6 files changed, 1223 insertions(+), 1148 deletions(-) create mode 100644 frame/transaction-payment/asset-tx-payment/src/mock.rs create mode 100644 frame/transaction-payment/src/mock.rs create mode 100644 frame/transaction-payment/src/tests.rs diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index 43cc1efa08..230b307317 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -59,6 +59,8 @@ use sp_runtime::{ FixedPointOperand, }; +#[cfg(test)] +mod mock; #[cfg(test)] mod tests; diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs new file mode 100644 index 0000000000..ddb02f5a61 --- /dev/null +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -0,0 +1,213 @@ +// Copyright (C) 2021-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate as pallet_asset_tx_payment; + +use codec; +use frame_support::{ + dispatch::DispatchClass, + pallet_prelude::*, + parameter_types, + traits::{AsEnsureOriginWithArg, ConstU32, ConstU64, ConstU8, FindAuthor}, + weights::{Weight, WeightToFee as WeightToFeeT}, + ConsensusEngineId, +}; +use frame_system as system; +use frame_system::EnsureRoot; +use pallet_transaction_payment::CurrencyAdapter; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion}, +}; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; +type Balance = u64; +type AccountId = u64; + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, + Assets: pallet_assets::{Pallet, Call, Storage, Event}, + Authorship: pallet_authorship::{Pallet, Call, Storage}, + AssetTxPayment: pallet_asset_tx_payment::{Pallet, Event}, + } +); + +parameter_types! { + pub(crate) static ExtrinsicBaseWeight: Weight = Weight::zero(); +} + +pub struct BlockWeights; +impl Get for BlockWeights { + fn get() -> frame_system::limits::BlockWeights { + frame_system::limits::BlockWeights::builder() + .base_block(Weight::zero()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get().into(); + }) + .for_class(DispatchClass::non_mandatory(), |weights| { + weights.max_total = Weight::from_ref_time(1024).set_proof_size(u64::MAX).into(); + }) + .build_or_panic() + } +} + +parameter_types! { + pub static WeightToFee: u64 = 1; + pub static TransactionByteFee: u64 = 1; +} + +impl frame_system::Config for Runtime { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = BlockWeights; + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type BlockNumber = u64; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +parameter_types! { + pub const ExistentialDeposit: u64 = 10; +} + +impl pallet_balances::Config for Runtime { + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ConstU64<10>; + type AccountStore = System; + type MaxLocks = (); + type WeightInfo = (); + type MaxReserves = ConstU32<50>; + type ReserveIdentifier = [u8; 8]; +} + +impl WeightToFeeT for WeightToFee { + type Balance = u64; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) + } +} + +impl WeightToFeeT for TransactionByteFee { + type Balance = u64; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) + } +} + +impl pallet_transaction_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = CurrencyAdapter; + type WeightToFee = WeightToFee; + type LengthToFee = TransactionByteFee; + type FeeMultiplierUpdate = (); + type OperationalFeeMultiplier = ConstU8<5>; +} + +type AssetId = u32; + +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type AssetId = AssetId; + type AssetIdParameter = codec::Compact; + type Currency = Balances; + type CreateOrigin = AsEnsureOriginWithArg>; + type ForceOrigin = EnsureRoot; + type AssetDeposit = ConstU64<2>; + type AssetAccountDeposit = ConstU64<2>; + type MetadataDepositBase = ConstU64<0>; + type MetadataDepositPerByte = ConstU64<0>; + type ApprovalDeposit = ConstU64<0>; + type StringLimit = ConstU32<20>; + type Freezer = (); + type Extra = (); + type CallbackHandle = (); + type WeightInfo = (); + type RemoveItemsLimit = ConstU32<1000>; + pallet_assets::runtime_benchmarks_enabled! { + type BenchmarkHelper = (); + } +} + +pub struct HardcodedAuthor; +pub(crate) const BLOCK_AUTHOR: AccountId = 1234; +impl FindAuthor for HardcodedAuthor { + fn find_author<'a, I>(_: I) -> Option + where + I: 'a + IntoIterator, + { + Some(BLOCK_AUTHOR) + } +} + +impl pallet_authorship::Config for Runtime { + type FindAuthor = HardcodedAuthor; + type UncleGenerations = (); + type FilterUncle = (); + type EventHandler = (); +} + +pub struct CreditToBlockAuthor; +impl HandleCredit for CreditToBlockAuthor { + fn handle_credit(credit: CreditOf) { + if let Some(author) = pallet_authorship::Pallet::::author() { + // What to do in case paying the author fails (e.g. because `fee < min_balance`) + // default: drop the result which will trigger the `OnDrop` of the imbalance. + let _ = >::resolve(&author, credit); + } + } +} + +impl Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Fungibles = Assets; + type OnChargeAssetTransaction = FungiblesAdapter< + pallet_assets::BalanceToAssetBalance, + CreditToBlockAuthor, + >; +} diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index b79b87a93c..f76293f456 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -14,209 +14,22 @@ // limitations under the License. use super::*; -use crate as pallet_asset_tx_payment; -use codec; use frame_support::{ assert_ok, - dispatch::{DispatchClass, DispatchInfo, PostDispatchInfo}, + dispatch::{DispatchInfo, PostDispatchInfo}, pallet_prelude::*, - parameter_types, - traits::{fungibles::Mutate, AsEnsureOriginWithArg, ConstU32, ConstU64, ConstU8, FindAuthor}, - weights::{Weight, WeightToFee as WeightToFeeT}, - ConsensusEngineId, + traits::fungibles::Mutate, + weights::Weight, }; use frame_system as system; -use frame_system::EnsureRoot; +use mock::{ExtrinsicBaseWeight, *}; use pallet_balances::Call as BalancesCall; -use pallet_transaction_payment::CurrencyAdapter; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, ConvertInto, IdentityLookup, SaturatedConversion, StaticLookup}, -}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; -type Balance = u64; -type AccountId = u64; - -frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - Assets: pallet_assets::{Pallet, Call, Storage, Event}, - Authorship: pallet_authorship::{Pallet, Call, Storage}, - AssetTxPayment: pallet_asset_tx_payment::{Pallet, Event}, - } -); +use sp_runtime::traits::StaticLookup; const CALL: &::RuntimeCall = &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); -parameter_types! { - static ExtrinsicBaseWeight: Weight = Weight::zero(); -} - -pub struct BlockWeights; -impl Get for BlockWeights { - fn get() -> frame_system::limits::BlockWeights { - frame_system::limits::BlockWeights::builder() - .base_block(Weight::zero()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get().into(); - }) - .for_class(DispatchClass::non_mandatory(), |weights| { - weights.max_total = Weight::from_ref_time(1024).set_proof_size(u64::MAX).into(); - }) - .build_or_panic() - } -} - -parameter_types! { - pub static WeightToFee: u64 = 1; - pub static TransactionByteFee: u64 = 1; -} - -impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = BlockWeights; - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u64 = 10; -} - -impl pallet_balances::Config for Runtime { - type Balance = Balance; - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ConstU64<10>; - type AccountStore = System; - type MaxLocks = (); - type WeightInfo = (); - type MaxReserves = ConstU32<50>; - type ReserveIdentifier = [u8; 8]; -} - -impl WeightToFeeT for WeightToFee { - type Balance = u64; - - fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(weight.ref_time()) - .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) - } -} - -impl WeightToFeeT for TransactionByteFee { - type Balance = u64; - - fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(weight.ref_time()) - .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) - } -} - -impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = CurrencyAdapter; - type WeightToFee = WeightToFee; - type LengthToFee = TransactionByteFee; - type FeeMultiplierUpdate = (); - type OperationalFeeMultiplier = ConstU8<5>; -} - -type AssetId = u32; - -impl pallet_assets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type AssetId = AssetId; - type AssetIdParameter = codec::Compact; - type Currency = Balances; - type CreateOrigin = AsEnsureOriginWithArg>; - type ForceOrigin = EnsureRoot; - type AssetDeposit = ConstU64<2>; - type AssetAccountDeposit = ConstU64<2>; - type MetadataDepositBase = ConstU64<0>; - type MetadataDepositPerByte = ConstU64<0>; - type ApprovalDeposit = ConstU64<0>; - type StringLimit = ConstU32<20>; - type Freezer = (); - type Extra = (); - type CallbackHandle = (); - type WeightInfo = (); - type RemoveItemsLimit = ConstU32<1000>; - pallet_assets::runtime_benchmarks_enabled! { - type BenchmarkHelper = (); - } -} - -pub struct HardcodedAuthor; -const BLOCK_AUTHOR: AccountId = 1234; -impl FindAuthor for HardcodedAuthor { - fn find_author<'a, I>(_: I) -> Option - where - I: 'a + IntoIterator, - { - Some(BLOCK_AUTHOR) - } -} - -impl pallet_authorship::Config for Runtime { - type FindAuthor = HardcodedAuthor; - type UncleGenerations = (); - type FilterUncle = (); - type EventHandler = (); -} - -pub struct CreditToBlockAuthor; -impl HandleCredit for CreditToBlockAuthor { - fn handle_credit(credit: CreditOf) { - if let Some(author) = pallet_authorship::Pallet::::author() { - // What to do in case paying the author fails (e.g. because `fee < min_balance`) - // default: drop the result which will trigger the `OnDrop` of the imbalance. - let _ = >::resolve(&author, credit); - } - } -} - -impl Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Fungibles = Assets; - type OnChargeAssetTransaction = FungiblesAdapter< - pallet_assets::BalanceToAssetBalance, - CreditToBlockAuthor, - >; -} - pub struct ExtBuilder { balance_factor: u64, base_weight: Weight, diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index ce747fa6bd..13adbf89c4 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -70,6 +70,11 @@ use frame_support::{ weights::{Weight, WeightToFee}, }; +#[cfg(test)] +mod mock; +#[cfg(test)] +mod tests; + mod payment; mod types; @@ -847,959 +852,3 @@ where Self::compute_actual_fee(len, &info, &post_info, Zero::zero()) } } - -#[cfg(test)] -mod tests { - use super::*; - use crate as pallet_transaction_payment; - - use codec::Encode; - - use sp_core::H256; - use sp_runtime::{ - testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentityLookup, One}, - transaction_validity::InvalidTransaction, - }; - - use frame_support::{ - assert_noop, assert_ok, - dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo}, - parameter_types, - traits::{ConstU32, ConstU64, Currency, GenesisBuild, Imbalance, OnUnbalanced}, - weights::{Weight, WeightToFee as WeightToFeeT}, - }; - use frame_system as system; - use pallet_balances::Call as BalancesCall; - - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - type Block = frame_system::mocking::MockBlock; - - frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - } - ); - - const CALL: &::RuntimeCall = - &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); - - parameter_types! { - static ExtrinsicBaseWeight: Weight = Weight::zero(); - } - - pub struct BlockWeights; - impl Get for BlockWeights { - fn get() -> frame_system::limits::BlockWeights { - frame_system::limits::BlockWeights::builder() - .base_block(Weight::zero()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get().into(); - }) - .for_class(DispatchClass::non_mandatory(), |weights| { - weights.max_total = Weight::from_ref_time(1024).set_proof_size(u64::MAX).into(); - }) - .build_or_panic() - } - } - - parameter_types! { - pub static WeightToFee: u64 = 1; - pub static TransactionByteFee: u64 = 1; - pub static OperationalFeeMultiplier: u8 = 5; - } - - impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = BlockWeights; - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU64<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; - } - - impl pallet_balances::Config for Runtime { - type Balance = u64; - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ConstU64<1>; - type AccountStore = System; - type MaxLocks = (); - type MaxReserves = (); - type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); - } - - impl WeightToFeeT for WeightToFee { - type Balance = u64; - - fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(weight.ref_time()) - .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) - } - } - - impl WeightToFeeT for TransactionByteFee { - type Balance = u64; - - fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(weight.ref_time()) - .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) - } - } - - parameter_types! { - static TipUnbalancedAmount: u64 = 0; - static FeeUnbalancedAmount: u64 = 0; - } - - pub struct DealWithFees; - impl OnUnbalanced> for DealWithFees { - fn on_unbalanceds( - mut fees_then_tips: impl Iterator>, - ) { - if let Some(fees) = fees_then_tips.next() { - FeeUnbalancedAmount::mutate(|a| *a += fees.peek()); - if let Some(tips) = fees_then_tips.next() { - TipUnbalancedAmount::mutate(|a| *a += tips.peek()); - } - } - } - } - - impl Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = CurrencyAdapter; - type OperationalFeeMultiplier = OperationalFeeMultiplier; - type WeightToFee = WeightToFee; - type LengthToFee = TransactionByteFee; - type FeeMultiplierUpdate = (); - } - - pub struct ExtBuilder { - balance_factor: u64, - base_weight: Weight, - byte_fee: u64, - weight_to_fee: u64, - initial_multiplier: Option, - } - - impl Default for ExtBuilder { - fn default() -> Self { - Self { - balance_factor: 1, - base_weight: Weight::zero(), - byte_fee: 1, - weight_to_fee: 1, - initial_multiplier: None, - } - } - } - - impl ExtBuilder { - pub fn base_weight(mut self, base_weight: Weight) -> Self { - self.base_weight = base_weight; - self - } - pub fn byte_fee(mut self, byte_fee: u64) -> Self { - self.byte_fee = byte_fee; - self - } - pub fn weight_fee(mut self, weight_to_fee: u64) -> Self { - self.weight_to_fee = weight_to_fee; - self - } - pub fn balance_factor(mut self, factor: u64) -> Self { - self.balance_factor = factor; - self - } - pub fn with_initial_multiplier(mut self, multiplier: Multiplier) -> Self { - self.initial_multiplier = Some(multiplier); - self - } - fn set_constants(&self) { - ExtrinsicBaseWeight::mutate(|v| *v = self.base_weight); - TRANSACTION_BYTE_FEE.with(|v| *v.borrow_mut() = self.byte_fee); - WEIGHT_TO_FEE.with(|v| *v.borrow_mut() = self.weight_to_fee); - } - pub fn build(self) -> sp_io::TestExternalities { - self.set_constants(); - let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - pallet_balances::GenesisConfig:: { - balances: if self.balance_factor > 0 { - vec![ - (1, 10 * self.balance_factor), - (2, 20 * self.balance_factor), - (3, 30 * self.balance_factor), - (4, 40 * self.balance_factor), - (5, 50 * self.balance_factor), - (6, 60 * self.balance_factor), - ] - } else { - vec![] - }, - } - .assimilate_storage(&mut t) - .unwrap(); - - if let Some(multiplier) = self.initial_multiplier { - let genesis = pallet::GenesisConfig { multiplier }; - GenesisBuild::::assimilate_storage(&genesis, &mut t).unwrap(); - } - - t.into() - } - } - - /// create a transaction info struct from weight. Handy to avoid building the whole struct. - pub fn info_from_weight(w: Weight) -> DispatchInfo { - // pays_fee: Pays::Yes -- class: DispatchClass::Normal - DispatchInfo { weight: w, ..Default::default() } - } - - fn post_info_from_weight(w: Weight) -> PostDispatchInfo { - PostDispatchInfo { actual_weight: Some(w), pays_fee: Default::default() } - } - - fn post_info_from_pays(p: Pays) -> PostDispatchInfo { - PostDispatchInfo { actual_weight: None, pays_fee: p } - } - - fn default_post_info() -> PostDispatchInfo { - PostDispatchInfo { actual_weight: None, pays_fee: Default::default() } - } - - #[test] - fn signed_extension_transaction_payment_work() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(5)) - .build() - .execute_with(|| { - let len = 10; - let pre = ChargeTransactionPayment::::from(0) - .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(5)), len) - .unwrap(); - assert_eq!(Balances::free_balance(1), 100 - 5 - 5 - 10); - - assert_ok!(ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(Weight::from_ref_time(5)), - &default_post_info(), - len, - &Ok(()) - )); - assert_eq!(Balances::free_balance(1), 100 - 5 - 5 - 10); - assert_eq!(FeeUnbalancedAmount::get(), 5 + 5 + 10); - assert_eq!(TipUnbalancedAmount::get(), 0); - - FeeUnbalancedAmount::mutate(|a| *a = 0); - - let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) - .unwrap(); - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); - - assert_ok!(ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(Weight::from_ref_time(100)), - &post_info_from_weight(Weight::from_ref_time(50)), - len, - &Ok(()) - )); - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 50 - 5); - assert_eq!(FeeUnbalancedAmount::get(), 5 + 10 + 50); - assert_eq!(TipUnbalancedAmount::get(), 5); - }); - } - - #[test] - fn signed_extension_transaction_payment_multiplied_refund_works() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(5)) - .build() - .execute_with(|| { - let len = 10; - >::put(Multiplier::saturating_from_rational(3, 2)); - - let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) - .unwrap(); - // 5 base fee, 10 byte fee, 3/2 * 100 weight fee, 5 tip - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 150 - 5); - - assert_ok!(ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(Weight::from_ref_time(100)), - &post_info_from_weight(Weight::from_ref_time(50)), - len, - &Ok(()) - )); - // 75 (3/2 of the returned 50 units of weight) is refunded - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 75 - 5); - }); - } - - #[test] - fn signed_extension_transaction_payment_is_bounded() { - ExtBuilder::default().balance_factor(1000).byte_fee(0).build().execute_with(|| { - // maximum weight possible - assert_ok!(ChargeTransactionPayment::::from(0).pre_dispatch( - &1, - CALL, - &info_from_weight(Weight::MAX), - 10 - )); - // fee will be proportional to what is the actual maximum weight in the runtime. - assert_eq!( - Balances::free_balance(&1), - (10000 - - ::BlockWeights::get().max_block.ref_time()) as u64 - ); - }); - } - - #[test] - fn signed_extension_allows_free_transactions() { - ExtBuilder::default() - .base_weight(Weight::from_ref_time(100)) - .balance_factor(0) - .build() - .execute_with(|| { - // 1 ain't have a penny. - assert_eq!(Balances::free_balance(1), 0); - - let len = 100; - - // This is a completely free (and thus wholly insecure/DoS-ridden) transaction. - let operational_transaction = DispatchInfo { - weight: Weight::from_ref_time(0), - class: DispatchClass::Operational, - pays_fee: Pays::No, - }; - assert_ok!(ChargeTransactionPayment::::from(0).validate( - &1, - CALL, - &operational_transaction, - len - )); - - // like a InsecureFreeNormal - let free_transaction = DispatchInfo { - weight: Weight::from_ref_time(0), - class: DispatchClass::Normal, - pays_fee: Pays::Yes, - }; - assert_noop!( - ChargeTransactionPayment::::from(0).validate( - &1, - CALL, - &free_transaction, - len - ), - TransactionValidityError::Invalid(InvalidTransaction::Payment), - ); - }); - } - - #[test] - fn signed_ext_length_fee_is_also_updated_per_congestion() { - ExtBuilder::default() - .base_weight(Weight::from_ref_time(5)) - .balance_factor(10) - .build() - .execute_with(|| { - // all fees should be x1.5 - >::put(Multiplier::saturating_from_rational(3, 2)); - let len = 10; - - assert_ok!( - ChargeTransactionPayment::::from(10) // tipped - .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(3)), len) - ); - assert_eq!( - Balances::free_balance(1), - 100 // original - - 10 // tip - - 5 // base - - 10 // len - - (3 * 3 / 2) // adjusted weight - ); - }) - } - - #[test] - fn query_info_and_fee_details_works() { - let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); - let origin = 111111; - let extra = (); - let xt = TestXt::new(call.clone(), Some((origin, extra))); - let info = xt.get_dispatch_info(); - let ext = xt.encode(); - let len = ext.len() as u32; - - let unsigned_xt = TestXt::<_, ()>::new(call, None); - let unsigned_xt_info = unsigned_xt.get_dispatch_info(); - - ExtBuilder::default() - .base_weight(Weight::from_ref_time(5)) - .weight_fee(2) - .build() - .execute_with(|| { - // all fees should be x1.5 - >::put(Multiplier::saturating_from_rational(3, 2)); - - assert_eq!( - TransactionPayment::query_info(xt.clone(), len), - RuntimeDispatchInfo { - weight: info.weight, - class: info.class, - partial_fee: 5 * 2 /* base * weight_fee */ - + len as u64 /* len * 1 */ - + info.weight.min(BlockWeights::get().max_block).ref_time() as u64 * 2 * 3 / 2 /* weight */ - }, - ); - - assert_eq!( - TransactionPayment::query_info(unsigned_xt.clone(), len), - RuntimeDispatchInfo { - weight: unsigned_xt_info.weight, - class: unsigned_xt_info.class, - partial_fee: 0, - }, - ); - - assert_eq!( - TransactionPayment::query_fee_details(xt, len), - FeeDetails { - inclusion_fee: Some(InclusionFee { - base_fee: 5 * 2, - len_fee: len as u64, - adjusted_weight_fee: info - .weight - .min(BlockWeights::get().max_block) - .ref_time() as u64 * 2 * 3 / 2 - }), - tip: 0, - }, - ); - - assert_eq!( - TransactionPayment::query_fee_details(unsigned_xt, len), - FeeDetails { inclusion_fee: None, tip: 0 }, - ); - }); - } - - #[test] - fn query_call_info_and_fee_details_works() { - let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); - let info = call.get_dispatch_info(); - let encoded_call = call.encode(); - let len = encoded_call.len() as u32; - - ExtBuilder::default() - .base_weight(Weight::from_ref_time(5)) - .weight_fee(2) - .build() - .execute_with(|| { - // all fees should be x1.5 - >::put(Multiplier::saturating_from_rational(3, 2)); - - assert_eq!( - TransactionPayment::query_call_info(call.clone(), len), - RuntimeDispatchInfo { - weight: info.weight, - class: info.class, - partial_fee: 5 * 2 /* base * weight_fee */ - + len as u64 /* len * 1 */ - + info.weight.min(BlockWeights::get().max_block).ref_time() as u64 * 2 * 3 / 2 /* weight */ - }, - ); - - assert_eq!( - TransactionPayment::query_call_fee_details(call, len), - FeeDetails { - inclusion_fee: Some(InclusionFee { - base_fee: 5 * 2, /* base * weight_fee */ - len_fee: len as u64, /* len * 1 */ - adjusted_weight_fee: info - .weight - .min(BlockWeights::get().max_block) - .ref_time() as u64 * 2 * 3 / 2 /* weight * weight_fee * multipler */ - }), - tip: 0, - }, - ); - }); - } - - #[test] - fn compute_fee_works_without_multiplier() { - ExtBuilder::default() - .base_weight(Weight::from_ref_time(100)) - .byte_fee(10) - .balance_factor(0) - .build() - .execute_with(|| { - // Next fee multiplier is zero - assert_eq!(>::get(), Multiplier::one()); - - // Tip only, no fees works - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(0), - class: DispatchClass::Operational, - pays_fee: Pays::No, - }; - assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 10), 10); - // No tip, only base fee works - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(0), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 100); - // Tip + base fee works - assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 69), 169); - // Len (byte fee) + base fee works - assert_eq!(Pallet::::compute_fee(42, &dispatch_info, 0), 520); - // Weight fee + base fee works - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(1000), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 1100); - }); - } - - #[test] - fn compute_fee_works_with_multiplier() { - ExtBuilder::default() - .base_weight(Weight::from_ref_time(100)) - .byte_fee(10) - .balance_factor(0) - .build() - .execute_with(|| { - // Add a next fee multiplier. Fees will be x3/2. - >::put(Multiplier::saturating_from_rational(3, 2)); - // Base fee is unaffected by multiplier - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(0), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 100); - - // Everything works together :) - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(123), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - // 123 weight, 456 length, 100 base - assert_eq!( - Pallet::::compute_fee(456, &dispatch_info, 789), - 100 + (3 * 123 / 2) + 4560 + 789, - ); - }); - } - - #[test] - fn compute_fee_works_with_negative_multiplier() { - ExtBuilder::default() - .base_weight(Weight::from_ref_time(100)) - .byte_fee(10) - .balance_factor(0) - .build() - .execute_with(|| { - // Add a next fee multiplier. All fees will be x1/2. - >::put(Multiplier::saturating_from_rational(1, 2)); - - // Base fee is unaffected by multiplier. - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(0), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 100); - - // Everything works together. - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(123), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - // 123 weight, 456 length, 100 base - assert_eq!( - Pallet::::compute_fee(456, &dispatch_info, 789), - 100 + (123 / 2) + 4560 + 789, - ); - }); - } - - #[test] - fn compute_fee_does_not_overflow() { - ExtBuilder::default() - .base_weight(Weight::from_ref_time(100)) - .byte_fee(10) - .balance_factor(0) - .build() - .execute_with(|| { - // Overflow is handled - let dispatch_info = DispatchInfo { - weight: Weight::MAX, - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - assert_eq!( - Pallet::::compute_fee(u32::MAX, &dispatch_info, u64::MAX), - u64::MAX - ); - }); - } - - #[test] - fn refund_does_not_recreate_account() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(5)) - .build() - .execute_with(|| { - // So events are emitted - System::set_block_number(10); - let len = 10; - let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) - .unwrap(); - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); - - // kill the account between pre and post dispatch - assert_ok!(Balances::transfer(Some(2).into(), 3, Balances::free_balance(2))); - assert_eq!(Balances::free_balance(2), 0); - - assert_ok!(ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(Weight::from_ref_time(100)), - &post_info_from_weight(Weight::from_ref_time(50)), - len, - &Ok(()) - )); - assert_eq!(Balances::free_balance(2), 0); - // Transfer Event - System::assert_has_event(RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80 }, - )); - // Killed Event - System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount { - account: 2, - })); - }); - } - - #[test] - fn actual_weight_higher_than_max_refunds_nothing() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(5)) - .build() - .execute_with(|| { - let len = 10; - let pre = ChargeTransactionPayment::::from(5 /* tipped */) - .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) - .unwrap(); - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); - - assert_ok!(ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info_from_weight(Weight::from_ref_time(100)), - &post_info_from_weight(Weight::from_ref_time(101)), - len, - &Ok(()) - )); - assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); - }); - } - - #[test] - fn zero_transfer_on_free_transaction() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(5)) - .build() - .execute_with(|| { - // So events are emitted - System::set_block_number(10); - let len = 10; - let dispatch_info = DispatchInfo { - weight: Weight::from_ref_time(100), - pays_fee: Pays::No, - class: DispatchClass::Normal, - }; - let user = 69; - let pre = ChargeTransactionPayment::::from(0) - .pre_dispatch(&user, CALL, &dispatch_info, len) - .unwrap(); - assert_eq!(Balances::total_balance(&user), 0); - assert_ok!(ChargeTransactionPayment::::post_dispatch( - Some(pre), - &dispatch_info, - &default_post_info(), - len, - &Ok(()) - )); - assert_eq!(Balances::total_balance(&user), 0); - // TransactionFeePaid Event - System::assert_has_event(RuntimeEvent::TransactionPayment( - pallet_transaction_payment::Event::TransactionFeePaid { - who: user, - actual_fee: 0, - tip: 0, - }, - )); - }); - } - - #[test] - fn refund_consistent_with_actual_weight() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(7)) - .build() - .execute_with(|| { - let info = info_from_weight(Weight::from_ref_time(100)); - let post_info = post_info_from_weight(Weight::from_ref_time(33)); - let prev_balance = Balances::free_balance(2); - let len = 10; - let tip = 5; - - >::put(Multiplier::saturating_from_rational(5, 4)); - - let pre = ChargeTransactionPayment::::from(tip) - .pre_dispatch(&2, CALL, &info, len) - .unwrap(); - - ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info, - &post_info, - len, - &Ok(()), - ) - .unwrap(); - - let refund_based_fee = prev_balance - Balances::free_balance(2); - let actual_fee = - Pallet::::compute_actual_fee(len as u32, &info, &post_info, tip); - - // 33 weight, 10 length, 7 base, 5 tip - assert_eq!(actual_fee, 7 + 10 + (33 * 5 / 4) + 5); - assert_eq!(refund_based_fee, actual_fee); - }); - } - - #[test] - fn should_alter_operational_priority() { - let tip = 5; - let len = 10; - - ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let normal = DispatchInfo { - weight: Weight::from_ref_time(100), - class: DispatchClass::Normal, - pays_fee: Pays::Yes, - }; - let priority = ChargeTransactionPayment::(tip) - .validate(&2, CALL, &normal, len) - .unwrap() - .priority; - - assert_eq!(priority, 60); - - let priority = ChargeTransactionPayment::(2 * tip) - .validate(&2, CALL, &normal, len) - .unwrap() - .priority; - - assert_eq!(priority, 110); - }); - - ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let op = DispatchInfo { - weight: Weight::from_ref_time(100), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - let priority = ChargeTransactionPayment::(tip) - .validate(&2, CALL, &op, len) - .unwrap() - .priority; - assert_eq!(priority, 5810); - - let priority = ChargeTransactionPayment::(2 * tip) - .validate(&2, CALL, &op, len) - .unwrap() - .priority; - assert_eq!(priority, 6110); - }); - } - - #[test] - fn no_tip_has_some_priority() { - let tip = 0; - let len = 10; - - ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let normal = DispatchInfo { - weight: Weight::from_ref_time(100), - class: DispatchClass::Normal, - pays_fee: Pays::Yes, - }; - let priority = ChargeTransactionPayment::(tip) - .validate(&2, CALL, &normal, len) - .unwrap() - .priority; - - assert_eq!(priority, 10); - }); - - ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let op = DispatchInfo { - weight: Weight::from_ref_time(100), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - let priority = ChargeTransactionPayment::(tip) - .validate(&2, CALL, &op, len) - .unwrap() - .priority; - assert_eq!(priority, 5510); - }); - } - - #[test] - fn higher_tip_have_higher_priority() { - let get_priorities = |tip: u64| { - let mut priority1 = 0; - let mut priority2 = 0; - let len = 10; - ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let normal = DispatchInfo { - weight: Weight::from_ref_time(100), - class: DispatchClass::Normal, - pays_fee: Pays::Yes, - }; - priority1 = ChargeTransactionPayment::(tip) - .validate(&2, CALL, &normal, len) - .unwrap() - .priority; - }); - - ExtBuilder::default().balance_factor(100).build().execute_with(|| { - let op = DispatchInfo { - weight: Weight::from_ref_time(100), - class: DispatchClass::Operational, - pays_fee: Pays::Yes, - }; - priority2 = ChargeTransactionPayment::(tip) - .validate(&2, CALL, &op, len) - .unwrap() - .priority; - }); - - (priority1, priority2) - }; - - let mut prev_priorities = get_priorities(0); - - for tip in 1..3 { - let priorities = get_priorities(tip); - assert!(prev_priorities.0 < priorities.0); - assert!(prev_priorities.1 < priorities.1); - prev_priorities = priorities; - } - } - - #[test] - fn post_info_can_change_pays_fee() { - ExtBuilder::default() - .balance_factor(10) - .base_weight(Weight::from_ref_time(7)) - .build() - .execute_with(|| { - let info = info_from_weight(Weight::from_ref_time(100)); - let post_info = post_info_from_pays(Pays::No); - let prev_balance = Balances::free_balance(2); - let len = 10; - let tip = 5; - - >::put(Multiplier::saturating_from_rational(5, 4)); - - let pre = ChargeTransactionPayment::::from(tip) - .pre_dispatch(&2, CALL, &info, len) - .unwrap(); - - ChargeTransactionPayment::::post_dispatch( - Some(pre), - &info, - &post_info, - len, - &Ok(()), - ) - .unwrap(); - - let refund_based_fee = prev_balance - Balances::free_balance(2); - let actual_fee = - Pallet::::compute_actual_fee(len as u32, &info, &post_info, tip); - - // Only 5 tip is paid - assert_eq!(actual_fee, 5); - assert_eq!(refund_based_fee, actual_fee); - }); - } - - #[test] - fn genesis_config_works() { - ExtBuilder::default() - .with_initial_multiplier(Multiplier::from_u32(100)) - .build() - .execute_with(|| { - assert_eq!( - >::get(), - Multiplier::saturating_from_integer(100) - ); - }); - } - - #[test] - fn genesis_default_works() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!(>::get(), Multiplier::saturating_from_integer(1)); - }); - } -} diff --git a/frame/transaction-payment/src/mock.rs b/frame/transaction-payment/src/mock.rs new file mode 100644 index 0000000000..e214458b37 --- /dev/null +++ b/frame/transaction-payment/src/mock.rs @@ -0,0 +1,162 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate as pallet_transaction_payment; + +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, +}; + +use frame_support::{ + dispatch::DispatchClass, + parameter_types, + traits::{ConstU32, ConstU64, Imbalance, OnUnbalanced}, + weights::{Weight, WeightToFee as WeightToFeeT}, +}; +use frame_system as system; +use pallet_balances::Call as BalancesCall; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: system::{Pallet, Call, Config, Storage, Event}, + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, + } +); + +pub(crate) const CALL: &::RuntimeCall = + &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + +parameter_types! { + pub(crate) static ExtrinsicBaseWeight: Weight = Weight::zero(); +} + +pub struct BlockWeights; +impl Get for BlockWeights { + fn get() -> frame_system::limits::BlockWeights { + frame_system::limits::BlockWeights::builder() + .base_block(Weight::zero()) + .for_class(DispatchClass::all(), |weights| { + weights.base_extrinsic = ExtrinsicBaseWeight::get().into(); + }) + .for_class(DispatchClass::non_mandatory(), |weights| { + weights.max_total = Weight::from_ref_time(1024).set_proof_size(u64::MAX).into(); + }) + .build_or_panic() + } +} + +parameter_types! { + pub static WeightToFee: u64 = 1; + pub static TransactionByteFee: u64 = 1; + pub static OperationalFeeMultiplier: u8 = 5; +} + +impl frame_system::Config for Runtime { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = BlockWeights; + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type BlockNumber = u64; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; +} + +impl pallet_balances::Config for Runtime { + type Balance = u64; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ConstU64<1>; + type AccountStore = System; + type MaxLocks = (); + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type WeightInfo = (); +} + +impl WeightToFeeT for WeightToFee { + type Balance = u64; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) + } +} + +impl WeightToFeeT for TransactionByteFee { + type Balance = u64; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) + } +} + +parameter_types! { + pub(crate) static TipUnbalancedAmount: u64 = 0; + pub(crate) static FeeUnbalancedAmount: u64 = 0; +} + +pub struct DealWithFees; +impl OnUnbalanced> for DealWithFees { + fn on_unbalanceds( + mut fees_then_tips: impl Iterator>, + ) { + if let Some(fees) = fees_then_tips.next() { + FeeUnbalancedAmount::mutate(|a| *a += fees.peek()); + if let Some(tips) = fees_then_tips.next() { + TipUnbalancedAmount::mutate(|a| *a += tips.peek()); + } + } + } +} + +impl Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = CurrencyAdapter; + type OperationalFeeMultiplier = OperationalFeeMultiplier; + type WeightToFee = WeightToFee; + type LengthToFee = TransactionByteFee; + type FeeMultiplierUpdate = (); +} diff --git a/frame/transaction-payment/src/tests.rs b/frame/transaction-payment/src/tests.rs new file mode 100644 index 0000000000..ee54c1130e --- /dev/null +++ b/frame/transaction-payment/src/tests.rs @@ -0,0 +1,836 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +use crate as pallet_transaction_payment; + +use codec::Encode; + +use sp_runtime::{testing::TestXt, traits::One, transaction_validity::InvalidTransaction}; + +use frame_support::{ + assert_noop, assert_ok, + dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo}, + traits::{Currency, GenesisBuild}, + weights::Weight, +}; +use frame_system as system; +use mock::*; +use pallet_balances::Call as BalancesCall; + +pub struct ExtBuilder { + balance_factor: u64, + base_weight: Weight, + byte_fee: u64, + weight_to_fee: u64, + initial_multiplier: Option, +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { + balance_factor: 1, + base_weight: Weight::zero(), + byte_fee: 1, + weight_to_fee: 1, + initial_multiplier: None, + } + } +} + +impl ExtBuilder { + pub fn base_weight(mut self, base_weight: Weight) -> Self { + self.base_weight = base_weight; + self + } + pub fn byte_fee(mut self, byte_fee: u64) -> Self { + self.byte_fee = byte_fee; + self + } + pub fn weight_fee(mut self, weight_to_fee: u64) -> Self { + self.weight_to_fee = weight_to_fee; + self + } + pub fn balance_factor(mut self, factor: u64) -> Self { + self.balance_factor = factor; + self + } + pub fn with_initial_multiplier(mut self, multiplier: Multiplier) -> Self { + self.initial_multiplier = Some(multiplier); + self + } + fn set_constants(&self) { + ExtrinsicBaseWeight::mutate(|v| *v = self.base_weight); + TRANSACTION_BYTE_FEE.with(|v| *v.borrow_mut() = self.byte_fee); + WEIGHT_TO_FEE.with(|v| *v.borrow_mut() = self.weight_to_fee); + } + pub fn build(self) -> sp_io::TestExternalities { + self.set_constants(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { + balances: if self.balance_factor > 0 { + vec![ + (1, 10 * self.balance_factor), + (2, 20 * self.balance_factor), + (3, 30 * self.balance_factor), + (4, 40 * self.balance_factor), + (5, 50 * self.balance_factor), + (6, 60 * self.balance_factor), + ] + } else { + vec![] + }, + } + .assimilate_storage(&mut t) + .unwrap(); + + if let Some(multiplier) = self.initial_multiplier { + let genesis = pallet::GenesisConfig { multiplier }; + GenesisBuild::::assimilate_storage(&genesis, &mut t).unwrap(); + } + + t.into() + } +} + +/// create a transaction info struct from weight. Handy to avoid building the whole struct. +pub fn info_from_weight(w: Weight) -> DispatchInfo { + // pays_fee: Pays::Yes -- class: DispatchClass::Normal + DispatchInfo { weight: w, ..Default::default() } +} + +fn post_info_from_weight(w: Weight) -> PostDispatchInfo { + PostDispatchInfo { actual_weight: Some(w), pays_fee: Default::default() } +} + +fn post_info_from_pays(p: Pays) -> PostDispatchInfo { + PostDispatchInfo { actual_weight: None, pays_fee: p } +} + +fn default_post_info() -> PostDispatchInfo { + PostDispatchInfo { actual_weight: None, pays_fee: Default::default() } +} + +#[test] +fn signed_extension_transaction_payment_work() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(5)) + .build() + .execute_with(|| { + let len = 10; + let pre = ChargeTransactionPayment::::from(0) + .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(5)), len) + .unwrap(); + assert_eq!(Balances::free_balance(1), 100 - 5 - 5 - 10); + + assert_ok!(ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info_from_weight(Weight::from_ref_time(5)), + &default_post_info(), + len, + &Ok(()) + )); + assert_eq!(Balances::free_balance(1), 100 - 5 - 5 - 10); + assert_eq!(FeeUnbalancedAmount::get(), 5 + 5 + 10); + assert_eq!(TipUnbalancedAmount::get(), 0); + + FeeUnbalancedAmount::mutate(|a| *a = 0); + + let pre = ChargeTransactionPayment::::from(5 /* tipped */) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) + .unwrap(); + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); + + assert_ok!(ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), + len, + &Ok(()) + )); + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 50 - 5); + assert_eq!(FeeUnbalancedAmount::get(), 5 + 10 + 50); + assert_eq!(TipUnbalancedAmount::get(), 5); + }); +} + +#[test] +fn signed_extension_transaction_payment_multiplied_refund_works() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(5)) + .build() + .execute_with(|| { + let len = 10; + >::put(Multiplier::saturating_from_rational(3, 2)); + + let pre = ChargeTransactionPayment::::from(5 /* tipped */) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) + .unwrap(); + // 5 base fee, 10 byte fee, 3/2 * 100 weight fee, 5 tip + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 150 - 5); + + assert_ok!(ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), + len, + &Ok(()) + )); + // 75 (3/2 of the returned 50 units of weight) is refunded + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 75 - 5); + }); +} + +#[test] +fn signed_extension_transaction_payment_is_bounded() { + ExtBuilder::default().balance_factor(1000).byte_fee(0).build().execute_with(|| { + // maximum weight possible + assert_ok!(ChargeTransactionPayment::::from(0).pre_dispatch( + &1, + CALL, + &info_from_weight(Weight::MAX), + 10 + )); + // fee will be proportional to what is the actual maximum weight in the runtime. + assert_eq!( + Balances::free_balance(&1), + (10000 - ::BlockWeights::get().max_block.ref_time()) + as u64 + ); + }); +} + +#[test] +fn signed_extension_allows_free_transactions() { + ExtBuilder::default() + .base_weight(Weight::from_ref_time(100)) + .balance_factor(0) + .build() + .execute_with(|| { + // 1 ain't have a penny. + assert_eq!(Balances::free_balance(1), 0); + + let len = 100; + + // This is a completely free (and thus wholly insecure/DoS-ridden) transaction. + let operational_transaction = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Operational, + pays_fee: Pays::No, + }; + assert_ok!(ChargeTransactionPayment::::from(0).validate( + &1, + CALL, + &operational_transaction, + len + )); + + // like a InsecureFreeNormal + let free_transaction = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; + assert_noop!( + ChargeTransactionPayment::::from(0).validate( + &1, + CALL, + &free_transaction, + len + ), + TransactionValidityError::Invalid(InvalidTransaction::Payment), + ); + }); +} + +#[test] +fn signed_ext_length_fee_is_also_updated_per_congestion() { + ExtBuilder::default() + .base_weight(Weight::from_ref_time(5)) + .balance_factor(10) + .build() + .execute_with(|| { + // all fees should be x1.5 + >::put(Multiplier::saturating_from_rational(3, 2)); + let len = 10; + + assert_ok!(ChargeTransactionPayment::::from(10) // tipped + .pre_dispatch(&1, CALL, &info_from_weight(Weight::from_ref_time(3)), len)); + assert_eq!( + Balances::free_balance(1), + 100 // original + - 10 // tip + - 5 // base + - 10 // len + - (3 * 3 / 2) // adjusted weight + ); + }) +} + +#[test] +fn query_info_and_fee_details_works() { + let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + let origin = 111111; + let extra = (); + let xt = TestXt::new(call.clone(), Some((origin, extra))); + let info = xt.get_dispatch_info(); + let ext = xt.encode(); + let len = ext.len() as u32; + + let unsigned_xt = TestXt::<_, ()>::new(call, None); + let unsigned_xt_info = unsigned_xt.get_dispatch_info(); + + ExtBuilder::default() + .base_weight(Weight::from_ref_time(5)) + .weight_fee(2) + .build() + .execute_with(|| { + // all fees should be x1.5 + >::put(Multiplier::saturating_from_rational(3, 2)); + + assert_eq!( + TransactionPayment::query_info(xt.clone(), len), + RuntimeDispatchInfo { + weight: info.weight, + class: info.class, + partial_fee: 5 * 2 /* base * weight_fee */ + + len as u64 /* len * 1 */ + + info.weight.min(BlockWeights::get().max_block).ref_time() as u64 * 2 * 3 / 2 /* weight */ + }, + ); + + assert_eq!( + TransactionPayment::query_info(unsigned_xt.clone(), len), + RuntimeDispatchInfo { + weight: unsigned_xt_info.weight, + class: unsigned_xt_info.class, + partial_fee: 0, + }, + ); + + assert_eq!( + TransactionPayment::query_fee_details(xt, len), + FeeDetails { + inclusion_fee: Some(InclusionFee { + base_fee: 5 * 2, + len_fee: len as u64, + adjusted_weight_fee: info + .weight + .min(BlockWeights::get().max_block) + .ref_time() as u64 * 2 * 3 / 2 + }), + tip: 0, + }, + ); + + assert_eq!( + TransactionPayment::query_fee_details(unsigned_xt, len), + FeeDetails { inclusion_fee: None, tip: 0 }, + ); + }); +} + +#[test] +fn query_call_info_and_fee_details_works() { + let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + let info = call.get_dispatch_info(); + let encoded_call = call.encode(); + let len = encoded_call.len() as u32; + + ExtBuilder::default() + .base_weight(Weight::from_ref_time(5)) + .weight_fee(2) + .build() + .execute_with(|| { + // all fees should be x1.5 + >::put(Multiplier::saturating_from_rational(3, 2)); + + assert_eq!( + TransactionPayment::query_call_info(call.clone(), len), + RuntimeDispatchInfo { + weight: info.weight, + class: info.class, + partial_fee: 5 * 2 /* base * weight_fee */ + + len as u64 /* len * 1 */ + + info.weight.min(BlockWeights::get().max_block).ref_time() as u64 * 2 * 3 / 2 /* weight */ + }, + ); + + assert_eq!( + TransactionPayment::query_call_fee_details(call, len), + FeeDetails { + inclusion_fee: Some(InclusionFee { + base_fee: 5 * 2, /* base * weight_fee */ + len_fee: len as u64, /* len * 1 */ + adjusted_weight_fee: info + .weight + .min(BlockWeights::get().max_block) + .ref_time() as u64 * 2 * 3 / 2 /* weight * weight_fee * multipler */ + }), + tip: 0, + }, + ); + }); +} + +#[test] +fn compute_fee_works_without_multiplier() { + ExtBuilder::default() + .base_weight(Weight::from_ref_time(100)) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { + // Next fee multiplier is zero + assert_eq!(>::get(), Multiplier::one()); + + // Tip only, no fees works + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Operational, + pays_fee: Pays::No, + }; + assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 10), 10); + // No tip, only base fee works + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 100); + // Tip + base fee works + assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 69), 169); + // Len (byte fee) + base fee works + assert_eq!(Pallet::::compute_fee(42, &dispatch_info, 0), 520); + // Weight fee + base fee works + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(1000), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 1100); + }); +} + +#[test] +fn compute_fee_works_with_multiplier() { + ExtBuilder::default() + .base_weight(Weight::from_ref_time(100)) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { + // Add a next fee multiplier. Fees will be x3/2. + >::put(Multiplier::saturating_from_rational(3, 2)); + // Base fee is unaffected by multiplier + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 100); + + // Everything works together :) + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(123), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + // 123 weight, 456 length, 100 base + assert_eq!( + Pallet::::compute_fee(456, &dispatch_info, 789), + 100 + (3 * 123 / 2) + 4560 + 789, + ); + }); +} + +#[test] +fn compute_fee_works_with_negative_multiplier() { + ExtBuilder::default() + .base_weight(Weight::from_ref_time(100)) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { + // Add a next fee multiplier. All fees will be x1/2. + >::put(Multiplier::saturating_from_rational(1, 2)); + + // Base fee is unaffected by multiplier. + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(0), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + assert_eq!(Pallet::::compute_fee(0, &dispatch_info, 0), 100); + + // Everything works together. + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(123), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + // 123 weight, 456 length, 100 base + assert_eq!( + Pallet::::compute_fee(456, &dispatch_info, 789), + 100 + (123 / 2) + 4560 + 789, + ); + }); +} + +#[test] +fn compute_fee_does_not_overflow() { + ExtBuilder::default() + .base_weight(Weight::from_ref_time(100)) + .byte_fee(10) + .balance_factor(0) + .build() + .execute_with(|| { + // Overflow is handled + let dispatch_info = DispatchInfo { + weight: Weight::MAX, + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + assert_eq!( + Pallet::::compute_fee(u32::MAX, &dispatch_info, u64::MAX), + u64::MAX + ); + }); +} + +#[test] +fn refund_does_not_recreate_account() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(5)) + .build() + .execute_with(|| { + // So events are emitted + System::set_block_number(10); + let len = 10; + let pre = ChargeTransactionPayment::::from(5 /* tipped */) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) + .unwrap(); + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); + + // kill the account between pre and post dispatch + assert_ok!(Balances::transfer(Some(2).into(), 3, Balances::free_balance(2))); + assert_eq!(Balances::free_balance(2), 0); + + assert_ok!(ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(50)), + len, + &Ok(()) + )); + assert_eq!(Balances::free_balance(2), 0); + // Transfer Event + System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer { + from: 2, + to: 3, + amount: 80, + })); + // Killed Event + System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount { + account: 2, + })); + }); +} + +#[test] +fn actual_weight_higher_than_max_refunds_nothing() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(5)) + .build() + .execute_with(|| { + let len = 10; + let pre = ChargeTransactionPayment::::from(5 /* tipped */) + .pre_dispatch(&2, CALL, &info_from_weight(Weight::from_ref_time(100)), len) + .unwrap(); + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); + + assert_ok!(ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info_from_weight(Weight::from_ref_time(100)), + &post_info_from_weight(Weight::from_ref_time(101)), + len, + &Ok(()) + )); + assert_eq!(Balances::free_balance(2), 200 - 5 - 10 - 100 - 5); + }); +} + +#[test] +fn zero_transfer_on_free_transaction() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(5)) + .build() + .execute_with(|| { + // So events are emitted + System::set_block_number(10); + let len = 10; + let dispatch_info = DispatchInfo { + weight: Weight::from_ref_time(100), + pays_fee: Pays::No, + class: DispatchClass::Normal, + }; + let user = 69; + let pre = ChargeTransactionPayment::::from(0) + .pre_dispatch(&user, CALL, &dispatch_info, len) + .unwrap(); + assert_eq!(Balances::total_balance(&user), 0); + assert_ok!(ChargeTransactionPayment::::post_dispatch( + Some(pre), + &dispatch_info, + &default_post_info(), + len, + &Ok(()) + )); + assert_eq!(Balances::total_balance(&user), 0); + // TransactionFeePaid Event + System::assert_has_event(RuntimeEvent::TransactionPayment( + pallet_transaction_payment::Event::TransactionFeePaid { + who: user, + actual_fee: 0, + tip: 0, + }, + )); + }); +} + +#[test] +fn refund_consistent_with_actual_weight() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(7)) + .build() + .execute_with(|| { + let info = info_from_weight(Weight::from_ref_time(100)); + let post_info = post_info_from_weight(Weight::from_ref_time(33)); + let prev_balance = Balances::free_balance(2); + let len = 10; + let tip = 5; + + >::put(Multiplier::saturating_from_rational(5, 4)); + + let pre = ChargeTransactionPayment::::from(tip) + .pre_dispatch(&2, CALL, &info, len) + .unwrap(); + + ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info, + &post_info, + len, + &Ok(()), + ) + .unwrap(); + + let refund_based_fee = prev_balance - Balances::free_balance(2); + let actual_fee = + Pallet::::compute_actual_fee(len as u32, &info, &post_info, tip); + + // 33 weight, 10 length, 7 base, 5 tip + assert_eq!(actual_fee, 7 + 10 + (33 * 5 / 4) + 5); + assert_eq!(refund_based_fee, actual_fee); + }); +} + +#[test] +fn should_alter_operational_priority() { + let tip = 5; + let len = 10; + + ExtBuilder::default().balance_factor(100).build().execute_with(|| { + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; + let priority = ChargeTransactionPayment::(tip) + .validate(&2, CALL, &normal, len) + .unwrap() + .priority; + + assert_eq!(priority, 60); + + let priority = ChargeTransactionPayment::(2 * tip) + .validate(&2, CALL, &normal, len) + .unwrap() + .priority; + + assert_eq!(priority, 110); + }); + + ExtBuilder::default().balance_factor(100).build().execute_with(|| { + let op = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + let priority = ChargeTransactionPayment::(tip) + .validate(&2, CALL, &op, len) + .unwrap() + .priority; + assert_eq!(priority, 5810); + + let priority = ChargeTransactionPayment::(2 * tip) + .validate(&2, CALL, &op, len) + .unwrap() + .priority; + assert_eq!(priority, 6110); + }); +} + +#[test] +fn no_tip_has_some_priority() { + let tip = 0; + let len = 10; + + ExtBuilder::default().balance_factor(100).build().execute_with(|| { + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; + let priority = ChargeTransactionPayment::(tip) + .validate(&2, CALL, &normal, len) + .unwrap() + .priority; + + assert_eq!(priority, 10); + }); + + ExtBuilder::default().balance_factor(100).build().execute_with(|| { + let op = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + let priority = ChargeTransactionPayment::(tip) + .validate(&2, CALL, &op, len) + .unwrap() + .priority; + assert_eq!(priority, 5510); + }); +} + +#[test] +fn higher_tip_have_higher_priority() { + let get_priorities = |tip: u64| { + let mut priority1 = 0; + let mut priority2 = 0; + let len = 10; + ExtBuilder::default().balance_factor(100).build().execute_with(|| { + let normal = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Normal, + pays_fee: Pays::Yes, + }; + priority1 = ChargeTransactionPayment::(tip) + .validate(&2, CALL, &normal, len) + .unwrap() + .priority; + }); + + ExtBuilder::default().balance_factor(100).build().execute_with(|| { + let op = DispatchInfo { + weight: Weight::from_ref_time(100), + class: DispatchClass::Operational, + pays_fee: Pays::Yes, + }; + priority2 = ChargeTransactionPayment::(tip) + .validate(&2, CALL, &op, len) + .unwrap() + .priority; + }); + + (priority1, priority2) + }; + + let mut prev_priorities = get_priorities(0); + + for tip in 1..3 { + let priorities = get_priorities(tip); + assert!(prev_priorities.0 < priorities.0); + assert!(prev_priorities.1 < priorities.1); + prev_priorities = priorities; + } +} + +#[test] +fn post_info_can_change_pays_fee() { + ExtBuilder::default() + .balance_factor(10) + .base_weight(Weight::from_ref_time(7)) + .build() + .execute_with(|| { + let info = info_from_weight(Weight::from_ref_time(100)); + let post_info = post_info_from_pays(Pays::No); + let prev_balance = Balances::free_balance(2); + let len = 10; + let tip = 5; + + >::put(Multiplier::saturating_from_rational(5, 4)); + + let pre = ChargeTransactionPayment::::from(tip) + .pre_dispatch(&2, CALL, &info, len) + .unwrap(); + + ChargeTransactionPayment::::post_dispatch( + Some(pre), + &info, + &post_info, + len, + &Ok(()), + ) + .unwrap(); + + let refund_based_fee = prev_balance - Balances::free_balance(2); + let actual_fee = + Pallet::::compute_actual_fee(len as u32, &info, &post_info, tip); + + // Only 5 tip is paid + assert_eq!(actual_fee, 5); + assert_eq!(refund_based_fee, actual_fee); + }); +} + +#[test] +fn genesis_config_works() { + ExtBuilder::default() + .with_initial_multiplier(Multiplier::from_u32(100)) + .build() + .execute_with(|| { + assert_eq!( + >::get(), + Multiplier::saturating_from_integer(100) + ); + }); +} + +#[test] +fn genesis_default_works() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(>::get(), Multiplier::saturating_from_integer(1)); + }); +} From 42f38dbd961342cd965154858e50f0253b0b7c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 17 Jan 2023 20:17:08 +0100 Subject: [PATCH 21/80] frame-benchmarking: Macros should not force a particular env (#13161) The macros in frame-benchmarking relied on having all the macros imported, which isn't a behavior for a proper macro :D This pr fixes this by making all internal macro usages absolute. --- bin/node/runtime/src/lib.rs | 6 +---- frame/benchmarking/src/lib.rs | 49 +++++++++++++++++------------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d34c04fcb5..fb5da9749a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1823,13 +1823,9 @@ mod mmr { pub type Hashing = ::Hashing; } -#[cfg(feature = "runtime-benchmarks")] -#[macro_use] -extern crate frame_benchmarking; - #[cfg(feature = "runtime-benchmarks")] mod benches { - define_benchmarks!( + frame_benchmarking::define_benchmarks!( [frame_benchmarking, BaselineBench::] [pallet_alliance, Alliance] [pallet_assets, Assets] diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 29fa0b6a6a..e4ebd2f228 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -1836,15 +1836,15 @@ macro_rules! add_benchmark { /// Callback for `define_benchmarks` to call `add_benchmark`. #[macro_export] macro_rules! cb_add_benchmarks { - // anchor + // anchor ( $params:ident, $batches:ident, [ $name:path, $( $location:tt )* ] ) => { - add_benchmark!( $params, $batches, $name, $( $location )* ); + $crate::add_benchmark!( $params, $batches, $name, $( $location )* ); }; - // recursion tail + // recursion tail ( $params:ident, $batches:ident, [ $name:path, $( $location:tt )* ] $([ $names:path, $( $locations:tt )* ])+ ) => { - cb_add_benchmarks!( $params, $batches, [ $name, $( $location )* ] ); - cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); - } + $crate::cb_add_benchmarks!( $params, $batches, [ $name, $( $location )* ] ); + $crate::cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); + } } /// This macro allows users to easily generate a list of benchmarks for the pallets configured @@ -1884,24 +1884,23 @@ macro_rules! list_benchmark { /// Callback for `define_benchmarks` to call `list_benchmark`. #[macro_export] macro_rules! cb_list_benchmarks { - // anchor + // anchor ( $list:ident, $extra:ident, [ $name:path, $( $location:tt )* ] ) => { - list_benchmark!( $list, $extra, $name, $( $location )* ); + $crate::list_benchmark!( $list, $extra, $name, $( $location )* ); }; - // recursion tail + // recursion tail ( $list:ident, $extra:ident, [ $name:path, $( $location:tt )* ] $([ $names:path, $( $locations:tt )* ])+ ) => { - cb_list_benchmarks!( $list, $extra, [ $name, $( $location )* ] ); - cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); - } + $crate::cb_list_benchmarks!( $list, $extra, [ $name, $( $location )* ] ); + $crate::cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); + } } /// Defines pallet configs that `add_benchmarks` and `list_benchmarks` use. /// Should be preferred instead of having a repetitive list of configs /// in `add_benchmark` and `list_benchmark`. - #[macro_export] macro_rules! define_benchmarks { - ( $([ $names:path, $( $locations:tt )* ])* ) => { + ( $([ $names:path, $( $locations:tt )* ])* ) => { /// Calls `list_benchmark` with all configs from `define_benchmarks` /// and passes the first two parameters on. /// @@ -1910,11 +1909,11 @@ macro_rules! define_benchmarks { /// list_benchmarks!(list, extra); /// ``` #[macro_export] - macro_rules! list_benchmarks { - ( $list:ident, $extra:ident ) => { - cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); - } - } + macro_rules! list_benchmarks { + ( $list:ident, $extra:ident ) => { + $crate::cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); + } + } /// Calls `add_benchmark` with all configs from `define_benchmarks` /// and passes the first two parameters on. @@ -1924,10 +1923,10 @@ macro_rules! define_benchmarks { /// add_benchmarks!(params, batches); /// ``` #[macro_export] - macro_rules! add_benchmarks { - ( $params:ident, $batches:ident ) => { - cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); - } - } - } + macro_rules! add_benchmarks { + ( $params:ident, $batches:ident ) => { + $crate::cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); + } + } + } } From cfe926282a284f7bdbf7b336eb78e80f51858577 Mon Sep 17 00:00:00 2001 From: Koute Date: Wed, 18 Jan 2023 15:28:27 +0900 Subject: [PATCH 22/80] Fix the `storage_size`/`state_getStorageSize` RPC call (#13154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Have `KeyIterator` clone the `prefix` it receives * Stream keys in `storage_size` RPC and add a runtime limit * Update client/rpc/Cargo.toml Co-authored-by: Bastian Köcher * Update client/rpc/src/state/utils.rs Co-authored-by: Bastian Köcher * Rename the types to signify that the cancellation is due to a timeout * Move the test into a `mod tests` * Add a comment regarding `biased` in `tokio::select` * Make the `clone` explicit when calling `KeyIterator::{new, new_child}` Co-authored-by: Bastian Köcher --- client/api/src/backend.rs | 26 +++--- client/rpc-api/src/state/mod.rs | 4 +- client/rpc/Cargo.toml | 4 +- client/rpc/src/state/mod.rs | 19 +++- client/rpc/src/state/state_full.rs | 67 +++++++++---- client/rpc/src/state/tests.rs | 7 +- client/rpc/src/state/utils.rs | 140 ++++++++++++++++++++++++++++ client/service/src/client/client.rs | 16 ++-- 8 files changed, 232 insertions(+), 51 deletions(-) create mode 100644 client/rpc/src/state/utils.rs diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 79cc0d7a16..21d213ffb1 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -303,17 +303,17 @@ pub trait AuxStore { } /// An `Iterator` that iterates keys in a given block under a prefix. -pub struct KeyIterator<'a, State, Block> { +pub struct KeyIterator { state: State, child_storage: Option, - prefix: Option<&'a StorageKey>, + prefix: Option, current_key: Vec, _phantom: PhantomData, } -impl<'a, State, Block> KeyIterator<'a, State, Block> { +impl KeyIterator { /// create a KeyIterator instance - pub fn new(state: State, prefix: Option<&'a StorageKey>, current_key: Vec) -> Self { + pub fn new(state: State, prefix: Option, current_key: Vec) -> Self { Self { state, child_storage: None, prefix, current_key, _phantom: PhantomData } } @@ -321,14 +321,14 @@ impl<'a, State, Block> KeyIterator<'a, State, Block> { pub fn new_child( state: State, child_info: ChildInfo, - prefix: Option<&'a StorageKey>, + prefix: Option, current_key: Vec, ) -> Self { Self { state, child_storage: Some(child_info), prefix, current_key, _phantom: PhantomData } } } -impl<'a, State, Block> Iterator for KeyIterator<'a, State, Block> +impl Iterator for KeyIterator where Block: BlockT, State: StateBackend>, @@ -344,7 +344,7 @@ where .ok() .flatten()?; // this terminates the iterator the first time it fails. - if let Some(prefix) = self.prefix { + if let Some(ref prefix) = self.prefix { if !next_key.starts_with(&prefix.0[..]) { return None } @@ -387,12 +387,12 @@ pub trait StorageProvider> { /// Given a block's `Hash` and a key prefix, return a `KeyIterator` iterates matching storage /// keys in that block. - fn storage_keys_iter<'a>( + fn storage_keys_iter( &self, hash: Block::Hash, - prefix: Option<&'a StorageKey>, + prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result>; + ) -> sp_blockchain::Result>; /// Given a block's `Hash`, a key and a child storage key, return the value under the key in /// that block. @@ -414,13 +414,13 @@ pub trait StorageProvider> { /// Given a block's `Hash` and a key `prefix` and a child storage key, /// return a `KeyIterator` that iterates matching storage keys in that block. - fn child_storage_keys_iter<'a>( + fn child_storage_keys_iter( &self, hash: Block::Hash, child_info: ChildInfo, - prefix: Option<&'a StorageKey>, + prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result>; + ) -> sp_blockchain::Result>; /// Given a block's `Hash`, a key and a child storage key, return the hash under the key in that /// block. diff --git a/client/rpc-api/src/state/mod.rs b/client/rpc-api/src/state/mod.rs index 40e208c2eb..323e6ad1d4 100644 --- a/client/rpc-api/src/state/mod.rs +++ b/client/rpc-api/src/state/mod.rs @@ -71,8 +71,8 @@ pub trait StateApi { fn storage_hash(&self, key: StorageKey, hash: Option) -> RpcResult>; /// Returns the size of a storage entry at a block's state. - #[method(name = "state_getStorageSize", aliases = ["state_getStorageSizeAt"], blocking)] - fn storage_size(&self, key: StorageKey, hash: Option) -> RpcResult>; + #[method(name = "state_getStorageSize", aliases = ["state_getStorageSizeAt"])] + async fn storage_size(&self, key: StorageKey, hash: Option) -> RpcResult>; /// Returns the runtime metadata as an opaque blob. #[method(name = "state_getMetadata", blocking)] diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index d97170ddf4..d39d8d8581 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -36,7 +36,7 @@ sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } sp-session = { version = "4.0.0-dev", path = "../../primitives/session" } sp-version = { version = "5.0.0", path = "../../primitives/version" } -tokio = { version = "1.22.0", optional = true } +tokio = "1.22.0" [dev-dependencies] env_logger = "0.9" @@ -51,4 +51,4 @@ sp-io = { version = "7.0.0", path = "../../primitives/io" } substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } [features] -test-helpers = ["tokio"] +test-helpers = [] diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index fd802e5a80..9ba4c8218d 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -19,6 +19,7 @@ //! Substrate state API. mod state_full; +mod utils; #[cfg(test)] mod tests; @@ -28,7 +29,7 @@ use std::sync::Arc; use crate::SubscriptionTaskExecutor; use jsonrpsee::{ - core::{server::rpc_module::SubscriptionSink, Error as JsonRpseeError, RpcResult}, + core::{async_trait, server::rpc_module::SubscriptionSink, Error as JsonRpseeError, RpcResult}, types::SubscriptionResult, }; @@ -53,6 +54,7 @@ use sp_blockchain::{HeaderBackend, HeaderMetadata}; const STORAGE_KEYS_PAGED_MAX_COUNT: u32 = 1000; /// State backend API. +#[async_trait] pub trait StateBackend: Send + Sync + 'static where Block: BlockT + 'static, @@ -107,10 +109,11 @@ where /// /// If data is available at `key`, it is returned. Else, the sum of values who's key has `key` /// prefix is returned, i.e. all the storage (double) maps that have this prefix. - fn storage_size( + async fn storage_size( &self, block: Option, key: StorageKey, + deny_unsafe: DenyUnsafe, ) -> Result, Error>; /// Returns the runtime metadata as an opaque blob. @@ -202,6 +205,7 @@ pub struct State { deny_unsafe: DenyUnsafe, } +#[async_trait] impl StateApiServer for State where Block: BlockT + 'static, @@ -262,8 +266,15 @@ where self.backend.storage_hash(block, key).map_err(Into::into) } - fn storage_size(&self, key: StorageKey, block: Option) -> RpcResult> { - self.backend.storage_size(block, key).map_err(Into::into) + async fn storage_size( + &self, + key: StorageKey, + block: Option, + ) -> RpcResult> { + self.backend + .storage_size(block, key, self.deny_unsafe) + .await + .map_err(Into::into) } fn metadata(&self, block: Option) -> RpcResult { diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index 58aeac66e5..d8fe39030a 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -18,17 +18,20 @@ //! State API backend for full nodes. -use std::{collections::HashMap, marker::PhantomData, sync::Arc}; +use std::{collections::HashMap, marker::PhantomData, sync::Arc, time::Duration}; use super::{ client_err, error::{Error, Result}, ChildStateBackend, StateBackend, }; -use crate::SubscriptionTaskExecutor; +use crate::{DenyUnsafe, SubscriptionTaskExecutor}; use futures::{future, stream, FutureExt, StreamExt}; -use jsonrpsee::{core::Error as JsonRpseeError, SubscriptionSink}; +use jsonrpsee::{ + core::{async_trait, Error as JsonRpseeError}, + SubscriptionSink, +}; use sc_client_api::{ Backend, BlockBackend, BlockchainEvents, CallExecutor, ExecutorProvider, ProofProvider, StorageProvider, @@ -48,6 +51,9 @@ use sp_core::{ use sp_runtime::{generic::BlockId, traits::Block as BlockT}; use sp_version::RuntimeVersion; +/// The maximum time allowed for an RPC call when running without unsafe RPC enabled. +const MAXIMUM_SAFE_RPC_CALL_TIMEOUT: Duration = Duration::from_secs(30); + /// Ranges to query in state_queryStorage. struct QueryStorageRange { /// Hashes of all the blocks in the range. @@ -166,6 +172,7 @@ where } } +#[async_trait] impl StateBackend for FullState where Block: BlockT + 'static, @@ -251,33 +258,53 @@ where .map_err(client_err) } - fn storage_size( + async fn storage_size( &self, block: Option, key: StorageKey, + deny_unsafe: DenyUnsafe, ) -> std::result::Result, Error> { let block = match self.block_or_best(block) { Ok(b) => b, Err(e) => return Err(client_err(e)), }; - match self.client.storage(block, &key) { - Ok(Some(d)) => return Ok(Some(d.0.len() as u64)), - Err(e) => return Err(client_err(e)), - Ok(None) => {}, - } + let client = self.client.clone(); + let timeout = match deny_unsafe { + DenyUnsafe::Yes => Some(MAXIMUM_SAFE_RPC_CALL_TIMEOUT), + DenyUnsafe::No => None, + }; - self.client - .storage_pairs(block, &key) - .map(|kv| { - let item_sum = kv.iter().map(|(_, v)| v.0.len() as u64).sum::(); - if item_sum > 0 { - Some(item_sum) - } else { - None - } - }) - .map_err(client_err) + super::utils::spawn_blocking_with_timeout(timeout, move |is_timed_out| { + // Does the key point to a concrete entry in the database? + match client.storage(block, &key) { + Ok(Some(d)) => return Ok(Ok(Some(d.0.len() as u64))), + Err(e) => return Ok(Err(client_err(e))), + Ok(None) => {}, + } + + // The key doesn't point to anything, so it's probably a prefix. + let iter = match client.storage_keys_iter(block, Some(&key), None).map_err(client_err) { + Ok(iter) => iter, + Err(e) => return Ok(Err(e)), + }; + + let mut sum = 0; + for storage_key in iter { + let value = client.storage(block, &storage_key).ok().flatten().unwrap_or_default(); + sum += value.0.len() as u64; + + is_timed_out.check_if_timed_out()?; + } + + if sum > 0 { + Ok(Ok(Some(sum))) + } else { + Ok(Ok(None)) + } + }) + .await + .map_err(|error| Error::Client(Box::new(error)))? } fn storage_hash( diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs index 3ef59e5ca9..fe8bdf0ac2 100644 --- a/client/rpc/src/state/tests.rs +++ b/client/rpc/src/state/tests.rs @@ -70,9 +70,12 @@ async fn should_return_storage() { client.storage_hash(key.clone(), Some(genesis_hash).into()).map(|x| x.is_some()), Ok(true) ); - assert_eq!(client.storage_size(key.clone(), None).unwrap().unwrap() as usize, VALUE.len(),); assert_eq!( - client.storage_size(StorageKey(b":map".to_vec()), None).unwrap().unwrap() as usize, + client.storage_size(key.clone(), None).await.unwrap().unwrap() as usize, + VALUE.len(), + ); + assert_eq!( + client.storage_size(StorageKey(b":map".to_vec()), None).await.unwrap().unwrap() as usize, 2 + 3, ); assert_eq!( diff --git a/client/rpc/src/state/utils.rs b/client/rpc/src/state/utils.rs new file mode 100644 index 0000000000..81476cdd34 --- /dev/null +++ b/client/rpc/src/state/utils.rs @@ -0,0 +1,140 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, + time::Duration, +}; + +/// An error signifying that a task has been cancelled due to a timeout. +#[derive(Debug)] +pub struct Timeout; + +impl std::error::Error for Timeout {} +impl std::fmt::Display for Timeout { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + fmt.write_str("task has been running too long") + } +} + +/// A handle which can be used to check whether the task has been cancelled due to a timeout. +#[repr(transparent)] +pub struct IsTimedOut(Arc); + +impl IsTimedOut { + #[must_use] + pub fn check_if_timed_out(&self) -> std::result::Result<(), Timeout> { + if self.0.load(Ordering::Relaxed) { + Err(Timeout) + } else { + Ok(()) + } + } +} + +/// An error for a task which either panicked, or has been cancelled due to a timeout. +#[derive(Debug)] +pub enum SpawnWithTimeoutError { + JoinError(tokio::task::JoinError), + Timeout, +} + +impl std::error::Error for SpawnWithTimeoutError {} +impl std::fmt::Display for SpawnWithTimeoutError { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + SpawnWithTimeoutError::JoinError(error) => error.fmt(fmt), + SpawnWithTimeoutError::Timeout => Timeout.fmt(fmt), + } + } +} + +struct CancelOnDrop(Arc); +impl Drop for CancelOnDrop { + fn drop(&mut self) { + self.0.store(true, Ordering::Relaxed) + } +} + +/// Spawns a new blocking task with a given `timeout`. +/// +/// The `callback` should continuously call [`IsTimedOut::check_if_timed_out`], +/// which will return an error once the task runs for longer than `timeout`. +/// +/// If `timeout` is `None` then this works just as a regular `spawn_blocking`. +pub async fn spawn_blocking_with_timeout( + timeout: Option, + callback: impl FnOnce(IsTimedOut) -> std::result::Result + Send + 'static, +) -> Result +where + R: Send + 'static, +{ + let is_timed_out_arc = Arc::new(AtomicBool::new(false)); + let is_timed_out = IsTimedOut(is_timed_out_arc.clone()); + let _cancel_on_drop = CancelOnDrop(is_timed_out_arc); + let task = tokio::task::spawn_blocking(move || callback(is_timed_out)); + + let result = if let Some(timeout) = timeout { + tokio::select! { + // Shouldn't really matter, but make sure the task is polled before the timeout, + // in case the task finishes after the timeout and the timeout is really short. + biased; + + task_result = task => task_result, + _ = tokio::time::sleep(timeout) => Ok(Err(Timeout)) + } + } else { + task.await + }; + + match result { + Ok(Ok(result)) => Ok(result), + Ok(Err(Timeout)) => Err(SpawnWithTimeoutError::Timeout), + Err(error) => Err(SpawnWithTimeoutError::JoinError(error)), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn spawn_blocking_with_timeout_works() { + let task: Result<(), SpawnWithTimeoutError> = + spawn_blocking_with_timeout(Some(Duration::from_millis(100)), |is_timed_out| { + std::thread::sleep(Duration::from_millis(200)); + is_timed_out.check_if_timed_out()?; + unreachable!(); + }) + .await; + + assert_matches::assert_matches!(task, Err(SpawnWithTimeoutError::Timeout)); + + let task = spawn_blocking_with_timeout(Some(Duration::from_millis(100)), |is_timed_out| { + std::thread::sleep(Duration::from_millis(20)); + is_timed_out.check_if_timed_out()?; + Ok(()) + }) + .await; + + assert_matches::assert_matches!(task, Ok(())); + } +} diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index 18012fc193..8e10a7b2ed 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -1432,27 +1432,27 @@ where Ok(keys) } - fn storage_keys_iter<'a>( + fn storage_keys_iter( &self, hash: ::Hash, - prefix: Option<&'a StorageKey>, + prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result> { + ) -> sp_blockchain::Result> { let state = self.state_at(hash)?; let start_key = start_key.or(prefix).map(|key| key.0.clone()).unwrap_or_else(Vec::new); - Ok(KeyIterator::new(state, prefix, start_key)) + Ok(KeyIterator::new(state, prefix.cloned(), start_key)) } - fn child_storage_keys_iter<'a>( + fn child_storage_keys_iter( &self, hash: ::Hash, child_info: ChildInfo, - prefix: Option<&'a StorageKey>, + prefix: Option<&StorageKey>, start_key: Option<&StorageKey>, - ) -> sp_blockchain::Result> { + ) -> sp_blockchain::Result> { let state = self.state_at(hash)?; let start_key = start_key.or(prefix).map(|key| key.0.clone()).unwrap_or_else(Vec::new); - Ok(KeyIterator::new_child(state, child_info, prefix, start_key)) + Ok(KeyIterator::new_child(state, child_info, prefix.cloned(), start_key)) } fn storage( From a447f03727ffd84020682f3e0e4044d5d282d274 Mon Sep 17 00:00:00 2001 From: Sasha Gryaznov Date: Wed, 18 Jan 2023 12:36:09 +0200 Subject: [PATCH 23/80] [contracts] Adapt storage reading host functions to Weights V2 (#12976) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update RuntimeCosts to Weights V2, update tests * improve docs * clearer naming and docs to compat_weight helper * Apply suggestions from code review Co-authored-by: Alexander Theißen * save before master merge * HostFnWeights to Weight * added to_weight! macro * Apply suggestions from code review Co-authored-by: Alexander Theißen * RuntimeCosts::ChainExtension to weight_v2 * chain extension to weight v2 Co-authored-by: Alexander Theißen --- frame/contracts/proc-macro/src/lib.rs | 14 +- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/contracts/src/chain_extension.rs | 7 +- frame/contracts/src/gas.rs | 4 +- frame/contracts/src/lib.rs | 22 +- frame/contracts/src/schedule.rs | 278 +++++++++++++----------- frame/contracts/src/tests.rs | 4 +- frame/contracts/src/wasm/mod.rs | 2 +- frame/contracts/src/wasm/runtime.rs | 10 +- 9 files changed, 189 insertions(+), 154 deletions(-) diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index a31d39f47e..d0247d720a 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -122,23 +122,23 @@ fn iterate_fields(data: &syn::DataStruct, fmt: impl Fn(&Ident) -> TokenStream2) fn format_weight(field: &Ident) -> TokenStream2 { quote_spanned! { field.span() => - &if self.#field > 1_000_000_000 { + &if self.#field.ref_time() > 1_000_000_000 { format!( "{:.1?} ms", - Fixed::saturating_from_rational(self.#field, 1_000_000_000).to_float() + Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000_000).to_float() ) - } else if self.#field > 1_000_000 { + } else if self.#field.ref_time() > 1_000_000 { format!( "{:.1?} µs", - Fixed::saturating_from_rational(self.#field, 1_000_000).to_float() + Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000).to_float() ) - } else if self.#field > 1_000 { + } else if self.#field.ref_time() > 1_000 { format!( "{:.1?} ns", - Fixed::saturating_from_rational(self.#field, 1_000).to_float() + Fixed::saturating_from_rational(self.#field.ref_time(), 1_000).to_float() ) } else { - format!("{} ps", self.#field) + format!("{} ps", self.#field.ref_time()) } } } diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index d46da8469e..a750a6b172 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -2928,7 +2928,7 @@ benchmarks! { // configured `Schedule` during benchmark development. // It can be outputed using the following command: // cargo run --manifest-path=bin/node/cli/Cargo.toml --release \ - // --features runtime-benchmarks -- benchmark --extra --dev --execution=native \ + // --features runtime-benchmarks -- benchmark pallet --extra --dev --execution=native \ // -p pallet_contracts -e print_schedule --no-median-slopes --no-min-squares #[extra] print_schedule { diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index dfa9c7c2de..3974bdba30 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -227,7 +227,7 @@ impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> { /// /// Weight is synonymous with gas in substrate. pub fn charge_weight(&mut self, amount: Weight) -> Result { - self.inner.runtime.charge_gas(RuntimeCosts::ChainExtension(amount.ref_time())) + self.inner.runtime.charge_gas(RuntimeCosts::ChainExtension(amount)) } /// Adjust a previously charged amount down to its actual amount. @@ -237,7 +237,7 @@ impl<'a, 'b, E: Ext, S: State> Environment<'a, 'b, E, S> { pub fn adjust_weight(&mut self, charged: ChargedAmount, actual_weight: Weight) { self.inner .runtime - .adjust_gas(charged, RuntimeCosts::ChainExtension(actual_weight.ref_time())) + .adjust_gas(charged, RuntimeCosts::ChainExtension(actual_weight)) } /// Grants access to the execution environment of the current contract call. @@ -408,8 +408,7 @@ impl<'a, 'b, E: Ext, S: BufOut> Environment<'a, 'b, E, S> { buffer, allow_skip, |len| { - weight_per_byte - .map(|w| RuntimeCosts::ChainExtension(w.ref_time().saturating_mul(len.into()))) + weight_per_byte.map(|w| RuntimeCosts::ChainExtension(w.saturating_mul(len.into()))) }, ) } diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index ccbe680b2f..c8383f307c 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -153,8 +153,8 @@ impl GasMeter { /// Returns `OutOfGas` if there is not enough gas or addition of the specified /// amount of gas has lead to overflow. On success returns `Proceed`. /// - /// NOTE that amount is always consumed, i.e. if there is not enough gas - /// then the counter will be set to zero. + /// NOTE that amount isn't consumed if there is not enough gas. This is considered + /// safe because we always charge gas before performing any resource-spending action. #[inline] pub fn charge>(&mut self, token: Tok) -> Result { #[cfg(test)] diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 9efeec65f5..581798e448 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -381,7 +381,7 @@ pub mod pallet { { /// Deprecated version if [`Self::call`] for use in an in-storage `Call`. #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::call().saturating_add(>::compat_weight(*gas_limit)))] + #[pallet::weight(T::WeightInfo::call().saturating_add(>::compat_weight_limit(*gas_limit)))] #[allow(deprecated)] #[deprecated(note = "1D weight is used in this extrinsic, please migrate to `call`")] pub fn call_old_weight( @@ -396,7 +396,7 @@ pub mod pallet { origin, dest, value, - >::compat_weight(gas_limit), + >::compat_weight_limit(gas_limit), storage_deposit_limit, data, ) @@ -406,7 +406,7 @@ pub mod pallet { #[pallet::call_index(1)] #[pallet::weight( T::WeightInfo::instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32) - .saturating_add(>::compat_weight(*gas_limit)) + .saturating_add(>::compat_weight_limit(*gas_limit)) )] #[allow(deprecated)] #[deprecated( @@ -424,7 +424,7 @@ pub mod pallet { Self::instantiate_with_code( origin, value, - >::compat_weight(gas_limit), + >::compat_weight_limit(gas_limit), storage_deposit_limit, code, data, @@ -435,7 +435,7 @@ pub mod pallet { /// Deprecated version if [`Self::instantiate`] for use in an in-storage `Call`. #[pallet::call_index(2)] #[pallet::weight( - T::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(>::compat_weight(*gas_limit)) + T::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(>::compat_weight_limit(*gas_limit)) )] #[allow(deprecated)] #[deprecated(note = "1D weight is used in this extrinsic, please migrate to `instantiate`")] @@ -451,7 +451,7 @@ pub mod pallet { Self::instantiate( origin, value, - >::compat_weight(gas_limit), + >::compat_weight_limit(gas_limit), storage_deposit_limit, code_hash, data, @@ -1216,12 +1216,12 @@ impl Pallet { >>::minimum_balance() } - /// Convert a 1D Weight to a 2D weight. + /// Convert gas_limit from 1D Weight to a 2D Weight. /// - /// Used by backwards compatible extrinsics. We cannot just set the proof to zero - /// or an old `Call` will just fail. - fn compat_weight(gas_limit: OldWeight) -> Weight { - Weight::from(gas_limit).set_proof_size(u64::from(T::MaxCodeLen::get()) * 2) + /// Used by backwards compatible extrinsics. We cannot just set the proof_size weight limit to + /// zero or an old `Call` will just fail with OutOfGas. + fn compat_weight_limit(gas_limit: OldWeight) -> Weight { + Weight::from_parts(gas_limit.0, u64::from(T::MaxCodeLen::get()) * 2) } } diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index 912e58b048..dabdc70135 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -21,7 +21,7 @@ use crate::{wasm::Determinism, weights::WeightInfo, Config}; use codec::{Decode, Encode}; -use frame_support::DefaultNoBound; +use frame_support::{weights::Weight, DefaultNoBound}; use pallet_contracts_proc_macro::{ScheduleDebug, WeightDebug}; use scale_info::TypeInfo; #[cfg(feature = "std")] @@ -169,7 +169,7 @@ impl Limits { /// that use them as supporting instructions. Supporting means mainly pushing arguments /// and dropping return values in order to maintain a valid module. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Clone, Encode, Decode, PartialEq, Eq, WeightDebug, TypeInfo)] +#[derive(Clone, Encode, Decode, PartialEq, Eq, ScheduleDebug, TypeInfo)] #[scale_info(skip_type_params(T))] pub struct InstructionWeights { /// Version of the instruction weights. @@ -255,178 +255,178 @@ pub struct InstructionWeights { #[scale_info(skip_type_params(T))] pub struct HostFnWeights { /// Weight of calling `seal_caller`. - pub caller: u64, + pub caller: Weight, /// Weight of calling `seal_is_contract`. - pub is_contract: u64, + pub is_contract: Weight, /// Weight of calling `seal_code_hash`. - pub code_hash: u64, + pub code_hash: Weight, /// Weight of calling `seal_own_code_hash`. - pub own_code_hash: u64, + pub own_code_hash: Weight, /// Weight of calling `seal_caller_is_origin`. - pub caller_is_origin: u64, + pub caller_is_origin: Weight, /// Weight of calling `seal_address`. - pub address: u64, + pub address: Weight, /// Weight of calling `seal_gas_left`. - pub gas_left: u64, + pub gas_left: Weight, /// Weight of calling `seal_balance`. - pub balance: u64, + pub balance: Weight, /// Weight of calling `seal_value_transferred`. - pub value_transferred: u64, + pub value_transferred: Weight, /// Weight of calling `seal_minimum_balance`. - pub minimum_balance: u64, + pub minimum_balance: Weight, /// Weight of calling `seal_block_number`. - pub block_number: u64, + pub block_number: Weight, /// Weight of calling `seal_now`. - pub now: u64, + pub now: Weight, /// Weight of calling `seal_weight_to_fee`. - pub weight_to_fee: u64, + pub weight_to_fee: Weight, /// Weight of calling `gas`. - pub gas: u64, + pub gas: Weight, /// Weight of calling `seal_input`. - pub input: u64, + pub input: Weight, /// Weight per input byte copied to contract memory by `seal_input`. - pub input_per_byte: u64, + pub input_per_byte: Weight, /// Weight of calling `seal_return`. - pub r#return: u64, + pub r#return: Weight, /// Weight per byte returned through `seal_return`. - pub return_per_byte: u64, + pub return_per_byte: Weight, /// Weight of calling `seal_terminate`. - pub terminate: u64, + pub terminate: Weight, /// Weight of calling `seal_random`. - pub random: u64, + pub random: Weight, /// Weight of calling `seal_reposit_event`. - pub deposit_event: u64, + pub deposit_event: Weight, /// Weight per topic supplied to `seal_deposit_event`. - pub deposit_event_per_topic: u64, + pub deposit_event_per_topic: Weight, /// Weight per byte of an event deposited through `seal_deposit_event`. - pub deposit_event_per_byte: u64, + pub deposit_event_per_byte: Weight, /// Weight of calling `seal_debug_message`. - pub debug_message: u64, + pub debug_message: Weight, /// Weight of calling `seal_set_storage`. - pub set_storage: u64, + pub set_storage: Weight, /// Weight per written byten of an item stored with `seal_set_storage`. - pub set_storage_per_new_byte: u64, + pub set_storage_per_new_byte: Weight, /// Weight per overwritten byte of an item stored with `seal_set_storage`. - pub set_storage_per_old_byte: u64, + pub set_storage_per_old_byte: Weight, /// Weight of calling `seal_set_code_hash`. - pub set_code_hash: u64, + pub set_code_hash: Weight, /// Weight of calling `seal_clear_storage`. - pub clear_storage: u64, + pub clear_storage: Weight, /// Weight of calling `seal_clear_storage` per byte of the stored item. - pub clear_storage_per_byte: u64, + pub clear_storage_per_byte: Weight, /// Weight of calling `seal_contains_storage`. - pub contains_storage: u64, + pub contains_storage: Weight, /// Weight of calling `seal_contains_storage` per byte of the stored item. - pub contains_storage_per_byte: u64, + pub contains_storage_per_byte: Weight, /// Weight of calling `seal_get_storage`. - pub get_storage: u64, + pub get_storage: Weight, /// Weight per byte of an item received via `seal_get_storage`. - pub get_storage_per_byte: u64, + pub get_storage_per_byte: Weight, /// Weight of calling `seal_take_storage`. - pub take_storage: u64, + pub take_storage: Weight, /// Weight per byte of an item received via `seal_take_storage`. - pub take_storage_per_byte: u64, + pub take_storage_per_byte: Weight, /// Weight of calling `seal_transfer`. - pub transfer: u64, + pub transfer: Weight, /// Weight of calling `seal_call`. - pub call: u64, + pub call: Weight, /// Weight of calling `seal_delegate_call`. - pub delegate_call: u64, + pub delegate_call: Weight, /// Weight surcharge that is claimed if `seal_call` does a balance transfer. - pub call_transfer_surcharge: u64, + pub call_transfer_surcharge: Weight, /// Weight per byte that is cloned by supplying the `CLONE_INPUT` flag. - pub call_per_cloned_byte: u64, + pub call_per_cloned_byte: Weight, /// Weight of calling `seal_instantiate`. - pub instantiate: u64, + pub instantiate: Weight, /// Weight surcharge that is claimed if `seal_instantiate` does a balance transfer. - pub instantiate_transfer_surcharge: u64, + pub instantiate_transfer_surcharge: Weight, /// Weight per input byte supplied to `seal_instantiate`. - pub instantiate_per_input_byte: u64, + pub instantiate_per_input_byte: Weight, /// Weight per salt byte supplied to `seal_instantiate`. - pub instantiate_per_salt_byte: u64, + pub instantiate_per_salt_byte: Weight, /// Weight of calling `seal_hash_sha_256`. - pub hash_sha2_256: u64, + pub hash_sha2_256: Weight, /// Weight per byte hashed by `seal_hash_sha_256`. - pub hash_sha2_256_per_byte: u64, + pub hash_sha2_256_per_byte: Weight, /// Weight of calling `seal_hash_keccak_256`. - pub hash_keccak_256: u64, + pub hash_keccak_256: Weight, /// Weight per byte hashed by `seal_hash_keccak_256`. - pub hash_keccak_256_per_byte: u64, + pub hash_keccak_256_per_byte: Weight, /// Weight of calling `seal_hash_blake2_256`. - pub hash_blake2_256: u64, + pub hash_blake2_256: Weight, /// Weight per byte hashed by `seal_hash_blake2_256`. - pub hash_blake2_256_per_byte: u64, + pub hash_blake2_256_per_byte: Weight, /// Weight of calling `seal_hash_blake2_128`. - pub hash_blake2_128: u64, + pub hash_blake2_128: Weight, /// Weight per byte hashed by `seal_hash_blake2_128`. - pub hash_blake2_128_per_byte: u64, + pub hash_blake2_128_per_byte: Weight, /// Weight of calling `seal_ecdsa_recover`. - pub ecdsa_recover: u64, + pub ecdsa_recover: Weight, /// Weight of calling `seal_ecdsa_to_eth_address`. - pub ecdsa_to_eth_address: u64, + pub ecdsa_to_eth_address: Weight, /// Weight of calling `reentrance_count`. - pub reentrance_count: u64, + pub reentrance_count: Weight, /// Weight of calling `account_reentrance_count`. - pub account_reentrance_count: u64, + pub account_reentrance_count: Weight, /// Weight of calling `instantiation_nonce`. - pub instantiation_nonce: u64, + pub instantiation_nonce: Weight, /// The type parameter is used in the default implementation. #[codec(skip)] @@ -514,6 +514,12 @@ macro_rules! cost_byte_batched { }; } +macro_rules! to_weight { + ($ref_time:expr $(, $proof_size:expr )?) => { + Weight::from_ref_time($ref_time)$(.set_proof_size($proof_size))? + }; +} + impl Default for Limits { fn default() -> Self { Self { @@ -596,85 +602,115 @@ impl Default for InstructionWeights { } impl Default for HostFnWeights { + /// PoV should contain all trie nodes that are read during state transition (i.e. block + /// production). Hence we need to charge the `proof_size` weight for every host function which + /// reads storage, namely: + /// - get_storage, + /// - take_storage, + /// - contains_storage, + /// - clear_storage, + /// - set_storage. + /// + /// The last two functions write to storage, but they also do read storage in order to return + /// the size of the pre-existed value. Till we have PoV benchmarks implemented, we approximate + /// `proof_size` as being equal to the size of storage read. fn default() -> Self { Self { - caller: cost_batched!(seal_caller), - is_contract: cost_batched!(seal_is_contract), - code_hash: cost_batched!(seal_code_hash), - own_code_hash: cost_batched!(seal_own_code_hash), - caller_is_origin: cost_batched!(seal_caller_is_origin), - address: cost_batched!(seal_address), - gas_left: cost_batched!(seal_gas_left), - balance: cost_batched!(seal_balance), - value_transferred: cost_batched!(seal_value_transferred), - minimum_balance: cost_batched!(seal_minimum_balance), - block_number: cost_batched!(seal_block_number), - now: cost_batched!(seal_now), - weight_to_fee: cost_batched!(seal_weight_to_fee), - gas: cost_batched!(seal_gas), - input: cost_batched!(seal_input), - input_per_byte: cost_byte_batched!(seal_input_per_kb), - r#return: cost!(seal_return), - return_per_byte: cost_byte!(seal_return_per_kb), - terminate: cost!(seal_terminate), - random: cost_batched!(seal_random), - deposit_event: cost_batched!(seal_deposit_event), - deposit_event_per_topic: cost_batched_args!(seal_deposit_event_per_topic_and_kb, 1, 0), - deposit_event_per_byte: cost_byte_batched_args!( + caller: to_weight!(cost_batched!(seal_caller)), + is_contract: to_weight!(cost_batched!(seal_is_contract)), + code_hash: to_weight!(cost_batched!(seal_code_hash)), + own_code_hash: to_weight!(cost_batched!(seal_own_code_hash)), + caller_is_origin: to_weight!(cost_batched!(seal_caller_is_origin)), + address: to_weight!(cost_batched!(seal_address)), + gas_left: to_weight!(cost_batched!(seal_gas_left)), + balance: to_weight!(cost_batched!(seal_balance)), + value_transferred: to_weight!(cost_batched!(seal_value_transferred)), + minimum_balance: to_weight!(cost_batched!(seal_minimum_balance)), + block_number: to_weight!(cost_batched!(seal_block_number)), + now: to_weight!(cost_batched!(seal_now)), + weight_to_fee: to_weight!(cost_batched!(seal_weight_to_fee)), + gas: to_weight!(cost_batched!(seal_gas)), + input: to_weight!(cost_batched!(seal_input)), + input_per_byte: to_weight!(cost_byte_batched!(seal_input_per_kb)), + r#return: to_weight!(cost!(seal_return)), + return_per_byte: to_weight!(cost_byte!(seal_return_per_kb)), + terminate: to_weight!(cost!(seal_terminate)), + random: to_weight!(cost_batched!(seal_random)), + deposit_event: to_weight!(cost_batched!(seal_deposit_event)), + deposit_event_per_topic: to_weight!(cost_batched_args!( + seal_deposit_event_per_topic_and_kb, + 1, + 0 + )), + deposit_event_per_byte: to_weight!(cost_byte_batched_args!( seal_deposit_event_per_topic_and_kb, 0, 1 + )), + debug_message: to_weight!(cost_batched!(seal_debug_message)), + set_storage: to_weight!(cost_batched!(seal_set_storage)), + set_code_hash: to_weight!(cost_batched!(seal_set_code_hash)), + set_storage_per_new_byte: to_weight!(cost_byte_batched!(seal_set_storage_per_new_kb)), + set_storage_per_old_byte: to_weight!( + cost_byte_batched!(seal_set_storage_per_old_kb), + 1u64 ), - debug_message: cost_batched!(seal_debug_message), - set_storage: cost_batched!(seal_set_storage), - set_code_hash: cost_batched!(seal_set_code_hash), - set_storage_per_new_byte: cost_byte_batched!(seal_set_storage_per_new_kb), - set_storage_per_old_byte: cost_byte_batched!(seal_set_storage_per_old_kb), - clear_storage: cost_batched!(seal_clear_storage), - clear_storage_per_byte: cost_byte_batched!(seal_clear_storage_per_kb), - contains_storage: cost_batched!(seal_contains_storage), - contains_storage_per_byte: cost_byte_batched!(seal_contains_storage_per_kb), - get_storage: cost_batched!(seal_get_storage), - get_storage_per_byte: cost_byte_batched!(seal_get_storage_per_kb), - take_storage: cost_batched!(seal_take_storage), - take_storage_per_byte: cost_byte_batched!(seal_take_storage_per_kb), - transfer: cost_batched!(seal_transfer), - call: cost_batched!(seal_call), - delegate_call: cost_batched!(seal_delegate_call), - call_transfer_surcharge: cost_batched_args!(seal_call_per_transfer_clone_kb, 1, 0), - call_per_cloned_byte: cost_batched_args!(seal_call_per_transfer_clone_kb, 0, 1), - instantiate: cost_batched!(seal_instantiate), - instantiate_transfer_surcharge: cost_byte_batched_args!( + clear_storage: to_weight!(cost_batched!(seal_clear_storage)), + clear_storage_per_byte: to_weight!(cost_byte_batched!(seal_clear_storage_per_kb), 1u64), + contains_storage: to_weight!(cost_batched!(seal_contains_storage)), + contains_storage_per_byte: to_weight!( + cost_byte_batched!(seal_contains_storage_per_kb), + 1u64 + ), + get_storage: to_weight!(cost_batched!(seal_get_storage)), + get_storage_per_byte: to_weight!(cost_byte_batched!(seal_get_storage_per_kb), 1u64), + take_storage: to_weight!(cost_batched!(seal_take_storage)), + take_storage_per_byte: to_weight!(cost_byte_batched!(seal_take_storage_per_kb), 1u64), + transfer: to_weight!(cost_batched!(seal_transfer)), + call: to_weight!(cost_batched!(seal_call)), + delegate_call: to_weight!(cost_batched!(seal_delegate_call)), + call_transfer_surcharge: to_weight!(cost_batched_args!( + seal_call_per_transfer_clone_kb, + 1, + 0 + )), + call_per_cloned_byte: to_weight!(cost_batched_args!( + seal_call_per_transfer_clone_kb, + 0, + 1 + )), + instantiate: to_weight!(cost_batched!(seal_instantiate)), + instantiate_transfer_surcharge: to_weight!(cost_byte_batched_args!( seal_instantiate_per_transfer_input_salt_kb, 1, 0, 0 - ), - instantiate_per_input_byte: cost_byte_batched_args!( + )), + instantiate_per_input_byte: to_weight!(cost_byte_batched_args!( seal_instantiate_per_transfer_input_salt_kb, 0, 1, 0 - ), - instantiate_per_salt_byte: cost_byte_batched_args!( + )), + instantiate_per_salt_byte: to_weight!(cost_byte_batched_args!( seal_instantiate_per_transfer_input_salt_kb, 0, 0, 1 - ), - hash_sha2_256: cost_batched!(seal_hash_sha2_256), - hash_sha2_256_per_byte: cost_byte_batched!(seal_hash_sha2_256_per_kb), - hash_keccak_256: cost_batched!(seal_hash_keccak_256), - hash_keccak_256_per_byte: cost_byte_batched!(seal_hash_keccak_256_per_kb), - hash_blake2_256: cost_batched!(seal_hash_blake2_256), - hash_blake2_256_per_byte: cost_byte_batched!(seal_hash_blake2_256_per_kb), - hash_blake2_128: cost_batched!(seal_hash_blake2_128), - hash_blake2_128_per_byte: cost_byte_batched!(seal_hash_blake2_128_per_kb), - ecdsa_recover: cost_batched!(seal_ecdsa_recover), - ecdsa_to_eth_address: cost_batched!(seal_ecdsa_to_eth_address), - reentrance_count: cost_batched!(seal_reentrance_count), - account_reentrance_count: cost_batched!(seal_account_reentrance_count), - instantiation_nonce: cost_batched!(seal_instantiation_nonce), + )), + hash_sha2_256: to_weight!(cost_batched!(seal_hash_sha2_256)), + hash_sha2_256_per_byte: to_weight!(cost_byte_batched!(seal_hash_sha2_256_per_kb)), + hash_keccak_256: to_weight!(cost_batched!(seal_hash_keccak_256)), + hash_keccak_256_per_byte: to_weight!(cost_byte_batched!(seal_hash_keccak_256_per_kb)), + hash_blake2_256: to_weight!(cost_batched!(seal_hash_blake2_256)), + hash_blake2_256_per_byte: to_weight!(cost_byte_batched!(seal_hash_blake2_256_per_kb)), + hash_blake2_128: to_weight!(cost_batched!(seal_hash_blake2_128)), + hash_blake2_128_per_byte: to_weight!(cost_byte_batched!(seal_hash_blake2_128_per_kb)), + ecdsa_recover: to_weight!(cost_batched!(seal_ecdsa_recover)), + ecdsa_to_eth_address: to_weight!(cost_batched!(seal_ecdsa_to_eth_address)), + reentrance_count: to_weight!(cost_batched!(seal_reentrance_count)), + account_reentrance_count: to_weight!(cost_batched!(seal_account_reentrance_count)), + instantiation_nonce: to_weight!(cost_batched!(seal_instantiation_nonce)), _phantom: PhantomData, } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 7a0736d1ed..b9462ce45e 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -416,7 +416,7 @@ pub const BOB: AccountId32 = AccountId32::new([2u8; 32]); pub const CHARLIE: AccountId32 = AccountId32::new([3u8; 32]); pub const DJANGO: AccountId32 = AccountId32::new([4u8; 32]); -pub const GAS_LIMIT: Weight = Weight::from_ref_time(100_000_000_000).set_proof_size(256 * 1024); +pub const GAS_LIMIT: Weight = Weight::from_parts(100_000_000_000, 512 * 1024); pub struct ExtBuilder { existential_deposit: u64, @@ -2837,7 +2837,7 @@ fn gas_estimation_call_runtime() { let call = RuntimeCall::Contracts(crate::Call::call { dest: addr_callee, value: 0, - gas_limit: GAS_LIMIT.set_ref_time(GAS_LIMIT.ref_time() / 3), + gas_limit: GAS_LIMIT / 3, storage_deposit_limit: None, data: vec![], }); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index b540b3deb4..c2b0611769 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -430,7 +430,7 @@ mod tests { events: Default::default(), runtime_calls: Default::default(), schedule: Default::default(), - gas_meter: GasMeter::new(Weight::from_ref_time(10_000_000_000)), + gas_meter: GasMeter::new(Weight::from_parts(10_000_000_000, 10 * 1024 * 1024)), debug_buffer: Default::default(), ecdsa_recover: Default::default(), } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index b5398bb620..745583b337 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -253,7 +253,7 @@ pub enum RuntimeCosts { /// Weight of calling `seal_ecdsa_recover`. EcdsaRecovery, /// Weight charged by a chain extension through `seal_call_chain_extension`. - ChainExtension(u64), + ChainExtension(Weight), /// Weight charged for calling into the runtime. CallRuntime(Weight), /// Weight of calling `seal_set_code_hash` @@ -272,7 +272,7 @@ impl RuntimeCosts { fn token(&self, s: &HostFnWeights) -> RuntimeToken { use self::RuntimeCosts::*; let weight = match *self { - MeteringBlock(amount) => s.gas.saturating_add(amount), + MeteringBlock(amount) => s.gas.saturating_add(Weight::from_ref_time(amount)), CopyFromContract(len) => s.return_per_byte.saturating_mul(len.into()), CopyToContract(len) => s.input_per_byte.saturating_mul(len.into()), Caller => s.caller, @@ -335,8 +335,8 @@ impl RuntimeCosts { .hash_blake2_128 .saturating_add(s.hash_blake2_128_per_byte.saturating_mul(len.into())), EcdsaRecovery => s.ecdsa_recover, - ChainExtension(amount) => amount, - CallRuntime(weight) => weight.ref_time(), + ChainExtension(weight) => weight, + CallRuntime(weight) => weight, SetCodeHash => s.set_code_hash, EcdsaToEthAddress => s.ecdsa_to_eth_address, ReentrantCount => s.reentrance_count, @@ -346,7 +346,7 @@ impl RuntimeCosts { RuntimeToken { #[cfg(test)] _created_from: *self, - weight: Weight::from_ref_time(weight), + weight, } } } From af5a499a269542cfd7f1aef415c801575f083d4a Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:26:12 +0100 Subject: [PATCH 24/80] zobmienet tests are not supposed to fail (#13015) * zobmienet tests are not supposed to fail * Update scripts/ci/gitlab/pipeline/zombienet.yml Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> --- scripts/ci/gitlab/pipeline/zombienet.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/ci/gitlab/pipeline/zombienet.yml b/scripts/ci/gitlab/pipeline/zombienet.yml index 8d772ff51f..7dc98c0068 100644 --- a/scripts/ci/gitlab/pipeline/zombienet.yml +++ b/scripts/ci/gitlab/pipeline/zombienet.yml @@ -30,7 +30,6 @@ after_script: - mkdir -p ./zombienet-logs - cp /tmp/zombie*/logs/* ./zombienet-logs/ - allow_failure: true retry: 2 tags: - zombienet-polkadot-integration-test From cba59778aa5207b11f7513e5cbb127ea47dd8924 Mon Sep 17 00:00:00 2001 From: Sasha Gryaznov Date: Wed, 18 Jan 2023 18:03:52 +0200 Subject: [PATCH 25/80] [contracts] Add integrity checks by pallet hook (#12993) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * integrity test for MaxCodeLen and CallStack::len() * integrity test for MaxDebugBufferLen * addressed review comments * fix append_debug_buffer() * ci fix * updated code_len_limit formula after further discussion * enlarged mem safe margin after discussion * +doc to Config trait associated types * Apply suggestions from code review Co-authored-by: Alexander Theißen * more lil fixes from code review feedback * lowered max call depth to satisfy mem limits * fix node runtime pallet params to satisfy integrity check * fix max call depth value calc Co-authored-by: Alexander Theißen --- bin/node/runtime/src/lib.rs | 4 +- frame/contracts/src/exec.rs | 24 ++++++----- frame/contracts/src/lib.rs | 75 ++++++++++++++++++++++++++++++++- frame/contracts/src/schedule.rs | 4 -- frame/contracts/src/tests.rs | 4 +- 5 files changed, 91 insertions(+), 20 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fb5da9749a..0ac6ade912 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1206,7 +1206,7 @@ impl pallet_contracts::Config for Runtime { type CallFilter = Nothing; type DepositPerItem = DepositPerItem; type DepositPerByte = DepositPerByte; - type CallStack = [pallet_contracts::Frame; 31]; + type CallStack = [pallet_contracts::Frame; 5]; type WeightPrice = pallet_transaction_payment::Pallet; type WeightInfo = pallet_contracts::weights::SubstrateWeight; type ChainExtension = (); @@ -1214,7 +1214,7 @@ impl pallet_contracts::Config for Runtime { type DeletionWeightLimit = DeletionWeightLimit; type Schedule = Schedule; type AddressGenerator = pallet_contracts::DefaultAddressGenerator; - type MaxCodeLen = ConstU32<{ 128 * 1024 }>; + type MaxCodeLen = ConstU32<{ 123 * 1024 }>; type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = ConstBool; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 8ae70b804d..b5b6306536 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1336,7 +1336,18 @@ where fn append_debug_buffer(&mut self, msg: &str) -> bool { if let Some(buffer) = &mut self.debug_message { - let mut msg = msg.bytes(); + let err_msg = scale_info::prelude::format!( + "Debug message too big (size={}) for debug buffer (bound={})", + msg.len(), + DebugBufferVec::::bound(), + ); + + let mut msg = if msg.len() > DebugBufferVec::::bound() { + err_msg.bytes() + } else { + msg.bytes() + }; + let num_drain = { let capacity = DebugBufferVec::::bound().checked_sub(buffer.len()).expect( " @@ -1349,16 +1360,7 @@ where msg.len().saturating_sub(capacity).min(buffer.len()) }; buffer.drain(0..num_drain); - buffer - .try_extend(&mut msg) - .map_err(|_| { - log::debug!( - target: "runtime::contracts", - "Debug message to big (size={}) for debug buffer (bound={})", - msg.len(), DebugBufferVec::::bound(), - ); - }) - .ok(); + buffer.try_extend(&mut msg).ok(); true } else { false diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 581798e448..672c4517d0 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -123,6 +123,7 @@ use pallet_contracts_primitives::{ StorageDeposit, }; use scale_info::TypeInfo; +use smallvec::Array; use sp_runtime::traits::{Convert, Hash, Saturating, StaticLookup, TrailingZeroInput}; use sp_std::{fmt::Debug, marker::PhantomData, prelude::*}; @@ -272,7 +273,10 @@ pub mod pallet { /// The allowed depth is `CallStack::size() + 1`. /// Therefore a size of `0` means that a contract cannot use call or instantiate. /// In other words only the origin called "root contract" is allowed to execute then. - type CallStack: smallvec::Array>; + /// + /// This setting along with [`MaxCodeLen`](#associatedtype.MaxCodeLen) directly affects + /// memory usage of your runtime. + type CallStack: Array>; /// The maximum number of contracts that can be pending for deletion. /// @@ -323,6 +327,10 @@ pub mod pallet { /// The maximum length of a contract code in bytes. This limit applies to the instrumented /// version of the code. Therefore `instantiate_with_code` can fail even when supplying /// a wasm binary below this maximum size. + /// + /// The value should be chosen carefully taking into the account the overall memory limit + /// your runtime has, as well as the [maximum allowed callstack + /// depth](#associatedtype.CallStack). Look into the `integrity_test()` for some insights. #[pallet::constant] type MaxCodeLen: Get; @@ -372,6 +380,71 @@ pub mod pallet { T::WeightInfo::on_process_deletion_queue_batch() } } + + fn integrity_test() { + // Total runtime memory is expected to have 128Mb upper limit + const MAX_RUNTIME_MEM: u32 = 1024 * 1024 * 128; + // Memory limits for a single contract: + // Value stack size: 1Mb per contract, default defined in wasmi + const MAX_STACK_SIZE: u32 = 1024 * 1024; + // Heap limit is normally 16 mempages of 64kb each = 1Mb per contract + let max_heap_size = T::Schedule::get().limits.max_memory_size(); + // Max call depth is CallStack::size() + 1 + let max_call_depth = u32::try_from(T::CallStack::size().saturating_add(1)) + .expect("CallStack size is too big"); + + // Check that given configured `MaxCodeLen`, runtime heap memory limit can't be broken. + // + // In worst case, the decoded wasm contract code would be `x16` times larger than the + // encoded one. This is because even a single-byte wasm instruction has 16-byte size in + // wasmi. This gives us `MaxCodeLen*16` safety margin. + // + // Next, the pallet keeps both the original and instrumented wasm blobs for each + // contract, hence we add up `MaxCodeLen*2` more to the safety margin. + // + // Finally, the inefficiencies of the freeing-bump allocator + // being used in the client for the runtime memory allocations, could lead to possible + // memory allocations for contract code grow up to `x4` times in some extreme cases, + // which gives us total multiplier of `18*4` for `MaxCodeLen`. + // + // That being said, for every contract executed in runtime, at least `MaxCodeLen*18*4` + // memory should be available. Note that maximum allowed heap memory and stack size per + // each contract (stack frame) should also be counted. + // + // Finally, we allow 50% of the runtime memory to be utilized by the contracts call + // stack, keeping the rest for other facilities, such as PoV, etc. + // + // This gives us the following formula: + // + // `(MaxCodeLen * 18 * 4 + MAX_STACK_SIZE + max_heap_size) * max_call_depth < + // MAX_RUNTIME_MEM/2` + // + // Hence the upper limit for the `MaxCodeLen` can be defined as follows: + let code_len_limit = MAX_RUNTIME_MEM + .saturating_div(2) + .saturating_div(max_call_depth) + .saturating_sub(max_heap_size) + .saturating_sub(MAX_STACK_SIZE) + .saturating_div(18 * 4); + + assert!( + T::MaxCodeLen::get() < code_len_limit, + "Given `CallStack` height {:?}, `MaxCodeLen` should be set less than {:?} \ + (current value is {:?}), to avoid possible runtime oom issues.", + max_call_depth, + code_len_limit, + T::MaxCodeLen::get(), + ); + + // Debug buffer should at least be large enough to accomodate a simple error message + const MIN_DEBUG_BUF_SIZE: u32 = 256; + assert!( + T::MaxDebugBufferLen::get() > MIN_DEBUG_BUF_SIZE, + "Debug buffer should have minimum size of {} (current setting is {})", + MIN_DEBUG_BUF_SIZE, + T::MaxDebugBufferLen::get(), + ) + } } #[pallet::call] diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index dabdc70135..eabd18c818 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -134,9 +134,6 @@ pub struct Limits { /// The maximum length of a subject in bytes used for PRNG generation. pub subject_len: u32, - /// The maximum nesting level of the call stack. - pub call_depth: u32, - /// The maximum size of a storage value and event payload in bytes. pub payload_len: u32, } @@ -532,7 +529,6 @@ impl Default for Limits { table_size: 4096, br_table_size: 256, subject_len: 32, - call_depth: 32, payload_len: 16 * 1024, } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index b9462ce45e..ce84da743d 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -394,7 +394,7 @@ impl Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; - type CallStack = [Frame; 31]; + type CallStack = [Frame; 5]; type WeightPrice = Self; type WeightInfo = (); type ChainExtension = @@ -405,7 +405,7 @@ impl Config for Test { type DepositPerByte = DepositPerByte; type DepositPerItem = DepositPerItem; type AddressGenerator = DefaultAddressGenerator; - type MaxCodeLen = ConstU32<{ 128 * 1024 }>; + type MaxCodeLen = ConstU32<{ 123 * 1024 }>; type MaxStorageKeyLen = ConstU32<128>; type UnsafeUnstableInterface = UnstableInterface; type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; From 911c9ab067d3cf487cfef61906ed2525cb87a5c9 Mon Sep 17 00:00:00 2001 From: Tsvetomir Dimitrov Date: Thu, 19 Jan 2023 13:32:50 +0200 Subject: [PATCH 26/80] Expose `UnknownBlock` error via `ApiError` (#12707) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Expose `UnknownBlock` error via `ApiError` In [certain cases](https://github.com/paritytech/polkadot/issues/5885) a runtime api is called for an unknown block. For example a block which is already pruned or on an abandon fork. In such cases the correct error is returned but it is wrapped in `ApiError::Application` and the only way to figure out what is the problem is to inspect the actual message in the error. In polkadot for example this usually happens when the runtime api version is being queried. It's beneficial to be able to clearly separate such errors so i that when they occur the client side can handle them more gracefully. E.g. log less stressful error message than `State already discarded for BlockId` or cancel any pending work related on this block. * Update primitives/api/src/lib.rs Co-authored-by: Bastian Köcher Co-authored-by: Bastian Köcher --- primitives/api/src/lib.rs | 2 ++ primitives/blockchain/src/error.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/primitives/api/src/lib.rs b/primitives/api/src/lib.rs index 91d4b07a1c..4ff4becb80 100644 --- a/primitives/api/src/lib.rs +++ b/primitives/api/src/lib.rs @@ -519,6 +519,8 @@ pub enum ApiError { StateBackendIsNotTrie, #[error(transparent)] Application(#[from] Box), + #[error("Api called for an unknown Block: {0}")] + UnknownBlock(String), } /// Extends the runtime api implementation with some common functionality. diff --git a/primitives/blockchain/src/error.rs b/primitives/blockchain/src/error.rs index 783c40c406..6585cc54f1 100644 --- a/primitives/blockchain/src/error.rs +++ b/primitives/blockchain/src/error.rs @@ -191,6 +191,7 @@ impl From> for Error { impl From for ApiError { fn from(err: Error) -> ApiError { match err { + Error::UnknownBlock(msg) => ApiError::UnknownBlock(msg), Error::RuntimeApiError(err) => err, e => ApiError::Application(Box::new(e)), } From d4384f242f48fd62516aac02c3f18b5a8c9e5793 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Thu, 19 Jan 2023 16:13:16 +0100 Subject: [PATCH 27/80] Notification-based block pinning (#13157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Worker * Reorganize and unpin onnotification drop * Pin in state-db, pass block number * Pin blocks in blockchain db * Switch to reference counted LRU * Disable pinning when we keep all blocks * Fix pinning hint for state-db * Remove pinning from backend layer * Improve readability * Add justifications to test * Fix justification behaviour * Remove debug prints * Convert channels to tracing_unbounded * Add comments to the test * Documentation and Cleanup * Move task start to client * Simplify cache * Improve test, remove unwanted log * Add tracing logs, remove expect for block number * Cleanup * Add conversion method for unpin handle to Finalitynotification * Revert unwanted changes * Improve naming * Make clippy happy * Fix docs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> * Use `NumberFor` instead of u64 in API * Hand over weak reference to unpin worker task * Unwanted * &Hash -> Hash * Remove number from interface, rename `_unpin_handle`, LOG_TARGET * Move RwLock one layer up * Apply code style suggestions * Improve comments * Replace lru crate by schnellru * Only insert values for pinned items + better docs * Apply suggestions from code review Co-authored-by: Bastian Köcher * Improve comments, log target and test Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Bastian Köcher --- Cargo.lock | 52 +- client/api/src/backend.rs | 22 +- client/api/src/client.rs | 109 +++- client/api/src/in_mem.rs | 6 + client/db/Cargo.toml | 1 + client/db/src/lib.rs | 531 ++++++++++++++++-- client/db/src/pinned_blocks_cache.rs | 231 ++++++++ client/finality-grandpa/src/until_imported.rs | 13 +- client/service/src/builder.rs | 4 +- client/service/src/client/client.rs | 77 ++- test-utils/client/src/lib.rs | 7 +- 11 files changed, 954 insertions(+), 99 deletions(-) create mode 100644 client/db/src/pinned_blocks_cache.rs diff --git a/Cargo.lock b/Cargo.lock index 4466382772..100e0d2152 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -137,6 +137,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" +dependencies = [ + "cfg-if", + "getrandom 0.2.8", + "once_cell", + "version_check", +] + [[package]] name = "aho-corasick" version = "0.7.20" @@ -1836,7 +1848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek 3.2.0", - "hashbrown", + "hashbrown 0.12.3", "hex", "rand_core 0.6.4", "sha2 0.9.9", @@ -2806,9 +2818,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", ] +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + [[package]] name = "heck" version = "0.4.0" @@ -3122,7 +3140,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] @@ -4172,7 +4190,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -4310,7 +4328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66" dependencies = [ "hash-db", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -5085,7 +5103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown", + "hashbrown 0.12.3", "indexmap", "memchr", ] @@ -7991,6 +8009,7 @@ dependencies = [ "rand 0.8.5", "sc-client-api", "sc-state-db", + "schnellru", "sp-arithmetic", "sp-blockchain", "sp-core", @@ -8334,7 +8353,7 @@ dependencies = [ name = "sc-finality-grandpa" version = "0.10.0-dev" dependencies = [ - "ahash", + "ahash 0.7.6", "array-bytes", "assert_matches", "async-trait", @@ -8534,7 +8553,7 @@ dependencies = [ name = "sc-network-gossip" version = "0.10.0-dev" dependencies = [ - "ahash", + "ahash 0.7.6", "futures", "futures-timer", "libp2p", @@ -9132,6 +9151,17 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "schnellru" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" +dependencies = [ + "ahash 0.8.2", + "cfg-if", + "hashbrown 0.13.2", +] + [[package]] name = "schnorrkel" version = "0.9.1" @@ -10275,11 +10305,11 @@ dependencies = [ name = "sp-trie" version = "7.0.0" dependencies = [ - "ahash", + "ahash 0.7.6", "array-bytes", "criterion", "hash-db", - "hashbrown", + "hashbrown 0.12.3", "lazy_static", "lru", "memory-db", @@ -11279,7 +11309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" dependencies = [ "hash-db", - "hashbrown", + "hashbrown 0.12.3", "log", "rustc-hex", "smallvec", diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 21d213ffb1..4ef609bdd4 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -436,12 +436,24 @@ pub trait StorageProvider> { /// /// Manages the data layer. /// -/// Note on state pruning: while an object from `state_at` is alive, the state +/// # State Pruning +/// +/// While an object from `state_at` is alive, the state /// should not be pruned. The backend should internally reference-count /// its state objects. /// /// The same applies for live `BlockImportOperation`s: while an import operation building on a /// parent `P` is alive, the state for `P` should not be pruned. +/// +/// # Block Pruning +/// +/// Users can pin blocks in memory by calling `pin_block`. When +/// a block would be pruned, its value is kept in an in-memory cache +/// until it is unpinned via `unpin_block`. +/// +/// While a block is pinned, its state is also preserved. +/// +/// The backend should internally reference count the number of pin / unpin calls. pub trait Backend: AuxStore + Send + Sync { /// Associated block insertion operation type. type BlockImportOperation: BlockImportOperation; @@ -502,6 +514,14 @@ pub trait Backend: AuxStore + Send + Sync { /// Returns a handle to offchain storage. fn offchain_storage(&self) -> Option; + /// Pin the block to keep body, justification and state available after pruning. + /// Number of pins are reference counted. Users need to make sure to perform + /// one call to [`Self::unpin_block`] per call to [`Self::pin_block`]. + fn pin_block(&self, hash: Block::Hash) -> sp_blockchain::Result<()>; + + /// Unpin the block to allow pruning. + fn unpin_block(&self, hash: Block::Hash); + /// Returns true if state for given block is available. fn have_state_at(&self, hash: Block::Hash, _number: NumberFor) -> bool { self.state_at(hash).is_ok() diff --git a/client/api/src/client.rs b/client/api/src/client.rs index 0d00257fa7..8e7ceb6870 100644 --- a/client/api/src/client.rs +++ b/client/api/src/client.rs @@ -30,7 +30,7 @@ use std::{collections::HashSet, fmt, sync::Arc}; use crate::{blockchain::Info, notifications::StorageEventStream, FinalizeSummary, ImportSummary}; use sc_transaction_pool_api::ChainEvent; -use sc_utils::mpsc::TracingUnboundedReceiver; +use sc_utils::mpsc::{TracingUnboundedReceiver, TracingUnboundedSender}; use sp_blockchain; /// Type that implements `futures::Stream` of block import events. @@ -264,6 +264,53 @@ impl fmt::Display for UsageInfo { } } +/// Sends a message to the pinning-worker once dropped to unpin a block in the backend. +#[derive(Debug)] +pub struct UnpinHandleInner { + /// Hash of the block pinned by this handle + hash: Block::Hash, + unpin_worker_sender: TracingUnboundedSender, +} + +impl UnpinHandleInner { + /// Create a new [`UnpinHandleInner`] + pub fn new( + hash: Block::Hash, + unpin_worker_sender: TracingUnboundedSender, + ) -> Self { + Self { hash, unpin_worker_sender } + } +} + +impl Drop for UnpinHandleInner { + fn drop(&mut self) { + if let Err(err) = self.unpin_worker_sender.unbounded_send(self.hash) { + log::debug!(target: "db", "Unable to unpin block with hash: {}, error: {:?}", self.hash, err); + }; + } +} + +/// Keeps a specific block pinned while the handle is alive. +/// Once the last handle instance for a given block is dropped, the +/// block is unpinned in the [`Backend`](crate::backend::Backend::unpin_block). +#[derive(Debug, Clone)] +pub struct UnpinHandle(Arc>); + +impl UnpinHandle { + /// Create a new [`UnpinHandle`] + pub fn new( + hash: Block::Hash, + unpin_worker_sender: TracingUnboundedSender, + ) -> UnpinHandle { + UnpinHandle(Arc::new(UnpinHandleInner::new(hash, unpin_worker_sender))) + } + + /// Hash of the block this handle is unpinning on drop + pub fn hash(&self) -> Block::Hash { + self.0.hash + } +} + /// Summary of an imported block #[derive(Clone, Debug)] pub struct BlockImportNotification { @@ -279,6 +326,36 @@ pub struct BlockImportNotification { /// /// If `None`, there was no re-org while importing. pub tree_route: Option>>, + /// Handle to unpin the block this notification is for + unpin_handle: UnpinHandle, +} + +impl BlockImportNotification { + /// Create new notification + pub fn new( + hash: Block::Hash, + origin: BlockOrigin, + header: Block::Header, + is_new_best: bool, + tree_route: Option>>, + unpin_worker_sender: TracingUnboundedSender, + ) -> Self { + Self { + hash, + origin, + header, + is_new_best, + tree_route, + unpin_handle: UnpinHandle::new(hash, unpin_worker_sender), + } + } + + /// Consume this notification and extract the unpin handle. + /// + /// Note: Only use this if you want to keep the block pinned in the backend. + pub fn into_unpin_handle(self) -> UnpinHandle { + self.unpin_handle + } } /// Summary of a finalized block. @@ -294,6 +371,8 @@ pub struct FinalityNotification { pub tree_route: Arc<[Block::Hash]>, /// Stale branches heads. pub stale_heads: Arc<[Block::Hash]>, + /// Handle to unpin the block this notification is for + unpin_handle: UnpinHandle, } impl TryFrom> for ChainEvent { @@ -314,26 +393,44 @@ impl From> for ChainEvent { } } -impl From> for FinalityNotification { - fn from(mut summary: FinalizeSummary) -> Self { +impl FinalityNotification { + /// Create finality notification from finality summary. + pub fn from_summary( + mut summary: FinalizeSummary, + unpin_worker_sender: TracingUnboundedSender, + ) -> FinalityNotification { let hash = summary.finalized.pop().unwrap_or_default(); FinalityNotification { hash, header: summary.header, tree_route: Arc::from(summary.finalized), stale_heads: Arc::from(summary.stale_heads), + unpin_handle: UnpinHandle::new(hash, unpin_worker_sender), } } + + /// Consume this notification and extract the unpin handle. + /// + /// Note: Only use this if you want to keep the block pinned in the backend. + pub fn into_unpin_handle(self) -> UnpinHandle { + self.unpin_handle + } } -impl From> for BlockImportNotification { - fn from(summary: ImportSummary) -> Self { +impl BlockImportNotification { + /// Create finality notification from finality summary. + pub fn from_summary( + summary: ImportSummary, + unpin_worker_sender: TracingUnboundedSender, + ) -> BlockImportNotification { + let hash = summary.hash; BlockImportNotification { - hash: summary.hash, + hash, origin: summary.origin, header: summary.header, is_new_best: summary.is_new_best, tree_route: summary.tree_route.map(Arc::new), + unpin_handle: UnpinHandle::new(hash, unpin_worker_sender), } } } diff --git a/client/api/src/in_mem.rs b/client/api/src/in_mem.rs index 144aa352f5..5e82757e7d 100644 --- a/client/api/src/in_mem.rs +++ b/client/api/src/in_mem.rs @@ -788,6 +788,12 @@ where fn requires_full_sync(&self) -> bool { false } + + fn pin_block(&self, _: ::Hash) -> blockchain::Result<()> { + Ok(()) + } + + fn unpin_block(&self, _: ::Hash) {} } impl backend::LocalBackend for Backend where Block::Hash: Ord {} diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 562a94f190..2d7291a014 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -26,6 +26,7 @@ parity-db = "0.4.2" parking_lot = "0.12.1" sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-state-db = { version = "0.10.0-dev", path = "../state-db" } +schnellru = "0.2.1" sp-arithmetic = { version = "6.0.0", path = "../../primitives/arithmetic" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-core = { version = "7.0.0", path = "../../primitives/core" } diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 99fa786e04..09ccfef1cc 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -34,6 +34,7 @@ pub mod bench; mod children; mod parity_db; +mod pinned_blocks_cache; mod record_stats_state; mod stats; #[cfg(any(feature = "rocksdb", test))] @@ -51,6 +52,7 @@ use std::{ }; use crate::{ + pinned_blocks_cache::PinnedBlocksCache, record_stats_state::RecordStatsState, stats::StateUsageStats, utils::{meta_keys, read_db, read_meta, DatabaseType, Meta}, @@ -481,6 +483,7 @@ pub struct BlockchainDb { leaves: RwLock>>, header_metadata_cache: Arc>, header_cache: Mutex>>, + pinned_blocks_cache: Arc>>, } impl BlockchainDb { @@ -493,6 +496,7 @@ impl BlockchainDb { meta: Arc::new(RwLock::new(meta)), header_metadata_cache: Arc::new(HeaderMetadataCache::default()), header_cache: Default::default(), + pinned_blocks_cache: Arc::new(RwLock::new(PinnedBlocksCache::new())), }) } @@ -521,62 +525,83 @@ impl BlockchainDb { let mut meta = self.meta.write(); meta.block_gap = gap; } -} -impl sc_client_api::blockchain::HeaderBackend for BlockchainDb { - fn header(&self, hash: Block::Hash) -> ClientResult> { - let mut cache = self.header_cache.lock(); - if let Some(result) = cache.get_refresh(&hash) { - return Ok(result.clone()) + /// Empty the cache of pinned items. + fn clear_pinning_cache(&self) { + self.pinned_blocks_cache.write().clear(); + } + + /// Load a justification into the cache of pinned items. + /// Reference count of the item will not be increased. Use this + /// to load values for items into the cache which have already been pinned. + fn insert_justifications_if_pinned(&self, hash: Block::Hash, justification: Justification) { + let mut cache = self.pinned_blocks_cache.write(); + if !cache.contains(hash) { + return } - let header = utils::read_header( - &*self.db, - columns::KEY_LOOKUP, - columns::HEADER, - BlockId::::Hash(hash), - )?; - cache_header(&mut cache, hash, header.clone()); - Ok(header) + + let justifications = Justifications::from(justification); + cache.insert_justifications(hash, Some(justifications)); } - fn info(&self) -> sc_client_api::blockchain::Info { - let meta = self.meta.read(); - sc_client_api::blockchain::Info { - best_hash: meta.best_hash, - best_number: meta.best_number, - genesis_hash: meta.genesis_hash, - finalized_hash: meta.finalized_hash, - finalized_number: meta.finalized_number, - finalized_state: meta.finalized_state, - number_leaves: self.leaves.read().count(), - block_gap: meta.block_gap, + /// Load a justification from the db into the cache of pinned items. + /// Reference count of the item will not be increased. Use this + /// to load values for items into the cache which have already been pinned. + fn insert_persisted_justifications_if_pinned(&self, hash: Block::Hash) -> ClientResult<()> { + let mut cache = self.pinned_blocks_cache.write(); + if !cache.contains(hash) { + return Ok(()) } + + let justifications = self.justifications_uncached(hash)?; + cache.insert_justifications(hash, justifications); + Ok(()) } - fn status(&self, hash: Block::Hash) -> ClientResult { - match self.header(hash)?.is_some() { - true => Ok(sc_client_api::blockchain::BlockStatus::InChain), - false => Ok(sc_client_api::blockchain::BlockStatus::Unknown), + /// Load a block body from the db into the cache of pinned items. + /// Reference count of the item will not be increased. Use this + /// to load values for items items into the cache which have already been pinned. + fn insert_persisted_body_if_pinned(&self, hash: Block::Hash) -> ClientResult<()> { + let mut cache = self.pinned_blocks_cache.write(); + if !cache.contains(hash) { + return Ok(()) } + + let body = self.body_uncached(hash)?; + cache.insert_body(hash, body); + Ok(()) } - fn number(&self, hash: Block::Hash) -> ClientResult>> { - Ok(self.header_metadata(hash).ok().map(|header_metadata| header_metadata.number)) + /// Bump reference count for pinned item. + fn bump_ref(&self, hash: Block::Hash) { + self.pinned_blocks_cache.write().pin(hash); } - fn hash(&self, number: NumberFor) -> ClientResult> { - Ok(utils::read_header::( + /// Decrease reference count for pinned item and remove if reference count is 0. + fn unpin(&self, hash: Block::Hash) { + self.pinned_blocks_cache.write().unpin(hash); + } + + fn justifications_uncached(&self, hash: Block::Hash) -> ClientResult> { + match read_db( &*self.db, columns::KEY_LOOKUP, - columns::HEADER, - BlockId::Number(number), - )? - .map(|header| header.hash())) + columns::JUSTIFICATIONS, + BlockId::::Hash(hash), + )? { + Some(justifications) => match Decode::decode(&mut &justifications[..]) { + Ok(justifications) => Ok(Some(justifications)), + Err(err) => + return Err(sp_blockchain::Error::Backend(format!( + "Error decoding justifications: {}", + err + ))), + }, + None => Ok(None), + } } -} -impl sc_client_api::blockchain::Backend for BlockchainDb { - fn body(&self, hash: Block::Hash) -> ClientResult>> { + fn body_uncached(&self, hash: Block::Hash) -> ClientResult>> { if let Some(body) = read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, BlockId::Hash::(hash))? { @@ -640,24 +665,77 @@ impl sc_client_api::blockchain::Backend for BlockchainDb ClientResult> { - match read_db( +impl sc_client_api::blockchain::HeaderBackend for BlockchainDb { + fn header(&self, hash: Block::Hash) -> ClientResult> { + let mut cache = self.header_cache.lock(); + if let Some(result) = cache.get_refresh(&hash) { + return Ok(result.clone()) + } + let header = utils::read_header( &*self.db, columns::KEY_LOOKUP, - columns::JUSTIFICATIONS, + columns::HEADER, BlockId::::Hash(hash), - )? { - Some(justifications) => match Decode::decode(&mut &justifications[..]) { - Ok(justifications) => Ok(Some(justifications)), - Err(err) => - return Err(sp_blockchain::Error::Backend(format!( - "Error decoding justifications: {}", - err - ))), - }, - None => Ok(None), + )?; + cache_header(&mut cache, hash, header.clone()); + Ok(header) + } + + fn info(&self) -> sc_client_api::blockchain::Info { + let meta = self.meta.read(); + sc_client_api::blockchain::Info { + best_hash: meta.best_hash, + best_number: meta.best_number, + genesis_hash: meta.genesis_hash, + finalized_hash: meta.finalized_hash, + finalized_number: meta.finalized_number, + finalized_state: meta.finalized_state, + number_leaves: self.leaves.read().count(), + block_gap: meta.block_gap, + } + } + + fn status(&self, hash: Block::Hash) -> ClientResult { + match self.header(hash)?.is_some() { + true => Ok(sc_client_api::blockchain::BlockStatus::InChain), + false => Ok(sc_client_api::blockchain::BlockStatus::Unknown), + } + } + + fn number(&self, hash: Block::Hash) -> ClientResult>> { + Ok(self.header_metadata(hash).ok().map(|header_metadata| header_metadata.number)) + } + + fn hash(&self, number: NumberFor) -> ClientResult> { + Ok(utils::read_header::( + &*self.db, + columns::KEY_LOOKUP, + columns::HEADER, + BlockId::Number(number), + )? + .map(|header| header.hash())) + } +} + +impl sc_client_api::blockchain::Backend for BlockchainDb { + fn body(&self, hash: Block::Hash) -> ClientResult>> { + let cache = self.pinned_blocks_cache.read(); + if let Some(result) = cache.body(&hash) { + return Ok(result.clone()) + } + + self.body_uncached(hash) + } + + fn justifications(&self, hash: Block::Hash) -> ClientResult> { + let cache = self.pinned_blocks_cache.read(); + if let Some(result) = cache.justifications(&hash) { + return Ok(result.clone()) } + + self.justifications_uncached(hash) } fn last_finalized(&self) -> ClientResult { @@ -1291,20 +1369,28 @@ impl Backend { header: &Block::Header, last_finalized: Option, justification: Option, + current_transaction_justifications: &mut HashMap, ) -> ClientResult> { // TODO: ensure best chain contains this block. let number = *header.number(); self.ensure_sequential_finalization(header, last_finalized)?; let with_state = sc_client_api::Backend::have_state_at(self, hash, number); - self.note_finalized(transaction, header, hash, with_state)?; + self.note_finalized( + transaction, + header, + hash, + with_state, + current_transaction_justifications, + )?; if let Some(justification) = justification { transaction.set_from_vec( columns::JUSTIFICATIONS, &utils::number_and_hash_to_lookup_key(number, hash)?, - Justifications::from(justification).encode(), + Justifications::from(justification.clone()).encode(), ); + current_transaction_justifications.insert(hash, justification); } Ok(MetaUpdate { hash, number, is_best: false, is_finalized: true, with_state }) } @@ -1371,6 +1457,8 @@ impl Backend { (meta.best_number, meta.finalized_hash, meta.finalized_number, meta.block_gap) }; + let mut current_transaction_justifications: HashMap = + HashMap::new(); for (block_hash, justification) in operation.finalized_blocks { let block_header = self.blockchain.expect_header(block_hash)?; meta_updates.push(self.finalize_block_with_transaction( @@ -1379,6 +1467,7 @@ impl Backend { &block_header, Some(last_finalized_hash), justification, + &mut current_transaction_justifications, )?); last_finalized_hash = block_hash; last_finalized_num = *block_header.number(); @@ -1551,7 +1640,14 @@ impl Backend { if finalized { // TODO: ensure best chain contains this block. self.ensure_sequential_finalization(header, Some(last_finalized_hash))?; - self.note_finalized(&mut transaction, header, hash, operation.commit_state)?; + let mut current_transaction_justifications = HashMap::new(); + self.note_finalized( + &mut transaction, + header, + hash, + operation.commit_state, + &mut current_transaction_justifications, + )?; } else { // canonicalize blocks which are old enough, regardless of finality. self.force_delayed_canonicalize(&mut transaction)? @@ -1684,6 +1780,7 @@ impl Backend { f_header: &Block::Header, f_hash: Block::Hash, with_state: bool, + current_transaction_justifications: &mut HashMap, ) -> ClientResult<()> { let f_num = *f_header.number(); @@ -1709,7 +1806,7 @@ impl Backend { } let new_displaced = self.blockchain.leaves.write().finalize_height(f_num); - self.prune_blocks(transaction, f_num, &new_displaced)?; + self.prune_blocks(transaction, f_num, &new_displaced, current_transaction_justifications)?; Ok(()) } @@ -1717,22 +1814,39 @@ impl Backend { fn prune_blocks( &self, transaction: &mut Transaction, - finalized: NumberFor, + finalized_number: NumberFor, displaced: &FinalizationOutcome>, + current_transaction_justifications: &mut HashMap, ) -> ClientResult<()> { match self.blocks_pruning { BlocksPruning::KeepAll => {}, BlocksPruning::Some(blocks_pruning) => { // Always keep the last finalized block let keep = std::cmp::max(blocks_pruning, 1); - if finalized >= keep.into() { - let number = finalized.saturating_sub(keep.into()); + if finalized_number >= keep.into() { + let number = finalized_number.saturating_sub(keep.into()); + + // Before we prune a block, check if it is pinned + if let Some(hash) = self.blockchain.hash(number)? { + self.blockchain.insert_persisted_body_if_pinned(hash)?; + + // If the block was finalized in this transaction, it will not be in the db + // yet. + if let Some(justification) = + current_transaction_justifications.remove(&hash) + { + self.blockchain.insert_justifications_if_pinned(hash, justification); + } else { + self.blockchain.insert_persisted_justifications_if_pinned(hash)?; + } + }; + self.prune_block(transaction, BlockId::::number(number))?; } - self.prune_displaced_branches(transaction, finalized, displaced)?; + self.prune_displaced_branches(transaction, finalized_number, displaced)?; }, BlocksPruning::KeepFinalized => { - self.prune_displaced_branches(transaction, finalized, displaced)?; + self.prune_displaced_branches(transaction, finalized_number, displaced)?; }, } Ok(()) @@ -1755,6 +1869,8 @@ impl Backend { while self.blockchain.hash(number)? != Some(hash) { match self.blockchain.header(hash)? { Some(header) => { + self.blockchain.insert_persisted_body_if_pinned(hash)?; + self.prune_block(transaction, BlockId::::hash(hash))?; number = header.number().saturating_sub(One::one()); hash = *header.parent_hash(); @@ -1985,6 +2101,7 @@ impl sc_client_api::backend::Backend for Backend { .state_db .reset(state_meta_db) .map_err(sp_blockchain::Error::from_state_db)?; + self.blockchain.clear_pinning_cache(); Err(e) } else { self.storage.state_db.sync(); @@ -2000,12 +2117,14 @@ impl sc_client_api::backend::Backend for Backend { let mut transaction = Transaction::new(); let header = self.blockchain.expect_header(hash)?; + let mut current_transaction_justifications = HashMap::new(); let m = self.finalize_block_with_transaction( &mut transaction, hash, &header, None, justification, + &mut current_transaction_justifications, )?; self.storage.db.commit(transaction)?; @@ -2382,6 +2501,49 @@ impl sc_client_api::backend::Backend for Backend { PruningMode::ArchiveAll | PruningMode::ArchiveCanonical ) } + + fn pin_block(&self, hash: ::Hash) -> sp_blockchain::Result<()> { + let hint = || { + let header_metadata = self.blockchain.header_metadata(hash); + header_metadata + .map(|hdr| { + sc_state_db::NodeDb::get(self.storage.as_ref(), hdr.state_root.as_ref()) + .unwrap_or(None) + .is_some() + }) + .unwrap_or(false) + }; + + if let Some(number) = self.blockchain.number(hash)? { + self.storage.state_db.pin(&hash, number.saturated_into::(), hint).map_err( + |_| { + sp_blockchain::Error::UnknownBlock(format!( + "State already discarded for `{:?}`", + hash + )) + }, + )?; + } else { + return Err(ClientError::UnknownBlock(format!( + "Can not pin block with hash `{:?}`. Block not found.", + hash + ))) + } + + if self.blocks_pruning != BlocksPruning::KeepAll { + // Only increase reference count for this hash. Value is loaded once we prune. + self.blockchain.bump_ref(hash); + } + Ok(()) + } + + fn unpin_block(&self, hash: ::Hash) { + self.storage.state_db.unpin(&hash); + + if self.blocks_pruning != BlocksPruning::KeepAll { + self.blockchain.unpin(hash); + } + } } impl sc_client_api::backend::LocalBackend for Backend {} @@ -4009,4 +4171,249 @@ pub(crate) mod tests { assert_eq!(block4, backend.blockchain().hash(4).unwrap().unwrap()); } } + + #[test] + fn test_pinned_blocks_on_finalize() { + let backend = Backend::::new_test_with_tx_storage(BlocksPruning::Some(1), 10); + let mut blocks = Vec::new(); + let mut prev_hash = Default::default(); + + let build_justification = |i: u64| ([0, 0, 0, 0], vec![i.try_into().unwrap()]); + // Block tree: + // 0 -> 1 -> 2 -> 3 -> 4 + for i in 0..5 { + let hash = insert_block( + &backend, + i, + prev_hash, + None, + Default::default(), + vec![i.into()], + None, + ) + .unwrap(); + blocks.push(hash); + // Avoid block pruning. + backend.pin_block(blocks[i as usize]).unwrap(); + + prev_hash = hash; + } + + let bc = backend.blockchain(); + + // Check that we can properly access values when there is reference count + // but no value. + assert_eq!(Some(vec![1.into()]), bc.body(blocks[1]).unwrap()); + + // Block 1 gets pinned three times + backend.pin_block(blocks[1]).unwrap(); + backend.pin_block(blocks[1]).unwrap(); + + // Finalize all blocks. This will trigger pruning. + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, blocks[4]).unwrap(); + for i in 1..5 { + op.mark_finalized(blocks[i], Some(build_justification(i.try_into().unwrap()))) + .unwrap(); + } + backend.commit_operation(op).unwrap(); + + // Block 0, 1, 2, 3 are pinned, so all values should be cached. + // Block 4 is inside the pruning window, its value is in db. + assert_eq!(Some(vec![0.into()]), bc.body(blocks[0]).unwrap()); + + assert_eq!(Some(vec![1.into()]), bc.body(blocks[1]).unwrap()); + assert_eq!( + Some(Justifications::from(build_justification(1))), + bc.justifications(blocks[1]).unwrap() + ); + + assert_eq!(Some(vec![2.into()]), bc.body(blocks[2]).unwrap()); + assert_eq!( + Some(Justifications::from(build_justification(2))), + bc.justifications(blocks[2]).unwrap() + ); + + assert_eq!(Some(vec![3.into()]), bc.body(blocks[3]).unwrap()); + assert_eq!( + Some(Justifications::from(build_justification(3))), + bc.justifications(blocks[3]).unwrap() + ); + + assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap()); + assert_eq!( + Some(Justifications::from(build_justification(4))), + bc.justifications(blocks[4]).unwrap() + ); + + // Unpin all blocks. Values should be removed from cache. + for block in &blocks { + backend.unpin_block(*block); + } + + assert!(bc.body(blocks[0]).unwrap().is_none()); + // Block 1 was pinned twice, we expect it to be still cached + assert!(bc.body(blocks[1]).unwrap().is_some()); + assert!(bc.justifications(blocks[1]).unwrap().is_some()); + // Headers should also be available while pinned + assert!(bc.header(blocks[1]).ok().flatten().is_some()); + assert!(bc.body(blocks[2]).unwrap().is_none()); + assert!(bc.justifications(blocks[2]).unwrap().is_none()); + assert!(bc.body(blocks[3]).unwrap().is_none()); + assert!(bc.justifications(blocks[3]).unwrap().is_none()); + + // After these unpins, block 1 should also be removed + backend.unpin_block(blocks[1]); + assert!(bc.body(blocks[1]).unwrap().is_some()); + assert!(bc.justifications(blocks[1]).unwrap().is_some()); + backend.unpin_block(blocks[1]); + assert!(bc.body(blocks[1]).unwrap().is_none()); + assert!(bc.justifications(blocks[1]).unwrap().is_none()); + + // Block 4 is inside the pruning window and still kept + assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap()); + assert_eq!( + Some(Justifications::from(build_justification(4))), + bc.justifications(blocks[4]).unwrap() + ); + + // Block tree: + // 0 -> 1 -> 2 -> 3 -> 4 -> 5 + let hash = + insert_block(&backend, 5, prev_hash, None, Default::default(), vec![5.into()], None) + .unwrap(); + blocks.push(hash); + + backend.pin_block(blocks[4]).unwrap(); + // Mark block 5 as finalized. + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, blocks[5]).unwrap(); + op.mark_finalized(blocks[5], Some(build_justification(5))).unwrap(); + backend.commit_operation(op).unwrap(); + + assert!(bc.body(blocks[0]).unwrap().is_none()); + assert!(bc.body(blocks[1]).unwrap().is_none()); + assert!(bc.body(blocks[2]).unwrap().is_none()); + assert!(bc.body(blocks[3]).unwrap().is_none()); + + assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap()); + assert_eq!( + Some(Justifications::from(build_justification(4))), + bc.justifications(blocks[4]).unwrap() + ); + assert_eq!(Some(vec![5.into()]), bc.body(blocks[5]).unwrap()); + assert!(bc.header(blocks[5]).ok().flatten().is_some()); + + backend.unpin_block(blocks[4]); + assert!(bc.body(blocks[4]).unwrap().is_none()); + assert!(bc.justifications(blocks[4]).unwrap().is_none()); + + // Append a justification to block 5. + backend.append_justification(blocks[5], ([0, 0, 0, 1], vec![42])).unwrap(); + + let hash = + insert_block(&backend, 6, blocks[5], None, Default::default(), vec![6.into()], None) + .unwrap(); + blocks.push(hash); + + // Pin block 5 so it gets loaded into the cache on prune + backend.pin_block(blocks[5]).unwrap(); + + // Finalize block 6 so block 5 gets pruned. Since it is pinned both justifications should be + // in memory. + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, blocks[6]).unwrap(); + op.mark_finalized(blocks[6], None).unwrap(); + backend.commit_operation(op).unwrap(); + + assert_eq!(Some(vec![5.into()]), bc.body(blocks[5]).unwrap()); + assert!(bc.header(blocks[5]).ok().flatten().is_some()); + let mut expected = Justifications::from(build_justification(5)); + expected.append(([0, 0, 0, 1], vec![42])); + assert_eq!(Some(expected), bc.justifications(blocks[5]).unwrap()); + } + + #[test] + fn test_pinned_blocks_on_finalize_with_fork() { + let backend = Backend::::new_test_with_tx_storage(BlocksPruning::Some(1), 10); + let mut blocks = Vec::new(); + let mut prev_hash = Default::default(); + + // Block tree: + // 0 -> 1 -> 2 -> 3 -> 4 + for i in 0..5 { + let hash = insert_block( + &backend, + i, + prev_hash, + None, + Default::default(), + vec![i.into()], + None, + ) + .unwrap(); + blocks.push(hash); + + // Avoid block pruning. + backend.pin_block(blocks[i as usize]).unwrap(); + + prev_hash = hash; + } + + // Insert a fork at the second block. + // Block tree: + // 0 -> 1 -> 2 -> 3 -> 4 + // \ -> 2 -> 3 + let fork_hash_root = + insert_block(&backend, 2, blocks[1], None, H256::random(), vec![2.into()], None) + .unwrap(); + let fork_hash_3 = insert_block( + &backend, + 3, + fork_hash_root, + None, + H256::random(), + vec![3.into(), 11.into()], + None, + ) + .unwrap(); + + // Do not prune the fork hash. + backend.pin_block(fork_hash_3).unwrap(); + + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, blocks[4]).unwrap(); + op.mark_head(blocks[4]).unwrap(); + backend.commit_operation(op).unwrap(); + + for i in 1..5 { + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, blocks[4]).unwrap(); + op.mark_finalized(blocks[i], None).unwrap(); + backend.commit_operation(op).unwrap(); + } + + let bc = backend.blockchain(); + assert_eq!(Some(vec![0.into()]), bc.body(blocks[0]).unwrap()); + assert_eq!(Some(vec![1.into()]), bc.body(blocks[1]).unwrap()); + assert_eq!(Some(vec![2.into()]), bc.body(blocks[2]).unwrap()); + assert_eq!(Some(vec![3.into()]), bc.body(blocks[3]).unwrap()); + assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap()); + // Check the fork hashes. + assert_eq!(None, bc.body(fork_hash_root).unwrap()); + assert_eq!(Some(vec![3.into(), 11.into()]), bc.body(fork_hash_3).unwrap()); + + // Unpin all blocks, except the forked one. + for block in &blocks { + backend.unpin_block(*block); + } + assert!(bc.body(blocks[0]).unwrap().is_none()); + assert!(bc.body(blocks[1]).unwrap().is_none()); + assert!(bc.body(blocks[2]).unwrap().is_none()); + assert!(bc.body(blocks[3]).unwrap().is_none()); + + assert!(bc.body(fork_hash_3).unwrap().is_some()); + backend.unpin_block(fork_hash_3); + assert!(bc.body(fork_hash_3).unwrap().is_none()); + } } diff --git a/client/db/src/pinned_blocks_cache.rs b/client/db/src/pinned_blocks_cache.rs new file mode 100644 index 0000000000..39ff1c5277 --- /dev/null +++ b/client/db/src/pinned_blocks_cache.rs @@ -0,0 +1,231 @@ +// This file is part of Substrate. + +// Copyright (C) 2017-2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use schnellru::{Limiter, LruMap}; +use sp_runtime::{traits::Block as BlockT, Justifications}; + +const LOG_TARGET: &str = "db::pin"; +const PINNING_CACHE_SIZE: usize = 1024; + +/// Entry for pinned blocks cache. +struct PinnedBlockCacheEntry { + /// How many times this item has been pinned + ref_count: u32, + + /// Cached justifications for this block + pub justifications: Option>, + + /// Cached body for this block + pub body: Option>>, +} + +impl Default for PinnedBlockCacheEntry { + fn default() -> Self { + Self { ref_count: 0, justifications: None, body: None } + } +} + +impl PinnedBlockCacheEntry { + pub fn decrease_ref(&mut self) { + self.ref_count = self.ref_count.saturating_sub(1); + } + + pub fn increase_ref(&mut self) { + self.ref_count = self.ref_count.saturating_add(1); + } + + pub fn has_no_references(&self) -> bool { + self.ref_count == 0 + } +} + +/// A limiter for a map which is limited by the number of elements. +#[derive(Copy, Clone, Debug)] +struct LoggingByLengthLimiter { + max_length: usize, +} + +impl LoggingByLengthLimiter { + /// Creates a new length limiter with a given `max_length`. + pub const fn new(max_length: usize) -> LoggingByLengthLimiter { + LoggingByLengthLimiter { max_length } + } +} + +impl Limiter> for LoggingByLengthLimiter { + type KeyToInsert<'a> = Block::Hash; + type LinkType = usize; + + fn is_over_the_limit(&self, length: usize) -> bool { + length > self.max_length + } + + fn on_insert( + &mut self, + _length: usize, + key: Self::KeyToInsert<'_>, + value: PinnedBlockCacheEntry, + ) -> Option<(Block::Hash, PinnedBlockCacheEntry)> { + if self.max_length > 0 { + Some((key, value)) + } else { + None + } + } + + fn on_replace( + &mut self, + _length: usize, + _old_key: &mut Block::Hash, + _new_key: Block::Hash, + _old_value: &mut PinnedBlockCacheEntry, + _new_value: &mut PinnedBlockCacheEntry, + ) -> bool { + true + } + + fn on_removed(&mut self, key: &mut Block::Hash, value: &mut PinnedBlockCacheEntry) { + // If reference count was larger than 0 on removal, + // the item was removed due to capacity limitations. + // Since the cache should be large enough for pinned items, + // we want to know about these evictions. + if value.ref_count > 0 { + log::warn!( + target: LOG_TARGET, + "Pinned block cache limit reached. Evicting value. hash = {}", + key + ); + } else { + log::trace!( + target: LOG_TARGET, + "Evicting value from pinned block cache. hash = {}", + key + ) + } + } + + fn on_cleared(&mut self) {} + + fn on_grow(&mut self, _new_memory_usage: usize) -> bool { + true + } +} + +/// Reference counted cache for pinned block bodies and justifications. +pub struct PinnedBlocksCache { + cache: LruMap, LoggingByLengthLimiter>, +} + +impl PinnedBlocksCache { + pub fn new() -> Self { + Self { cache: LruMap::new(LoggingByLengthLimiter::new(PINNING_CACHE_SIZE)) } + } + + /// Increase reference count of an item. + /// Create an entry with empty value in the cache if necessary. + pub fn pin(&mut self, hash: Block::Hash) { + match self.cache.get_or_insert(hash, Default::default) { + Some(entry) => { + entry.increase_ref(); + log::trace!( + target: LOG_TARGET, + "Bumped cache refcount. hash = {}, num_entries = {}", + hash, + self.cache.len() + ); + }, + None => + log::warn!(target: LOG_TARGET, "Unable to bump reference count. hash = {}", hash), + }; + } + + /// Clear the cache + pub fn clear(&mut self) { + self.cache.clear(); + } + + /// Check if item is contained in the cache + pub fn contains(&self, hash: Block::Hash) -> bool { + self.cache.peek(&hash).is_some() + } + + /// Attach body to an existing cache item + pub fn insert_body(&mut self, hash: Block::Hash, extrinsics: Option>) { + match self.cache.peek_mut(&hash) { + Some(mut entry) => { + entry.body = Some(extrinsics); + log::trace!( + target: LOG_TARGET, + "Cached body. hash = {}, num_entries = {}", + hash, + self.cache.len() + ); + }, + None => log::warn!( + target: LOG_TARGET, + "Unable to insert body for uncached item. hash = {}", + hash + ), + } + } + + /// Attach justification to an existing cache item + pub fn insert_justifications( + &mut self, + hash: Block::Hash, + justifications: Option, + ) { + match self.cache.peek_mut(&hash) { + Some(mut entry) => { + entry.justifications = Some(justifications); + log::trace!( + target: LOG_TARGET, + "Cached justification. hash = {}, num_entries = {}", + hash, + self.cache.len() + ); + }, + None => log::warn!( + target: LOG_TARGET, + "Unable to insert justifications for uncached item. hash = {}", + hash + ), + } + } + + /// Decreases reference count of an item. + /// If the count hits 0, the item is removed. + pub fn unpin(&mut self, hash: Block::Hash) { + if let Some(entry) = self.cache.peek_mut(&hash) { + entry.decrease_ref(); + if entry.has_no_references() { + self.cache.remove(&hash); + } + } + } + + /// Get justifications for cached block + pub fn justifications(&self, hash: &Block::Hash) -> Option<&Option> { + self.cache.peek(hash).and_then(|entry| entry.justifications.as_ref()) + } + + /// Get body for cached block + pub fn body(&self, hash: &Block::Hash) -> Option<&Option>> { + self.cache.peek(hash).and_then(|entry| entry.body.as_ref()) + } +} diff --git a/client/finality-grandpa/src/until_imported.rs b/client/finality-grandpa/src/until_imported.rs index 776411f8fb..3bca77ae83 100644 --- a/client/finality-grandpa/src/until_imported.rs +++ b/client/finality-grandpa/src/until_imported.rs @@ -593,16 +593,17 @@ mod tests { fn import_header(&self, header: Header) { let hash = header.hash(); let number = *header.number(); - + let (tx, _rx) = tracing_unbounded("unpin-worker-channel", 10_000); self.known_blocks.lock().insert(hash, number); self.sender - .unbounded_send(BlockImportNotification { + .unbounded_send(BlockImportNotification::::new( hash, - origin: BlockOrigin::File, + BlockOrigin::File, header, - is_new_best: false, - tree_route: None, - }) + false, + None, + tx, + )) .unwrap(); } } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 1f94f96fae..0b09f550ce 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -329,13 +329,15 @@ where let executor = crate::client::LocalCallExecutor::new( backend.clone(), executor, - spawn_handle, + spawn_handle.clone(), config.clone(), execution_extensions, )?; + crate::client::Client::new( backend, executor, + spawn_handle, genesis_block_builder, fork_blocks, bad_blocks, diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index 8e10a7b2ed..d32baa671f 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -22,7 +22,8 @@ use super::{ block_rules::{BlockRules, LookupResult as BlockLookupResult}, genesis::BuildGenesisBlock, }; -use log::{info, trace, warn}; +use futures::{FutureExt, StreamExt}; +use log::{error, info, trace, warn}; use parking_lot::{Mutex, RwLock}; use prometheus_endpoint::Registry; use rand::Rng; @@ -58,9 +59,12 @@ use sp_blockchain::{ use sp_consensus::{BlockOrigin, BlockStatus, Error as ConsensusError}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedSender}; -use sp_core::storage::{ - well_known_keys, ChildInfo, ChildType, PrefixedStorageKey, Storage, StorageChild, StorageData, - StorageKey, +use sp_core::{ + storage::{ + well_known_keys, ChildInfo, ChildType, PrefixedStorageKey, Storage, StorageChild, + StorageData, StorageKey, + }, + traits::SpawnNamed, }; #[cfg(feature = "test-helpers")] use sp_keystore::SyncCryptoStorePtr; @@ -88,9 +92,7 @@ use std::{ #[cfg(feature = "test-helpers")] use { - super::call_executor::LocalCallExecutor, - sc_client_api::in_mem, - sp_core::traits::{CodeExecutor, SpawnNamed}, + super::call_executor::LocalCallExecutor, sc_client_api::in_mem, sp_core::traits::CodeExecutor, }; type NotificationSinks = Mutex>>; @@ -116,6 +118,7 @@ where block_rules: BlockRules, config: ClientConfig, telemetry: Option, + unpin_worker_sender: TracingUnboundedSender, _phantom: PhantomData, } @@ -246,7 +249,7 @@ where let call_executor = LocalCallExecutor::new( backend.clone(), executor, - spawn_handle, + spawn_handle.clone(), config.clone(), extensions, )?; @@ -254,6 +257,7 @@ where Client::new( backend, call_executor, + spawn_handle, genesis_block_builder, Default::default(), Default::default(), @@ -296,11 +300,20 @@ where let ClientImportOperation { mut op, notify_imported, notify_finalized } = op; - let finality_notification = notify_finalized.map(|summary| summary.into()); + let finality_notification = notify_finalized.map(|summary| { + FinalityNotification::from_summary(summary, self.unpin_worker_sender.clone()) + }); + let (import_notification, storage_changes) = match notify_imported { Some(mut summary) => { let storage_changes = summary.storage_changes.take(); - (Some(summary.into()), storage_changes) + ( + Some(BlockImportNotification::from_summary( + summary, + self.unpin_worker_sender.clone(), + )), + storage_changes, + ) }, None => (None, None), }; @@ -318,6 +331,27 @@ where self.backend.commit_operation(op)?; + // We need to pin the block in the backend once + // for each notification. Once all notifications are + // dropped, the block will be unpinned automatically. + if let Some(ref notification) = finality_notification { + if let Err(err) = self.backend.pin_block(notification.hash) { + error!( + "Unable to pin block for finality notification. hash: {}, Error: {}", + notification.hash, err + ); + }; + } + + if let Some(ref notification) = import_notification { + if let Err(err) = self.backend.pin_block(notification.hash) { + error!( + "Unable to pin block for import notification. hash: {}, Error: {}", + notification.hash, err + ); + }; + } + self.notify_finalized(finality_notification)?; self.notify_imported(import_notification, storage_changes)?; @@ -357,6 +391,7 @@ where pub fn new( backend: Arc, executor: E, + spawn_handle: Box, genesis_block_builder: G, fork_blocks: ForkBlocks, bad_blocks: BadBlocks, @@ -369,6 +404,7 @@ where Block, BlockImportOperation = >::BlockImportOperation, >, + B: 'static, { let info = backend.blockchain().info(); if info.finalized_state.is_none() { @@ -390,6 +426,26 @@ where backend.commit_operation(op)?; } + let (unpin_worker_sender, mut rx) = + tracing_unbounded::("unpin-worker-channel", 10_000); + let task_backend = Arc::downgrade(&backend); + spawn_handle.spawn( + "unpin-worker", + None, + async move { + while let Some(message) = rx.next().await { + if let Some(backend) = task_backend.upgrade() { + backend.unpin_block(message); + } else { + log::debug!("Terminating unpin-worker, backend reference was dropped."); + return + } + } + log::debug!("Terminating unpin-worker, stream terminated.") + } + .boxed(), + ); + Ok(Client { backend, executor, @@ -402,6 +458,7 @@ where block_rules: BlockRules::new(fork_blocks, bad_blocks), config, telemetry, + unpin_worker_sender, _phantom: Default::default(), }) } diff --git a/test-utils/client/src/lib.rs b/test-utils/client/src/lib.rs index 5dc93da13f..ff744b80cb 100644 --- a/test-utils/client/src/lib.rs +++ b/test-utils/client/src/lib.rs @@ -41,7 +41,7 @@ use futures::{future::Future, stream::StreamExt}; use sc_client_api::BlockchainEvents; use sc_service::client::{ClientConfig, LocalCallExecutor}; use serde::Deserialize; -use sp_core::storage::ChildInfo; +use sp_core::{storage::ChildInfo, testing::TaskExecutor}; use sp_runtime::{codec::Encode, traits::Block as BlockT, OpaqueExtrinsic}; use std::{ collections::{HashMap, HashSet}, @@ -62,7 +62,7 @@ impl GenesisInit for () { } /// A builder for creating a test client instance. -pub struct TestClientBuilder { +pub struct TestClientBuilder { execution_strategies: ExecutionStrategies, genesis_init: G, /// The key is an unprefixed storage key, this only contains @@ -237,9 +237,12 @@ impl ) .expect("Creates genesis block builder"); + let spawn_handle = Box::new(TaskExecutor::new()); + let client = client::Client::new( self.backend.clone(), executor, + spawn_handle, genesis_block_builder, self.fork_blocks, self.bad_blocks, From 0b6aec52a90870c999856cd37f7d04789cdd8dfc Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 19 Jan 2023 13:47:47 -0300 Subject: [PATCH 28/80] Make DispatchError impl MEL (#13169) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make DispatchError impl MEL * Upgrade SCALE codec to support `codec(skip)` for MEL Co-authored-by: Bastian Köcher --- Cargo.lock | 12 ++++++------ bin/node-template/pallets/template/Cargo.toml | 2 +- bin/node-template/runtime/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- bin/node/executor/Cargo.toml | 2 +- bin/node/inspect/Cargo.toml | 2 +- bin/node/primitives/Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 2 +- bin/node/testing/Cargo.toml | 2 +- client/api/Cargo.toml | 2 +- client/authority-discovery/Cargo.toml | 2 +- client/basic-authorship/Cargo.toml | 2 +- client/beefy/Cargo.toml | 2 +- client/beefy/rpc/Cargo.toml | 2 +- client/block-builder/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/consensus/epochs/Cargo.toml | 2 +- client/consensus/manual-seal/Cargo.toml | 2 +- client/consensus/pow/Cargo.toml | 2 +- client/consensus/slots/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/executor/wasmtime/Cargo.toml | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/finality-grandpa/rpc/Cargo.toml | 2 +- client/merkle-mountain-range/Cargo.toml | 2 +- client/merkle-mountain-range/rpc/Cargo.toml | 2 +- client/network/Cargo.toml | 2 +- client/network/common/Cargo.toml | 2 +- client/network/light/Cargo.toml | 2 +- client/network/sync/Cargo.toml | 2 +- client/network/transactions/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/rpc-api/Cargo.toml | 2 +- client/rpc-spec-v2/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/service/test/Cargo.toml | 2 +- client/state-db/Cargo.toml | 2 +- client/sync-state-rpc/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- frame/alliance/Cargo.toml | 2 +- frame/assets/Cargo.toml | 2 +- frame/atomic-swap/Cargo.toml | 2 +- frame/aura/Cargo.toml | 2 +- frame/authority-discovery/Cargo.toml | 2 +- frame/authorship/Cargo.toml | 2 +- frame/babe/Cargo.toml | 2 +- frame/bags-list/Cargo.toml | 2 +- frame/balances/Cargo.toml | 2 +- frame/beefy-mmr/Cargo.toml | 2 +- frame/beefy/Cargo.toml | 2 +- frame/benchmarking/Cargo.toml | 2 +- frame/bounties/Cargo.toml | 2 +- frame/child-bounties/Cargo.toml | 2 +- frame/collective/Cargo.toml | 2 +- frame/contracts/Cargo.toml | 2 +- frame/contracts/primitives/Cargo.toml | 2 +- frame/conviction-voting/Cargo.toml | 2 +- frame/democracy/Cargo.toml | 2 +- frame/election-provider-multi-phase/Cargo.toml | 2 +- frame/election-provider-support/Cargo.toml | 2 +- .../benchmarking/Cargo.toml | 2 +- .../solution-type/Cargo.toml | 2 +- .../solution-type/fuzzer/Cargo.toml | 2 +- frame/elections-phragmen/Cargo.toml | 2 +- frame/examples/basic/Cargo.toml | 2 +- frame/examples/offchain-worker/Cargo.toml | 2 +- frame/executive/Cargo.toml | 2 +- frame/fast-unstake/Cargo.toml | 2 +- frame/grandpa/Cargo.toml | 2 +- frame/identity/Cargo.toml | 2 +- frame/im-online/Cargo.toml | 2 +- frame/indices/Cargo.toml | 2 +- frame/lottery/Cargo.toml | 2 +- frame/membership/Cargo.toml | 2 +- frame/merkle-mountain-range/Cargo.toml | 2 +- frame/message-queue/Cargo.toml | 2 +- frame/multisig/Cargo.toml | 2 +- frame/nfts/Cargo.toml | 2 +- frame/nicks/Cargo.toml | 2 +- frame/nis/Cargo.toml | 2 +- frame/node-authorization/Cargo.toml | 2 +- frame/nomination-pools/Cargo.toml | 2 +- frame/nomination-pools/benchmarking/Cargo.toml | 2 +- frame/nomination-pools/runtime-api/Cargo.toml | 2 +- frame/nomination-pools/test-staking/Cargo.toml | 2 +- frame/offences/Cargo.toml | 2 +- frame/offences/benchmarking/Cargo.toml | 2 +- frame/preimage/Cargo.toml | 2 +- frame/proxy/Cargo.toml | 2 +- frame/randomness-collective-flip/Cargo.toml | 2 +- frame/ranked-collective/Cargo.toml | 2 +- frame/recovery/Cargo.toml | 2 +- frame/referenda/Cargo.toml | 2 +- frame/remark/Cargo.toml | 2 +- frame/root-offences/Cargo.toml | 2 +- frame/root-testing/Cargo.toml | 2 +- frame/scheduler/Cargo.toml | 2 +- frame/scored-pool/Cargo.toml | 2 +- frame/session/Cargo.toml | 2 +- frame/session/benchmarking/Cargo.toml | 2 +- frame/society/Cargo.toml | 2 +- frame/staking/Cargo.toml | 2 +- frame/state-trie-migration/Cargo.toml | 2 +- frame/sudo/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 2 +- frame/support/test/compile_pass/Cargo.toml | 2 +- frame/support/test/pallet/Cargo.toml | 2 +- frame/system/Cargo.toml | 2 +- frame/system/benchmarking/Cargo.toml | 2 +- frame/system/rpc/runtime-api/Cargo.toml | 2 +- frame/timestamp/Cargo.toml | 2 +- frame/tips/Cargo.toml | 2 +- frame/transaction-payment/Cargo.toml | 2 +- .../transaction-payment/asset-tx-payment/Cargo.toml | 2 +- frame/transaction-payment/rpc/Cargo.toml | 2 +- frame/transaction-payment/rpc/runtime-api/Cargo.toml | 2 +- frame/transaction-storage/Cargo.toml | 2 +- frame/treasury/Cargo.toml | 2 +- frame/try-runtime/Cargo.toml | 2 +- frame/uniques/Cargo.toml | 2 +- frame/utility/Cargo.toml | 2 +- frame/vesting/Cargo.toml | 2 +- frame/whitelist/Cargo.toml | 2 +- primitives/api/Cargo.toml | 2 +- primitives/api/test/Cargo.toml | 2 +- primitives/application-crypto/Cargo.toml | 2 +- primitives/arithmetic/Cargo.toml | 2 +- primitives/arithmetic/src/lib.rs | 4 ++-- primitives/authority-discovery/Cargo.toml | 2 +- primitives/authorship/Cargo.toml | 2 +- primitives/beefy/Cargo.toml | 2 +- primitives/block-builder/Cargo.toml | 2 +- primitives/blockchain/Cargo.toml | 2 +- primitives/consensus/aura/Cargo.toml | 2 +- primitives/consensus/babe/Cargo.toml | 2 +- primitives/consensus/common/Cargo.toml | 2 +- primitives/consensus/pow/Cargo.toml | 2 +- primitives/consensus/slots/Cargo.toml | 2 +- primitives/consensus/vrf/Cargo.toml | 2 +- primitives/core/Cargo.toml | 2 +- primitives/externalities/Cargo.toml | 2 +- primitives/finality-grandpa/Cargo.toml | 2 +- primitives/inherents/Cargo.toml | 2 +- primitives/io/Cargo.toml | 2 +- primitives/keystore/Cargo.toml | 2 +- primitives/merkle-mountain-range/Cargo.toml | 2 +- primitives/npos-elections/Cargo.toml | 2 +- primitives/npos-elections/fuzzer/Cargo.toml | 2 +- primitives/runtime-interface/Cargo.toml | 2 +- primitives/runtime/Cargo.toml | 2 +- primitives/runtime/src/lib.rs | 8 ++++---- primitives/session/Cargo.toml | 2 +- primitives/staking/Cargo.toml | 2 +- primitives/state-machine/Cargo.toml | 2 +- primitives/storage/Cargo.toml | 2 +- primitives/test-primitives/Cargo.toml | 2 +- primitives/timestamp/Cargo.toml | 2 +- primitives/tracing/Cargo.toml | 2 +- primitives/transaction-storage-proof/Cargo.toml | 2 +- primitives/trie/Cargo.toml | 2 +- primitives/version/Cargo.toml | 2 +- primitives/version/proc-macro/Cargo.toml | 2 +- primitives/wasm-interface/Cargo.toml | 2 +- primitives/weights/Cargo.toml | 2 +- test-utils/client/Cargo.toml | 2 +- test-utils/runtime/Cargo.toml | 2 +- test-utils/runtime/client/Cargo.toml | 2 +- test-utils/runtime/transaction-pool/Cargo.toml | 2 +- utils/fork-tree/Cargo.toml | 2 +- utils/frame/benchmarking-cli/Cargo.toml | 2 +- utils/frame/remote-externalities/Cargo.toml | 2 +- utils/frame/rpc/state-trie-migration-rpc/Cargo.toml | 2 +- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- utils/frame/try-runtime/cli/Cargo.toml | 2 +- 180 files changed, 189 insertions(+), 189 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 100e0d2152..dbb046ccd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6679,9 +6679,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.2.1" +version = "3.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +checksum = "e7ab01d0f889e957861bc65888d5ccbe82c158d0270136ba46820d43837cdf72" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -6694,9 +6694,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7128,9 +7128,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" dependencies = [ "unicode-ident", ] diff --git a/bin/node-template/pallets/template/Cargo.toml b/bin/node-template/pallets/template/Cargo.toml index 7c04838cae..6dec5c8da6 100644 --- a/bin/node-template/pallets/template/Cargo.toml +++ b/bin/node-template/pallets/template/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/substrate-developer-hub/substrate-node-template targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 5dc7b03d39..5560eb6721 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -13,7 +13,7 @@ repository = "https://github.com/substrate-developer-hub/substrate-node-template targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } pallet-aura = { version = "4.0.0-dev", default-features = false, path = "../../../frame/aura" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 6b50115fd9..4d9279b857 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -37,7 +37,7 @@ crate-type = ["cdylib", "rlib"] # third-party dependencies array-bytes = "4.1" clap = { version = "4.0.9", features = ["derive"], optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } serde = { version = "1.0.136", features = ["derive"] } jsonrpsee = { version = "0.16.2", features = ["server"] } futures = "0.3.21" diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index 8b3add78a9..edcc4df9c8 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } scale-info = { version = "2.1.1", features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", path = "../../../frame/benchmarking" } node-primitives = { version = "2.0.0", path = "../primitives" } diff --git a/bin/node/inspect/Cargo.toml b/bin/node/inspect/Cargo.toml index a7343b3ca8..d6a8755179 100644 --- a/bin/node/inspect/Cargo.toml +++ b/bin/node/inspect/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] clap = { version = "4.0.9", features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } thiserror = "1.0" sc-cli = { version = "0.10.0-dev", path = "../../../client/cli" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 1aa0a8f0e2..1f515f3e3a 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 7037be9d7c..76fca730ef 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # third-party dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", "max-encoded-len", ] } diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index 0154a77845..a43b2b9ba1 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } fs_extra = "1" futures = "0.3.21" log = "0.4.17" diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index bd1f6f34b0..f494200852 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } fnv = "1.0.6" diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index a24002517c..b37507662b 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] prost-build = "0.11" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 09b5c47394..c4f1d2e245 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" futures-timer = "3.0.1" log = "0.4.17" diff --git a/client/beefy/Cargo.toml b/client/beefy/Cargo.toml index b039faa2d0..d81ff2587c 100644 --- a/client/beefy/Cargo.toml +++ b/client/beefy/Cargo.toml @@ -11,7 +11,7 @@ homepage = "https://substrate.io" [dependencies] array-bytes = "4.1" async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } fnv = "1.0.6" futures = "0.3" log = "0.4" diff --git a/client/beefy/rpc/Cargo.toml b/client/beefy/rpc/Cargo.toml index f853af8a81..ab3e6921f3 100644 --- a/client/beefy/rpc/Cargo.toml +++ b/client/beefy/rpc/Cargo.toml @@ -9,7 +9,7 @@ description = "RPC for the BEEFY Client gadget for substrate" homepage = "https://substrate.io" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } log = "0.4" diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 2516374864..3b4bea9818 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } sc-client-api = { version = "4.0.0-dev", path = "../api" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 5e1f2bab4b..c0da53ad12 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -21,7 +21,7 @@ futures = "0.3.21" libp2p = "0.50.0" log = "0.4.17" names = { version = "0.13.0", default-features = false } -parity-scale-codec = "3.0.0" +parity-scale-codec = "3.2.2" rand = "0.8.5" regex = "1.6.0" rpassword = "7.0.0" diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 47aee0ec08..4c0305e9f6 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" log = "0.4.17" thiserror = "1.0" diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 312cc25dd0..f0ff0080fd 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" log = "0.4.17" merlin = "2.0" diff --git a/client/consensus/epochs/Cargo.toml b/client/consensus/epochs/Cargo.toml index c88b5c52ba..89588cc7d4 100644 --- a/client/consensus/epochs/Cargo.toml +++ b/client/consensus/epochs/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } fork-tree = { version = "3.0.0", path = "../../../utils/fork-tree" } sc-client-api = { version = "4.0.0-dev", path = "../../api" } sc-consensus = { version = "0.10.0-dev", path = "../common" } diff --git a/client/consensus/manual-seal/Cargo.toml b/client/consensus/manual-seal/Cargo.toml index fb89445a97..19c4b22247 100644 --- a/client/consensus/manual-seal/Cargo.toml +++ b/client/consensus/manual-seal/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } assert_matches = "1.3.0" async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" log = "0.4.17" serde = { version = "1.0", features = ["derive"] } diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index 480d9b23b0..b5454e35f9 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" futures-timer = "3.0.1" log = "0.4.17" diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 6acd656d21..5cacf4f476 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" futures-timer = "3.0.1" log = "0.4.17" diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 2d7291a014..028af5d6e4 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } hash-db = "0.15.2" diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 83d4801d1c..4604b976b4 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -19,7 +19,7 @@ parking_lot = "0.12.1" tracing = "0.1.29" wasmi = "0.13" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } sc-executor-common = { version = "0.10.0-dev", path = "common" } sc-executor-wasmi = { version = "0.10.0-dev", path = "wasmi" } sc-executor-wasmtime = { version = "0.10.0-dev", path = "wasmtime" } diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml index 7e38929f05..983ca3c44f 100644 --- a/client/executor/wasmtime/Cargo.toml +++ b/client/executor/wasmtime/Cargo.toml @@ -47,4 +47,4 @@ sc-runtime-test = { version = "2.0.0", path = "../runtime-test" } sp-io = { version = "7.0.0", path = "../../../primitives/io" } tempfile = "3.3.0" paste = "1.0" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 95195bfc2d..9a31a1d4bf 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -22,7 +22,7 @@ finality-grandpa = { version = "0.16.1", features = ["derive-codec"] } futures = "0.3.21" futures-timer = "3.0.1" log = "0.4.17" -parity-scale-codec = { version = "3.0.0", features = ["derive"] } +parity-scale-codec = { version = "3.2.2", features = ["derive"] } parking_lot = "0.12.1" rand = "0.8.5" serde_json = "1.0.85" diff --git a/client/finality-grandpa/rpc/Cargo.toml b/client/finality-grandpa/rpc/Cargo.toml index 429331e96a..e20ff174d4 100644 --- a/client/finality-grandpa/rpc/Cargo.toml +++ b/client/finality-grandpa/rpc/Cargo.toml @@ -14,7 +14,7 @@ finality-grandpa = { version = "0.16.1", features = ["derive-codec"] } futures = "0.3.16" jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } log = "0.4.8" -parity-scale-codec = { version = "3.0.0", features = ["derive"] } +parity-scale-codec = { version = "3.2.2", features = ["derive"] } serde = { version = "1.0.105", features = ["derive"] } thiserror = "1.0" sc-client-api = { version = "4.0.0-dev", path = "../../api" } diff --git a/client/merkle-mountain-range/Cargo.toml b/client/merkle-mountain-range/Cargo.toml index cd7d944249..90fb65453b 100644 --- a/client/merkle-mountain-range/Cargo.toml +++ b/client/merkle-mountain-range/Cargo.toml @@ -11,7 +11,7 @@ homepage = "https://substrate.io" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3" log = "0.4" beefy-primitives = { version = "4.0.0-dev", path = "../../primitives/beefy", package = "sp-beefy" } diff --git a/client/merkle-mountain-range/rpc/Cargo.toml b/client/merkle-mountain-range/rpc/Cargo.toml index dcc5e49c52..ce71158808 100644 --- a/client/merkle-mountain-range/rpc/Cargo.toml +++ b/client/merkle-mountain-range/rpc/Cargo.toml @@ -12,7 +12,7 @@ description = "Node-specific RPC methods for interaction with Merkle Mountain Ra targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } serde = { version = "1.0.136", features = ["derive"] } sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 4356cc5df1..44a7973b33 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -19,7 +19,7 @@ async-trait = "0.1" asynchronous-codec = "0.6" backtrace = "0.3.67" bytes = "1" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } either = "1.5.3" fnv = "1.0.6" futures = "0.3.21" diff --git a/client/network/common/Cargo.toml b/client/network/common/Cargo.toml index e2dd7d0894..2aaada021f 100644 --- a/client/network/common/Cargo.toml +++ b/client/network/common/Cargo.toml @@ -19,7 +19,7 @@ prost-build = "0.11" async-trait = "0.1.57" bitflags = "1.3.2" bytes = "1" -codec = { package = "parity-scale-codec", version = "3.0.0", features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } futures = "0.3.21" diff --git a/client/network/light/Cargo.toml b/client/network/light/Cargo.toml index 8a3e903772..f3e94790df 100644 --- a/client/network/light/Cargo.toml +++ b/client/network/light/Cargo.toml @@ -17,7 +17,7 @@ prost-build = "0.11" [dependencies] array-bytes = "4.1" -codec = { package = "parity-scale-codec", version = "3.0.0", features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } futures = "0.3.21" diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index d2cbeb5ec1..ff72b4e993 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -18,7 +18,7 @@ prost-build = "0.11" [dependencies] array-bytes = "4.1" async-trait = "0.1.58" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" libp2p = "0.50.0" log = "0.4.17" diff --git a/client/network/transactions/Cargo.toml b/client/network/transactions/Cargo.toml index df13cdcb82..cab702fbd7 100644 --- a/client/network/transactions/Cargo.toml +++ b/client/network/transactions/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" libp2p = "0.50.0" log = "0.4.17" diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 09df9187fb..dd6e2e44ca 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" bytes = "1.1" -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } fnv = "1.0.6" futures = "0.3.21" futures-timer = "3.0.2" diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index f697f53e98..261339f131 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.85" diff --git a/client/rpc-spec-v2/Cargo.toml b/client/rpc-spec-v2/Cargo.toml index f9598b3c1a..43fb189081 100644 --- a/client/rpc-spec-v2/Cargo.toml +++ b/client/rpc-spec-v2/Cargo.toml @@ -24,7 +24,7 @@ sp-api = { version = "4.0.0-dev", path = "../../primitives/api" } sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" } sp-version = { version = "5.0.0", path = "../../primitives/version" } sc-client-api = { version = "4.0.0-dev", path = "../api" } -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } thiserror = "1.0" serde = "1.0" hex = "0.4" diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index d39d8d8581..a22f657878 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" jsonrpsee = { version = "0.16.2", features = ["server"] } log = "0.4.17" diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 45b1c02620..6122895d23 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -57,7 +57,7 @@ sc-chain-spec = { version = "4.0.0-dev", path = "../chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../api" } sp-api = { version = "4.0.0-dev", path = "../../primitives/api" } sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../db" } -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } sc-executor = { version = "0.10.0-dev", path = "../executor" } sc-transaction-pool = { version = "4.0.0-dev", path = "../transaction-pool" } sp-transaction-pool = { version = "4.0.0-dev", path = "../../primitives/transaction-pool" } diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index d3bc39aa34..488fe76c33 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -16,7 +16,7 @@ array-bytes = "4.1" fdlimit = "0.2.1" futures = "0.3.21" log = "0.4.17" -parity-scale-codec = "3.0.0" +parity-scale-codec = "3.2.2" parking_lot = "0.12.1" tempfile = "3.1.0" tokio = { version = "1.22.0", features = ["time"] } diff --git a/client/state-db/Cargo.toml b/client/state-db/Cargo.toml index fb70f5fc6a..13439de110 100644 --- a/client/state-db/Cargo.toml +++ b/client/state-db/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } log = "0.4.17" parking_lot = "0.12.1" sp-core = { version = "7.0.0", path = "../../primitives/core" } diff --git a/client/sync-state-rpc/Cargo.toml b/client/sync-state-rpc/Cargo.toml index a72b4106ba..3a964521c5 100644 --- a/client/sync-state-rpc/Cargo.toml +++ b/client/sync-state-rpc/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.85" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 4b69b6d0f2..bbb5ebae44 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" futures-timer = "3.0.2" linked-hash-map = "0.5.4" diff --git a/frame/alliance/Cargo.toml b/frame/alliance/Cargo.toml index da0a7d6657..d6a16e2c32 100644 --- a/frame/alliance/Cargo.toml +++ b/frame/alliance/Cargo.toml @@ -17,7 +17,7 @@ array-bytes = { version = "4.1", optional = true } sha2 = { version = "0.10.1", default-features = false, optional = true } log = { version = "0.4.14", default-features = false } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 84bfd9535a..6fe0e3e6c3 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } # Needed for various traits. In our case, `OnFinalize`. diff --git a/frame/atomic-swap/Cargo.toml b/frame/atomic-swap/Cargo.toml index 5220edb9d1..9c3bcf73af 100644 --- a/frame/atomic-swap/Cargo.toml +++ b/frame/atomic-swap/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 552f13301d..d2fd5a5b9c 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 47bd1a126f..50c6c411c5 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index 7c0289909f..84d00a6fbc 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } impl-trait-for-tuples = "0.2.2" diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index a3232f6f98..aa58139272 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/bags-list/Cargo.toml b/frame/bags-list/Cargo.toml index 52dd14b7d0..e3a4965f6c 100644 --- a/frame/bags-list/Cargo.toml +++ b/frame/bags-list/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # parity -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } # primitives diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index 934138a900..15ef136aa3 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/beefy-mmr/Cargo.toml b/frame/beefy-mmr/Cargo.toml index f65270acdc..54da26c394 100644 --- a/frame/beefy-mmr/Cargo.toml +++ b/frame/beefy-mmr/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://substrate.io" [dependencies] array-bytes = { version = "4.1", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } diff --git a/frame/beefy/Cargo.toml b/frame/beefy/Cargo.toml index 707e8e2571..4db8c05682 100644 --- a/frame/beefy/Cargo.toml +++ b/frame/beefy/Cargo.toml @@ -9,7 +9,7 @@ description = "BEEFY FRAME pallet" homepage = "https://substrate.io" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } beefy-primitives = { version = "4.0.0-dev", default-features = false, path = "../../primitives/beefy", package = "sp-beefy" } diff --git a/frame/benchmarking/Cargo.toml b/frame/benchmarking/Cargo.toml index 7c18b69401..168b260573 100644 --- a/frame/benchmarking/Cargo.toml +++ b/frame/benchmarking/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } linregress = { version = "0.4.4", optional = true } log = { version = "0.4.17", default-features = false } paste = "1.0" diff --git a/frame/bounties/Cargo.toml b/frame/bounties/Cargo.toml index a5411952a3..dcb1adae05 100644 --- a/frame/bounties/Cargo.toml +++ b/frame/bounties/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } log = { version = "0.4.17", default-features = false } diff --git a/frame/child-bounties/Cargo.toml b/frame/child-bounties/Cargo.toml index 6b0a672d04..8d29b76197 100644 --- a/frame/child-bounties/Cargo.toml +++ b/frame/child-bounties/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } log = { version = "0.4.17", default-features = false } diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 0e8c5421f5..26cd5a8ab4 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 8e6368490f..c238bdd14e 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] bitflags = "1.3" -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", "max-encoded-len", ] } diff --git a/frame/contracts/primitives/Cargo.toml b/frame/contracts/primitives/Cargo.toml index d0c3a34ddf..aafcd912af 100644 --- a/frame/contracts/primitives/Cargo.toml +++ b/frame/contracts/primitives/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] bitflags = "1.0" -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } # Substrate Dependencies (This crate should not rely on frame) sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } diff --git a/frame/conviction-voting/Cargo.toml b/frame/conviction-voting/Cargo.toml index 9bfc93f2d9..d112c54fb6 100644 --- a/frame/conviction-voting/Cargo.toml +++ b/frame/conviction-voting/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] assert_matches = "1.3.0" -codec = { package = "parity-scale-codec", version = "3.0.3", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", "max-encoded-len", ] } diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 49dbe133d6..fa107218cf 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/election-provider-multi-phase/Cargo.toml b/frame/election-provider-multi-phase/Cargo.toml index a21740dd72..aa734850aa 100644 --- a/frame/election-provider-multi-phase/Cargo.toml +++ b/frame/election-provider-multi-phase/Cargo.toml @@ -12,7 +12,7 @@ description = "PALLET two phase election providers" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = [ diff --git a/frame/election-provider-support/Cargo.toml b/frame/election-provider-support/Cargo.toml index 108a49eb08..c7f47e721d 100644 --- a/frame/election-provider-support/Cargo.toml +++ b/frame/election-provider-support/Cargo.toml @@ -12,7 +12,7 @@ description = "election provider supporting traits" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-election-provider-solution-type = { version = "4.0.0-dev", path = "solution-type" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/election-provider-support/benchmarking/Cargo.toml b/frame/election-provider-support/benchmarking/Cargo.toml index 6053899777..bef371ec5e 100644 --- a/frame/election-provider-support/benchmarking/Cargo.toml +++ b/frame/election-provider-support/benchmarking/Cargo.toml @@ -12,7 +12,7 @@ description = "Benchmarking for election provider support onchain config trait" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../../benchmarking" } diff --git a/frame/election-provider-support/solution-type/Cargo.toml b/frame/election-provider-support/solution-type/Cargo.toml index 50c39c547f..eb9598dca2 100644 --- a/frame/election-provider-support/solution-type/Cargo.toml +++ b/frame/election-provider-support/solution-type/Cargo.toml @@ -21,7 +21,7 @@ proc-macro2 = "1.0.37" proc-macro-crate = "1.1.3" [dev-dependencies] -parity-scale-codec = "3.0.0" +parity-scale-codec = "3.2.2" scale-info = "2.1.1" sp-arithmetic = { version = "6.0.0", path = "../../../primitives/arithmetic" } # used by generate_solution_type: diff --git a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml index 34aeaf9300..9275692788 100644 --- a/frame/election-provider-support/solution-type/fuzzer/Cargo.toml +++ b/frame/election-provider-support/solution-type/fuzzer/Cargo.toml @@ -17,7 +17,7 @@ clap = { version = "4.0.9", features = ["derive"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-election-provider-solution-type = { version = "4.0.0-dev", path = ".." } frame-election-provider-support = { version = "4.0.0-dev", path = "../.." } diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index fb1d924dbd..ce39e42b8e 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } log = { version = "0.4.14", default-features = false } diff --git a/frame/examples/basic/Cargo.toml b/frame/examples/basic/Cargo.toml index 8c69dc6c3e..47f623f453 100644 --- a/frame/examples/basic/Cargo.toml +++ b/frame/examples/basic/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../../benchmarking" } diff --git a/frame/examples/offchain-worker/Cargo.toml b/frame/examples/offchain-worker/Cargo.toml index 446af8dda9..f94cf36b2b 100644 --- a/frame/examples/offchain-worker/Cargo.toml +++ b/frame/examples/offchain-worker/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } lite-json = { version = "0.2.0", default-features = false } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index a6d16e9b07..1636cb3929 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/fast-unstake/Cargo.toml b/frame/fast-unstake/Cargo.toml index b61060e775..36b4c3a5ec 100644 --- a/frame/fast-unstake/Cargo.toml +++ b/frame/fast-unstake/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME fast unstake pallet" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 93dd4143af..fa63b84275 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index 8c7655af6a..c1a250368f 100644 --- a/frame/identity/Cargo.toml +++ b/frame/identity/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } enumflags2 = { version = "0.7.4" } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index c0058e9f23..d76fba4fb6 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index b3afa397c4..b667916ebc 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/lottery/Cargo.toml b/frame/lottery/Cargo.toml index 9ac69d63eb..8c1bf30106 100644 --- a/frame/lottery/Cargo.toml +++ b/frame/lottery/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME Participation Lottery Pallet" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index b457c4c291..bba5700cdd 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/merkle-mountain-range/Cargo.toml b/frame/merkle-mountain-range/Cargo.toml index cf26cfb231..3f7180f79a 100644 --- a/frame/merkle-mountain-range/Cargo.toml +++ b/frame/merkle-mountain-range/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME Merkle Mountain Range pallet." targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/message-queue/Cargo.toml b/frame/message-queue/Cargo.toml index 47d114902f..115200b826 100644 --- a/frame/message-queue/Cargo.toml +++ b/frame/message-queue/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/paritytech/substrate/" description = "FRAME pallet to queue and process messages" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.2", default-features = false, features = ["derive"] } serde = { version = "1.0.137", optional = true, features = ["derive"] } log = { version = "0.4.17", default-features = false } diff --git a/frame/multisig/Cargo.toml b/frame/multisig/Cargo.toml index 4e9f4f5d83..5cd744124e 100644 --- a/frame/multisig/Cargo.toml +++ b/frame/multisig/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/nfts/Cargo.toml b/frame/nfts/Cargo.toml index d2cdb48532..9e010cb557 100644 --- a/frame/nfts/Cargo.toml +++ b/frame/nfts/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } enumflags2 = { version = "0.7.5" } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index 2390060c71..1c829efc2d 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } diff --git a/frame/nis/Cargo.toml b/frame/nis/Cargo.toml index be12d97dd8..a5fc29cd79 100644 --- a/frame/nis/Cargo.toml +++ b/frame/nis/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/node-authorization/Cargo.toml b/frame/node-authorization/Cargo.toml index fbf486644e..c60ce1d12c 100644 --- a/frame/node-authorization/Cargo.toml +++ b/frame/node-authorization/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME pallet for node authorization" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/nomination-pools/Cargo.toml b/frame/nomination-pools/Cargo.toml index 3eb2d4bc5f..d51bcec51f 100644 --- a/frame/nomination-pools/Cargo.toml +++ b/frame/nomination-pools/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # parity -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } # FRAME diff --git a/frame/nomination-pools/benchmarking/Cargo.toml b/frame/nomination-pools/benchmarking/Cargo.toml index 74b71a353f..b96024af7d 100644 --- a/frame/nomination-pools/benchmarking/Cargo.toml +++ b/frame/nomination-pools/benchmarking/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] # parity -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } # FRAME diff --git a/frame/nomination-pools/runtime-api/Cargo.toml b/frame/nomination-pools/runtime-api/Cargo.toml index cf72d795c9..d1e4fbb30d 100644 --- a/frame/nomination-pools/runtime-api/Cargo.toml +++ b/frame/nomination-pools/runtime-api/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" } sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } diff --git a/frame/nomination-pools/test-staking/Cargo.toml b/frame/nomination-pools/test-staking/Cargo.toml index a45c7852d4..fbe5feca0f 100644 --- a/frame/nomination-pools/test-staking/Cargo.toml +++ b/frame/nomination-pools/test-staking/Cargo.toml @@ -13,7 +13,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } scale-info = { version = "2.0.1", features = ["derive"] } sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 107a0489cd..47ae264a69 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } diff --git a/frame/offences/benchmarking/Cargo.toml b/frame/offences/benchmarking/Cargo.toml index e31e8bbed9..23377f7883 100644 --- a/frame/offences/benchmarking/Cargo.toml +++ b/frame/offences/benchmarking/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../benchmarking" } frame-election-provider-support = { version = "4.0.0-dev", default-features = false, path = "../../election-provider-support" } diff --git a/frame/preimage/Cargo.toml b/frame/preimage/Cargo.toml index def39d61d5..6bc6c8c53c 100644 --- a/frame/preimage/Cargo.toml +++ b/frame/preimage/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/paritytech/substrate/" description = "FRAME pallet for storing preimages of hashes" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/proxy/Cargo.toml b/frame/proxy/Cargo.toml index 1674e40866..5c69fcfb9f 100644 --- a/frame/proxy/Cargo.toml +++ b/frame/proxy/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["max-encoded-len"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index 5a20949e9f..435c38d632 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } safe-mix = { version = "1.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/ranked-collective/Cargo.toml b/frame/ranked-collective/Cargo.toml index c5e79eb68f..e19aaa4439 100644 --- a/frame/ranked-collective/Cargo.toml +++ b/frame/ranked-collective/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.16", default-features = false } scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/recovery/Cargo.toml b/frame/recovery/Cargo.toml index cdcebbec16..3c25c0002b 100644 --- a/frame/recovery/Cargo.toml +++ b/frame/recovery/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/referenda/Cargo.toml b/frame/referenda/Cargo.toml index 02894e1499..ac4c8044da 100644 --- a/frame/referenda/Cargo.toml +++ b/frame/referenda/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] assert_matches = { version = "1.5", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.3", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/remark/Cargo.toml b/frame/remark/Cargo.toml index a827d165f8..151cc38884 100644 --- a/frame/remark/Cargo.toml +++ b/frame/remark/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/root-offences/Cargo.toml b/frame/root-offences/Cargo.toml index 76eb832c88..fd1f7c6325 100644 --- a/frame/root-offences/Cargo.toml +++ b/frame/root-offences/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../frame/session", default-features = false } diff --git a/frame/root-testing/Cargo.toml b/frame/root-testing/Cargo.toml index 4d3f70c5d0..09262b3d31 100644 --- a/frame/root-testing/Cargo.toml +++ b/frame/root-testing/Cargo.toml @@ -14,7 +14,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } diff --git a/frame/scheduler/Cargo.toml b/frame/scheduler/Cargo.toml index 25ac602681..9a67e68a01 100644 --- a/frame/scheduler/Cargo.toml +++ b/frame/scheduler/Cargo.toml @@ -10,7 +10,7 @@ description = "FRAME Scheduler pallet" readme = "README.md" [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index a1e8dc453d..d44fc1b2f1 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index 57b519e81e..bd28bffffd 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } impl-trait-for-tuples = "0.2.2" log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/session/benchmarking/Cargo.toml b/frame/session/benchmarking/Cargo.toml index 53d6ff0cd1..4d1d9b4eda 100644 --- a/frame/session/benchmarking/Cargo.toml +++ b/frame/session/benchmarking/Cargo.toml @@ -24,7 +24,7 @@ sp-session = { version = "4.0.0-dev", default-features = false, path = "../../.. sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } [dev-dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } scale-info = "2.1.1" frame-election-provider-support = { version = "4.0.0-dev", path = "../../election-provider-support" } pallet-balances = { version = "4.0.0-dev", path = "../../balances" } diff --git a/frame/society/Cargo.toml b/frame/society/Cargo.toml index 40b78c8922..ddc6ea6aac 100644 --- a/frame/society/Cargo.toml +++ b/frame/society/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } rand_chacha = { version = "0.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index f6b3b95d0b..3d5cf1161e 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.136", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/state-trie-migration/Cargo.toml b/frame/state-trie-migration/Cargo.toml index 90c8f426d0..36b5912a60 100644 --- a/frame/state-trie-migration/Cargo.toml +++ b/frame/state-trie-migration/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME pallet migration of trie" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.133", optional = true } diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index b0e38b0139..56d04b172c 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 4945b5ab91..4f62ae42ef 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.136", optional = true, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-metadata = { version = "15.0.0", default-features = false, features = ["v14"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index 7fe1bcb567..fc211d7713 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] serde = { version = "1.0.136", default-features = false, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../../primitives/arithmetic" } sp-io = { version = "7.0.0", path = "../../../primitives/io", default-features = false } diff --git a/frame/support/test/compile_pass/Cargo.toml b/frame/support/test/compile_pass/Cargo.toml index ea22a735b3..dd5e1b996d 100644 --- a/frame/support/test/compile_pass/Cargo.toml +++ b/frame/support/test/compile_pass/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../system" } diff --git a/frame/support/test/pallet/Cargo.toml b/frame/support/test/pallet/Cargo.toml index bf5febeb45..135d0e64b8 100644 --- a/frame/support/test/pallet/Cargo.toml +++ b/frame/support/test/pallet/Cargo.toml @@ -12,7 +12,7 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../system" } diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 55c9b5bda5..7f573a9cbd 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } diff --git a/frame/system/benchmarking/Cargo.toml b/frame/system/benchmarking/Cargo.toml index 30b299ea6a..8f00097254 100644 --- a/frame/system/benchmarking/Cargo.toml +++ b/frame/system/benchmarking/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } diff --git a/frame/system/rpc/runtime-api/Cargo.toml b/frame/system/rpc/runtime-api/Cargo.toml index 63d76d731e..cedb4e35be 100644 --- a/frame/system/rpc/runtime-api/Cargo.toml +++ b/frame/system/rpc/runtime-api/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } [features] diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index df63ed0d72..84c56da24e 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/tips/Cargo.toml b/frame/tips/Cargo.toml index 7d0576ec28..c7db61613c 100644 --- a/frame/tips/Cargo.toml +++ b/frame/tips/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index a2f77b6cf2..0c98796e4d 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/frame/transaction-payment/asset-tx-payment/Cargo.toml b/frame/transaction-payment/asset-tx-payment/Cargo.toml index 8e4645a267..324e17a080 100644 --- a/frame/transaction-payment/asset-tx-payment/Cargo.toml +++ b/frame/transaction-payment/asset-tx-payment/Cargo.toml @@ -25,7 +25,7 @@ pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../benchmarking", optional = true } # Other dependencies -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index b77143201f..b9bf226e2d 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", path = "./runtime-api" } sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index 86753526fe..854e4310b4 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, path = "../../../transaction-payment" } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../../../primitives/runtime" } diff --git a/frame/transaction-storage/Cargo.toml b/frame/transaction-storage/Cargo.toml index 73867c3643..527ff4f240 100644 --- a/frame/transaction-storage/Cargo.toml +++ b/frame/transaction-storage/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = { version = "4.1", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index 993f89ff0f..1fd1d7b3d4 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", "max-encoded-len", ] } diff --git a/frame/try-runtime/Cargo.toml b/frame/try-runtime/Cargo.toml index 87aca0d1ed..042dba5ed8 100644 --- a/frame/try-runtime/Cargo.toml +++ b/frame/try-runtime/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME pallet for democracy" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"]} +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"]} frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } diff --git a/frame/uniques/Cargo.toml b/frame/uniques/Cargo.toml index 6e36240748..a01ea60d8c 100644 --- a/frame/uniques/Cargo.toml +++ b/frame/uniques/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index de293ed5df..099526d3dc 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/frame/vesting/Cargo.toml b/frame/vesting/Cargo.toml index 23fa06454b..c18d1f45e0 100644 --- a/frame/vesting/Cargo.toml +++ b/frame/vesting/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } log = { version = "0.4.17", default-features = false } diff --git a/frame/whitelist/Cargo.toml b/frame/whitelist/Cargo.toml index f3f44d3187..56ceaca9f8 100644 --- a/frame/whitelist/Cargo.toml +++ b/frame/whitelist/Cargo.toml @@ -12,7 +12,7 @@ description = "FRAME pallet for whitelisting call, and dispatch from specific or targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.1", default-features = false, features = ["derive"] } frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } diff --git a/primitives/api/Cargo.toml b/primitives/api/Cargo.toml index 3139c66cef..75197bcaea 100644 --- a/primitives/api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } sp-api-proc-macro = { version = "4.0.0-dev", path = "proc-macro" } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-std = { version = "5.0.0", default-features = false, path = "../std" } diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index 7f15287cf3..b3ceb14fe0 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -19,7 +19,7 @@ sp-tracing = { version = "6.0.0", path = "../../tracing" } sp-runtime = { version = "7.0.0", path = "../../runtime" } sp-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } sc-block-builder = { version = "0.10.0-dev", path = "../../../client/block-builder" } -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } sp-state-machine = { version = "0.13.0", path = "../../state-machine" } trybuild = "1.0.74" rustversion = "1.0.6" diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 39a3413bcf..e7aa118dfd 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] sp-core = { version = "7.0.0", default-features = false, path = "../core" } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true, features = ["derive"] } sp-std = { version = "5.0.0", default-features = false, path = "../std" } diff --git a/primitives/arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml index 2da8767fd2..bbb4bbd177 100644 --- a/primitives/arithmetic/Cargo.toml +++ b/primitives/arithmetic/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", "max-encoded-len", ] } diff --git a/primitives/arithmetic/src/lib.rs b/primitives/arithmetic/src/lib.rs index f1f8fc8b59..590aaa3166 100644 --- a/primitives/arithmetic/src/lib.rs +++ b/primitives/arithmetic/src/lib.rs @@ -50,14 +50,14 @@ pub use rational::{Rational128, RationalInfinite}; use sp_std::{cmp::Ordering, fmt::Debug, prelude::*}; use traits::{BaseArithmetic, One, SaturatedConversion, Unsigned, Zero}; -use codec::{Decode, Encode}; +use codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; /// Arithmetic errors. -#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo)] +#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum ArithmeticError { /// Underflow. diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 4b450a4da4..ff36cf58d3 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" } sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" } diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index 49107ebed1..31ea3b2d4c 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" } sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" } sp-std = { version = "5.0.0", default-features = false, path = "../std" } diff --git a/primitives/beefy/Cargo.toml b/primitives/beefy/Cargo.toml index b286d9878b..6a22f0383a 100644 --- a/primitives/beefy/Cargo.toml +++ b/primitives/beefy/Cargo.toml @@ -12,7 +12,7 @@ description = "Primitives for BEEFY protocol." targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" } diff --git a/primitives/block-builder/Cargo.toml b/primitives/block-builder/Cargo.toml index 7770a0e210..6ccb7980df 100644 --- a/primitives/block-builder/Cargo.toml +++ b/primitives/block-builder/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" } sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" } sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" } diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 7f5f22fe09..68791852d8 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } futures = "0.3.21" log = "0.4.17" lru = "0.8.1" diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index 51b20e4fb7..001dc4a69a 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" } sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../application-crypto" } diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index 25cb8a2bf6..334fff2811 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } merlin = { version = "2.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 9b4cac722a..83b09f9eb4 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0", features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } futures = { version = "0.3.21", features = ["thread-pool"] } diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index 495372089e..6cc832b5af 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" } sp-core = { version = "7.0.0", default-features = false, path = "../../core" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../runtime" } diff --git a/primitives/consensus/slots/Cargo.toml b/primitives/consensus/slots/Cargo.toml index 3360e80772..a4d85dff6e 100644 --- a/primitives/consensus/slots/Cargo.toml +++ b/primitives/consensus/slots/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0", features = ["derive"], optional = true } sp-std = { version = "5.0.0", default-features = false, path = "../../std" } diff --git a/primitives/consensus/vrf/Cargo.toml b/primitives/consensus/vrf/Cargo.toml index 7159da2aa1..a4f92c30cc 100644 --- a/primitives/consensus/vrf/Cargo.toml +++ b/primitives/consensus/vrf/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false } schnorrkel = { version = "0.9.1", default-features = false, features = ["preaudit_deprecated", "u64_backend"] } sp-core = { version = "7.0.0", default-features = false, path = "../../core" } diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 68c780c473..f9a522178f 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.rs/sp-core" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", "max-encoded-len", ] } diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index c3d32370dc..0777111d88 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } environmental = { version = "1.1.3", default-features = false } sp-std = { version = "5.0.0", default-features = false, path = "../std" } sp-storage = { version = "7.0.0", default-features = false, path = "../storage" } diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index c33646e3cd..39bb6713a2 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } grandpa = { package = "finality-grandpa", version = "0.16.1", default-features = false, features = ["derive-codec"] } log = { version = "0.4.17", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index 8f6d8aef15..c901a6e68a 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } impl-trait-for-tuples = "0.2.2" thiserror = { version = "1.0.30", optional = true } sp-core = { version = "7.0.0", default-features = false, path = "../core" } diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index d83c82c022..e56bfcf560 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] bytes = { version = "1.1.0", default-features = false } -codec = { package = "parity-scale-codec", version = "3.1.3", default-features = false, features = ["bytes"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["bytes"] } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-keystore = { version = "0.13.0", default-features = false, optional = true, path = "../keystore" } sp-std = { version = "5.0.0", default-features = false, path = "../std" } diff --git a/primitives/keystore/Cargo.toml b/primitives/keystore/Cargo.toml index 0d5d7ca563..9386cb5d10 100644 --- a/primitives/keystore/Cargo.toml +++ b/primitives/keystore/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } futures = "0.3.21" merlin = { version = "2.0", default-features = false } parking_lot = { version = "0.12.1", default-features = false } diff --git a/primitives/merkle-mountain-range/Cargo.toml b/primitives/merkle-mountain-range/Cargo.toml index 2e532990a5..97add1ed1d 100644 --- a/primitives/merkle-mountain-range/Cargo.toml +++ b/primitives/merkle-mountain-range/Cargo.toml @@ -12,7 +12,7 @@ description = "Merkle Mountain Range primitives." targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } log = { version = "0.4.17", default-features = false } mmr-lib = { package = "ckb-merkle-mountain-range", version = "0.5.2", default-features = false } diff --git a/primitives/npos-elections/Cargo.toml b/primitives/npos-elections/Cargo.toml index 702986da30..7a4bdbd679 100644 --- a/primitives/npos-elections/Cargo.toml +++ b/primitives/npos-elections/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } sp-arithmetic = { version = "6.0.0", default-features = false, path = "../arithmetic" } diff --git a/primitives/npos-elections/fuzzer/Cargo.toml b/primitives/npos-elections/fuzzer/Cargo.toml index 860ed6b188..8a058cc92e 100644 --- a/primitives/npos-elections/fuzzer/Cargo.toml +++ b/primitives/npos-elections/fuzzer/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] clap = { version = "4.0.9", features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } honggfuzz = "0.5" rand = { version = "0.8", features = ["std", "small_rng"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index da746179e2..f2ddc84b1e 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -20,7 +20,7 @@ sp-std = { version = "5.0.0", default-features = false, path = "../std" } sp-tracing = { version = "6.0.0", default-features = false, path = "../tracing" } sp-runtime-interface-proc-macro = { version = "6.0.0", path = "proc-macro" } sp-externalities = { version = "0.13.0", default-features = false, path = "../externalities" } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["bytes"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["bytes"] } static_assertions = "1.0.0" primitive-types = { version = "0.12.0", default-features = false } sp-storage = { version = "7.0.0", default-features = false, path = "../storage" } diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 79bbda700d..3976de60cd 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "max-encoded-len"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive", "max-encoded-len"] } either = { version = "1.5", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } impl-trait-for-tuples = "0.2.2" diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 96fe7d2487..8a32d0b9b4 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -474,7 +474,7 @@ pub type DispatchResult = sp_std::result::Result<(), DispatchError>; pub type DispatchResultWithInfo = sp_std::result::Result>; /// Reason why a pallet call failed. -#[derive(Eq, Clone, Copy, Encode, Decode, Debug, TypeInfo)] +#[derive(Eq, Clone, Copy, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct ModuleError { /// Module index, matching the metadata module index. @@ -494,7 +494,7 @@ impl PartialEq for ModuleError { } /// Errors related to transactional storage layers. -#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo)] +#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum TransactionalError { /// Too many transactional layers have been spawned. @@ -519,7 +519,7 @@ impl From for DispatchError { } /// Reason why a dispatch call failed. -#[derive(Eq, Clone, Copy, Encode, Decode, Debug, TypeInfo, PartialEq)] +#[derive(Eq, Clone, Copy, Encode, Decode, Debug, TypeInfo, PartialEq, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum DispatchError { /// Some error occurred. @@ -602,7 +602,7 @@ impl From for DispatchError { } /// Description of what went wrong when trying to complete an operation on a token. -#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo)] +#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum TokenError { /// Funds are unavailable. diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index 94f9e8a235..31ec009ab2 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" } sp-core = { version = "7.0.0", default-features = false, path = "../core" } diff --git a/primitives/staking/Cargo.toml b/primitives/staking/Cargo.toml index 35feae43eb..a8e5a543db 100644 --- a/primitives/staking/Cargo.toml +++ b/primitives/staking/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" } diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 06419c5925..595dfe286d 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } hash-db = { version = "0.15.2", default-features = false } log = { version = "0.4.17", optional = true } parking_lot = { version = "0.12.1", optional = true } diff --git a/primitives/storage/Cargo.toml b/primitives/storage/Cargo.toml index eb166ee373..72ebc40fc1 100644 --- a/primitives/storage/Cargo.toml +++ b/primitives/storage/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } impl-serde = { version = "0.4.0", optional = true } ref-cast = "1.0.0" serde = { version = "1.0.136", features = ["derive"], optional = true } diff --git a/primitives/test-primitives/Cargo.toml b/primitives/test-primitives/Cargo.toml index 1d12ed74ee..deb120104b 100644 --- a/primitives/test-primitives/Cargo.toml +++ b/primitives/test-primitives/Cargo.toml @@ -12,7 +12,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } sp-application-crypto = { version = "7.0.0", default-features = false, path = "../application-crypto" } sp-core = { version = "7.0.0", default-features = false, path = "../core" } diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index 5d015086c4..27e306040f 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } futures-timer = { version = "3.0.2", optional = true } log = { version = "0.4.17", optional = true } thiserror = { version = "1.0.30", optional = true } diff --git a/primitives/tracing/Cargo.toml b/primitives/tracing/Cargo.toml index 794785085c..602f83c7b4 100644 --- a/primitives/tracing/Cargo.toml +++ b/primitives/tracing/Cargo.toml @@ -19,7 +19,7 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] [dependencies] sp-std = { version = "5.0.0", path = "../std", default-features = false } -codec = { version = "3.0.0", package = "parity-scale-codec", default-features = false, features = [ +codec = { version = "3.2.2", package = "parity-scale-codec", default-features = false, features = [ "derive", ] } tracing = { version = "0.1.29", default-features = false } diff --git a/primitives/transaction-storage-proof/Cargo.toml b/primitives/transaction-storage-proof/Cargo.toml index ea6419dfaa..565d3d8d29 100644 --- a/primitives/transaction-storage-proof/Cargo.toml +++ b/primitives/transaction-storage-proof/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } log = { version = "0.4.17", optional = true } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-core = { version = "7.0.0", optional = true, path = "../core" } diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 68a5fb17c3..3f045a1cb2 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -19,7 +19,7 @@ harness = false [dependencies] ahash = { version = "0.7.6", optional = true } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } hashbrown = { version = "0.12.3", optional = true } hash-db = { version = "0.15.2", default-features = false } lazy_static = { version = "1.4.0", optional = true } diff --git a/primitives/version/Cargo.toml b/primitives/version/Cargo.toml index 56fabcd566..7d32c540f9 100644 --- a/primitives/version/Cargo.toml +++ b/primitives/version/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } impl-serde = { version = "0.4.0", optional = true } parity-wasm = { version = "0.45", optional = true } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } diff --git a/primitives/version/proc-macro/Cargo.toml b/primitives/version/proc-macro/Cargo.toml index 3d129d4753..abe9e579a2 100644 --- a/primitives/version/proc-macro/Cargo.toml +++ b/primitives/version/proc-macro/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] proc-macro = true [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = [ "derive" ] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive" ] } proc-macro2 = "1.0.37" quote = "1.0.10" syn = { version = "1.0.98", features = ["full", "fold", "extra-traits", "visit"] } diff --git a/primitives/wasm-interface/Cargo.toml b/primitives/wasm-interface/Cargo.toml index 1822ae43ed..69937e6b05 100644 --- a/primitives/wasm-interface/Cargo.toml +++ b/primitives/wasm-interface/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } impl-trait-for-tuples = "0.2.2" log = { version = "0.4.17", optional = true } wasmi = { version = "0.13", optional = true } diff --git a/primitives/weights/Cargo.toml b/primitives/weights/Cargo.toml index 00da83069e..2368b913b3 100644 --- a/primitives/weights/Cargo.toml +++ b/primitives/weights/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.rs/sp-wasm-interface" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true, features = ["derive"] } smallvec = "1.8.0" diff --git a/test-utils/client/Cargo.toml b/test-utils/client/Cargo.toml index 106ec21d79..682c868f29 100644 --- a/test-utils/client/Cargo.toml +++ b/test-utils/client/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" async-trait = "0.1.57" -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" serde = "1.0.136" serde_json = "1.0.85" diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index cff0227d03..2c943c47f3 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -19,7 +19,7 @@ sp-application-crypto = { version = "7.0.0", default-features = false, path = ". sp-consensus-aura = { version = "0.10.0-dev", default-features = false, path = "../../primitives/consensus/aura" } sp-consensus-babe = { version = "0.10.0-dev", default-features = false, path = "../../primitives/consensus/babe" } sp-block-builder = { version = "4.0.0-dev", default-features = false, path = "../../primitives/block-builder" } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" } sp-keyring = { version = "7.0.0", optional = true, path = "../../primitives/keyring" } diff --git a/test-utils/runtime/client/Cargo.toml b/test-utils/runtime/client/Cargo.toml index 2ac944edc6..7d5c9673f6 100644 --- a/test-utils/runtime/client/Cargo.toml +++ b/test-utils/runtime/client/Cargo.toml @@ -12,7 +12,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" sc-block-builder = { version = "0.10.0-dev", path = "../../../client/block-builder" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } diff --git a/test-utils/runtime/transaction-pool/Cargo.toml b/test-utils/runtime/transaction-pool/Cargo.toml index f5cba2b99b..5ce397474f 100644 --- a/test-utils/runtime/transaction-pool/Cargo.toml +++ b/test-utils/runtime/transaction-pool/Cargo.toml @@ -12,7 +12,7 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } futures = "0.3.21" parking_lot = "0.12.1" thiserror = "1.0" diff --git a/utils/fork-tree/Cargo.toml b/utils/fork-tree/Cargo.toml index 4ac176f645..c60ef8fd33 100644 --- a/utils/fork-tree/Cargo.toml +++ b/utils/fork-tree/Cargo.toml @@ -14,4 +14,4 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } diff --git a/utils/frame/benchmarking-cli/Cargo.toml b/utils/frame/benchmarking-cli/Cargo.toml index 9e231b8173..fc23d07b62 100644 --- a/utils/frame/benchmarking-cli/Cargo.toml +++ b/utils/frame/benchmarking-cli/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] array-bytes = "4.1" chrono = "0.4" clap = { version = "4.0.9", features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } comfy-table = { version = "6.0.0", default-features = false } handlebars = "4.2.2" Inflector = "0.11.4" diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index 5a51dbc661..8611ae4980 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -12,7 +12,7 @@ description = "An externalities provided environment that can load itself from r targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } log = "0.4.17" serde = "1.0.136" frame-support = { version = "4.0.0-dev", optional = true, path = "../../../frame/support" } diff --git a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml index dd6456f714..17a68e2f4c 100644 --- a/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml +++ b/utils/frame/rpc/state-trie-migration-rpc/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } serde = { version = "1", features = ["derive"] } log = { version = "0.4.17", default-features = false } diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 0660384692..d75d3a5af5 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -15,7 +15,7 @@ description = "Substrate RPC for FRAME's support" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } jsonrpsee = { version = "0.16.2", features = ["jsonrpsee-types"] } serde = "1" frame-support = { version = "4.0.0-dev", path = "../../../../frame/support" } diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 55fc4b27db..b6848ceb29 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } +codec = { package = "parity-scale-codec", version = "3.2.2" } jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] } futures = "0.3.21" log = "0.4.17" diff --git a/utils/frame/try-runtime/cli/Cargo.toml b/utils/frame/try-runtime/cli/Cargo.toml index ed0f25cae7..8c14ddc291 100644 --- a/utils/frame/try-runtime/cli/Cargo.toml +++ b/utils/frame/try-runtime/cli/Cargo.toml @@ -33,7 +33,7 @@ substrate-rpc-client = { path = "../../rpc/client" } clap = { version = "4.0.9", features = ["derive"] } hex = { version = "0.4.3", default-features = false } log = "0.4.17" -parity-scale-codec = "3.0.0" +parity-scale-codec = "3.2.2" serde = "1.0.136" serde_json = "1.0.85" zstd = { version = "0.11.2", default-features = false } From b85d631d49b93d446074b364eb0e036c5ff12e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Thu, 19 Jan 2023 17:56:35 -0300 Subject: [PATCH 29/80] Remove fixtures from crate (#13181) --- frame/contracts/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index c238bdd14e..0ee9e36f1d 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -8,6 +8,7 @@ homepage = "https://substrate.io" repository = "https://github.com/paritytech/substrate/" description = "FRAME pallet for WASM contracts" readme = "README.md" +include = ["src/**/*", "README.md", "CHANGELOG.md"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] From d7acf9effdbb3a869fb3af75ce4adbb86c29918a Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Thu, 19 Jan 2023 23:21:41 +0100 Subject: [PATCH 30/80] txpool: LOG_TARGET const added (#13180) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * txpool: LOG_TARGET const added part of: #12873 * LOG_TARGET added to tests mod * txpool::api for api * Apply suggestions from code review Co-authored-by: Bastian Köcher * ".git/.scripts/commands/fmt/fmt.sh" Co-authored-by: Bastian Köcher Co-authored-by: command-bot <> --- client/transaction-pool/api/src/lib.rs | 6 ++-- client/transaction-pool/src/api.rs | 3 +- .../transaction-pool/src/enactment_state.rs | 27 +++++++++----- .../transaction-pool/src/graph/base_pool.rs | 14 +++++--- client/transaction-pool/src/graph/listener.rs | 20 +++++++---- client/transaction-pool/src/graph/pool.rs | 15 +++++--- client/transaction-pool/src/graph/ready.rs | 10 +++--- .../src/graph/validated_pool.rs | 27 ++++++++------ client/transaction-pool/src/lib.rs | 26 +++++++------- client/transaction-pool/src/revalidation.rs | 32 ++++++++++++----- client/transaction-pool/tests/pool.rs | 36 ++++++++++--------- 11 files changed, 135 insertions(+), 81 deletions(-) diff --git a/client/transaction-pool/api/src/lib.rs b/client/transaction-pool/api/src/lib.rs index c1e49ad07d..870760962a 100644 --- a/client/transaction-pool/api/src/lib.rs +++ b/client/transaction-pool/api/src/lib.rs @@ -30,6 +30,8 @@ use sp_runtime::{ }; use std::{collections::HashMap, hash::Hash, pin::Pin, sync::Arc}; +const LOG_TARGET: &str = "txpool::api"; + pub use sp_runtime::transaction_validity::{ TransactionLongevity, TransactionPriority, TransactionSource, TransactionTag, }; @@ -353,7 +355,7 @@ impl OffchainSubmitTransaction for TP extrinsic: ::Extrinsic, ) -> Result<(), ()> { log::debug!( - target: "txpool", + target: LOG_TARGET, "(offchain call) Submitting a transaction to the pool: {:?}", extrinsic ); @@ -362,7 +364,7 @@ impl OffchainSubmitTransaction for TP result.map(|_| ()).map_err(|e| { log::warn!( - target: "txpool", + target: LOG_TARGET, "(offchain call) Error submitting a transaction to the pool: {}", e ) diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs index a2b317cfb3..0166dfaced 100644 --- a/client/transaction-pool/src/api.rs +++ b/client/transaction-pool/src/api.rs @@ -18,6 +18,7 @@ //! Chain api required for the transaction pool. +use crate::LOG_TARGET; use codec::Encode; use futures::{ channel::{mpsc, oneshot}, @@ -85,7 +86,7 @@ impl FullChainApi { let metrics = prometheus.map(ApiMetrics::register).and_then(|r| match r { Err(err) => { log::warn!( - target: "txpool", + target: LOG_TARGET, "Failed to register transaction pool api prometheus metrics: {:?}", err, ); diff --git a/client/transaction-pool/src/enactment_state.rs b/client/transaction-pool/src/enactment_state.rs index 382b268315..7252c0dec7 100644 --- a/client/transaction-pool/src/enactment_state.rs +++ b/client/transaction-pool/src/enactment_state.rs @@ -18,6 +18,7 @@ //! Substrate transaction pool implementation. +use crate::LOG_TARGET; use num_traits::CheckedSub; use sc_transaction_pool_api::ChainEvent; use sp_blockchain::TreeRoute; @@ -113,14 +114,14 @@ where }; if skip_maintenance { - log::debug!(target: "txpool", "skip maintain: tree_route would be too long"); + log::debug!(target: LOG_TARGET, "skip maintain: tree_route would be too long"); self.force_update(event); return Ok(EnactmentAction::Skip) } // block was already finalized if self.recent_finalized_block == new_hash { - log::debug!(target: "txpool", "handle_enactment: block already finalized"); + log::debug!(target: LOG_TARGET, "handle_enactment: block already finalized"); return Ok(EnactmentAction::Skip) } @@ -129,9 +130,13 @@ where let tree_route = tree_route(self.recent_best_block, new_hash)?; log::debug!( - target: "txpool", + target: LOG_TARGET, "resolve hash:{:?} finalized:{:?} tree_route:{:?} best_block:{:?} finalized_block:{:?}", - new_hash, finalized, tree_route, self.recent_best_block, self.recent_finalized_block + new_hash, + finalized, + tree_route, + self.recent_best_block, + self.recent_finalized_block ); // check if recently finalized block is on retracted path. this could be @@ -139,9 +144,10 @@ where // best event for some old stale best head. if tree_route.retracted().iter().any(|x| x.hash == self.recent_finalized_block) { log::debug!( - target: "txpool", + target: LOG_TARGET, "Recently finalized block {} would be retracted by ChainEvent {}, skipping", - self.recent_finalized_block, new_hash + self.recent_finalized_block, + new_hash ); return Ok(EnactmentAction::Skip) } @@ -155,7 +161,7 @@ where // remains valid. if tree_route.enacted().is_empty() { log::trace!( - target: "txpool", + target: LOG_TARGET, "handle_enactment: no newly enacted blocks since recent best block" ); return Ok(EnactmentAction::HandleFinalization) @@ -176,7 +182,12 @@ where ChainEvent::NewBestBlock { hash, .. } => self.recent_best_block = *hash, ChainEvent::Finalized { hash, .. } => self.recent_finalized_block = *hash, }; - log::debug!(target: "txpool", "forced update: {:?}, {:?}", self.recent_best_block, self.recent_finalized_block); + log::debug!( + target: LOG_TARGET, + "forced update: {:?}, {:?}", + self.recent_best_block, + self.recent_finalized_block, + ); } } diff --git a/client/transaction-pool/src/graph/base_pool.rs b/client/transaction-pool/src/graph/base_pool.rs index 67580d698b..44371be62c 100644 --- a/client/transaction-pool/src/graph/base_pool.rs +++ b/client/transaction-pool/src/graph/base_pool.rs @@ -22,6 +22,7 @@ use std::{cmp::Ordering, collections::HashSet, fmt, hash, sync::Arc}; +use crate::LOG_TARGET; use log::{debug, trace, warn}; use sc_transaction_pool_api::{error, InPoolTransaction, PoolStatus}; use serde::Serialize; @@ -272,9 +273,9 @@ impl BasePool BasePool if first { - debug!(target: "txpool", "[{:?}] Error importing: {:?}", current_hash, e); + debug!(target: LOG_TARGET, "[{:?}] Error importing: {:?}", current_hash, e); return Err(e) } else { failed.push(current_hash); @@ -347,7 +348,7 @@ impl BasePool BasePool promoted.push(res), Err(e) => { - warn!(target: "txpool", "[{:?}] Failed to promote during pruning: {:?}", hash, e); + warn!( + target: LOG_TARGET, + "[{:?}] Failed to promote during pruning: {:?}", hash, e, + ); failed.push(hash) }, } diff --git a/client/transaction-pool/src/graph/listener.rs b/client/transaction-pool/src/graph/listener.rs index 776749abf2..c603a542c2 100644 --- a/client/transaction-pool/src/graph/listener.rs +++ b/client/transaction-pool/src/graph/listener.rs @@ -18,6 +18,7 @@ use std::{collections::HashMap, fmt::Debug, hash}; +use crate::LOG_TARGET; use linked_hash_map::LinkedHashMap; use log::{debug, trace}; use serde::Serialize; @@ -67,13 +68,13 @@ impl Listener { /// Notify the listeners about extrinsic broadcast. pub fn broadcasted(&mut self, hash: &H, peers: Vec) { - trace!(target: "txpool", "[{:?}] Broadcasted", hash); + trace!(target: LOG_TARGET, "[{:?}] Broadcasted", hash); self.fire(hash, |watcher| watcher.broadcast(peers)); } /// New transaction was added to the ready pool or promoted from the future pool. pub fn ready(&mut self, tx: &H, old: Option<&H>) { - trace!(target: "txpool", "[{:?}] Ready (replaced with {:?})", tx, old); + trace!(target: LOG_TARGET, "[{:?}] Ready (replaced with {:?})", tx, old); self.fire(tx, |watcher| watcher.ready()); if let Some(old) = old { self.fire(old, |watcher| watcher.usurped(tx.clone())); @@ -82,13 +83,13 @@ impl Listener { /// New transaction was added to the future pool. pub fn future(&mut self, tx: &H) { - trace!(target: "txpool", "[{:?}] Future", tx); + trace!(target: LOG_TARGET, "[{:?}] Future", tx); self.fire(tx, |watcher| watcher.future()); } /// Transaction was dropped from the pool because of the limit. pub fn dropped(&mut self, tx: &H, by: Option<&H>) { - trace!(target: "txpool", "[{:?}] Dropped (replaced with {:?})", tx, by); + trace!(target: LOG_TARGET, "[{:?}] Dropped (replaced with {:?})", tx, by); self.fire(tx, |watcher| match by { Some(t) => watcher.usurped(t.clone()), None => watcher.dropped(), @@ -97,13 +98,13 @@ impl Listener { /// Transaction was removed as invalid. pub fn invalid(&mut self, tx: &H) { - debug!(target: "txpool", "[{:?}] Extrinsic invalid", tx); + debug!(target: LOG_TARGET, "[{:?}] Extrinsic invalid", tx); self.fire(tx, |watcher| watcher.invalid()); } /// Transaction was pruned from the pool. pub fn pruned(&mut self, block_hash: BlockHash, tx: &H) { - debug!(target: "txpool", "[{:?}] Pruned at {:?}", tx, block_hash); + debug!(target: LOG_TARGET, "[{:?}] Pruned at {:?}", tx, block_hash); // Get the transactions included in the given block hash. let txs = self.finality_watchers.entry(block_hash).or_insert(vec![]); txs.push(tx.clone()); @@ -134,7 +135,12 @@ impl Listener { pub fn finalized(&mut self, block_hash: BlockHash) { if let Some(hashes) = self.finality_watchers.remove(&block_hash) { for (tx_index, hash) in hashes.into_iter().enumerate() { - log::debug!(target: "txpool", "[{:?}] Sent finalization event (block {:?})", hash, block_hash); + log::debug!( + target: LOG_TARGET, + "[{:?}] Sent finalization event (block {:?})", + hash, + block_hash, + ); self.fire(&hash, |watcher| watcher.finalized(block_hash, tx_index)) } } diff --git a/client/transaction-pool/src/graph/pool.rs b/client/transaction-pool/src/graph/pool.rs index 8e3570d1db..14217d56aa 100644 --- a/client/transaction-pool/src/graph/pool.rs +++ b/client/transaction-pool/src/graph/pool.rs @@ -18,6 +18,7 @@ use std::{collections::HashMap, sync::Arc, time::Duration}; +use crate::LOG_TARGET; use futures::{channel::mpsc::Receiver, Future}; use sc_transaction_pool_api::error; use sp_blockchain::TreeRoute; @@ -208,7 +209,8 @@ impl Pool { ) { let now = Instant::now(); self.validated_pool.resubmit(revalidated_transactions); - log::debug!(target: "txpool", + log::debug!( + target: LOG_TARGET, "Resubmitted. Took {} ms. Status: {:?}", now.elapsed().as_millis(), self.validated_pool.status() @@ -249,7 +251,7 @@ impl Pool { extrinsics: &[ExtrinsicFor], ) -> Result<(), B::Error> { log::debug!( - target: "txpool", + target: LOG_TARGET, "Starting pruning of block {:?} (extrinsics: {})", at, extrinsics.len() @@ -287,7 +289,10 @@ impl Pool { future_tags.extend(validity.provides); } } else { - log::trace!(target: "txpool", "txpool is empty, skipping validation for block {at:?}"); + log::trace!( + target: LOG_TARGET, + "txpool is empty, skipping validation for block {at:?}", + ); } }, } @@ -323,7 +328,7 @@ impl Pool { tags: impl IntoIterator, known_imported_hashes: impl IntoIterator> + Clone, ) -> Result<(), B::Error> { - log::debug!(target: "txpool", "Pruning at {:?}", at); + log::debug!(target: LOG_TARGET, "Pruning at {:?}", at); // Prune all transactions that provide given tags let prune_status = self.validated_pool.prune_tags(tags)?; @@ -342,7 +347,7 @@ impl Pool { let reverified_transactions = self.verify(at, pruned_transactions, CheckBannedBeforeVerify::Yes).await?; - log::trace!(target: "txpool", "Pruning at {:?}. Resubmitting transactions.", at); + log::trace!(target: LOG_TARGET, "Pruning at {:?}. Resubmitting transactions.", at); // And finally - submit reverified transactions back to the pool self.validated_pool.resubmit_pruned( diff --git a/client/transaction-pool/src/graph/ready.rs b/client/transaction-pool/src/graph/ready.rs index b52372a3c4..9040c81b3c 100644 --- a/client/transaction-pool/src/graph/ready.rs +++ b/client/transaction-pool/src/graph/ready.rs @@ -23,6 +23,7 @@ use std::{ sync::Arc, }; +use crate::LOG_TARGET; use log::{debug, trace}; use sc_transaction_pool_api::error; use serde::Serialize; @@ -314,7 +315,7 @@ impl ReadyTransactions { } // add to removed - trace!(target: "txpool", "[{:?}] Removed as part of the subtree.", hash); + trace!(target: LOG_TARGET, "[{:?}] Removed as part of the subtree.", hash); removed.push(tx.transaction.transaction); } } @@ -521,7 +522,7 @@ impl BestIterator { pub fn report_invalid(&mut self, tx: &Arc>) { if let Some(to_report) = self.all.get(&tx.hash) { debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Reported as invalid. Will skip sub-chains while iterating.", to_report.transaction.transaction.hash ); @@ -544,9 +545,8 @@ impl Iterator for BestIterator { // Check if the transaction was marked invalid. if self.invalid.contains(hash) { debug!( - target: "txpool", - "[{:?}] Skipping invalid child transaction while iterating.", - hash + target: LOG_TARGET, + "[{:?}] Skipping invalid child transaction while iterating.", hash, ); continue } diff --git a/client/transaction-pool/src/graph/validated_pool.rs b/client/transaction-pool/src/graph/validated_pool.rs index ab99a090e5..bf8a059af2 100644 --- a/client/transaction-pool/src/graph/validated_pool.rs +++ b/client/transaction-pool/src/graph/validated_pool.rs @@ -22,6 +22,7 @@ use std::{ sync::Arc, }; +use crate::LOG_TARGET; use futures::channel::mpsc::{channel, Sender}; use parking_lot::{Mutex, RwLock}; use sc_transaction_pool_api::{error, PoolStatus, ReadyTransactions}; @@ -199,7 +200,7 @@ impl ValidatedPool { Err(e) => if e.is_full() { log::warn!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Trying to notify an import but the channel is full", hash, ); @@ -230,15 +231,17 @@ impl ValidatedPool { let ready_limit = &self.options.ready; let future_limit = &self.options.future; - log::debug!(target: "txpool", "Pool Status: {:?}", status); + log::debug!(target: LOG_TARGET, "Pool Status: {:?}", status); if ready_limit.is_exceeded(status.ready, status.ready_bytes) || future_limit.is_exceeded(status.future, status.future_bytes) { log::debug!( - target: "txpool", + target: LOG_TARGET, "Enforcing limits ({}/{}kB ready, {}/{}kB future", - ready_limit.count, ready_limit.total_bytes / 1024, - future_limit.count, future_limit.total_bytes / 1024, + ready_limit.count, + ready_limit.total_bytes / 1024, + future_limit.count, + future_limit.total_bytes / 1024, ); // clean up the pool @@ -254,7 +257,7 @@ impl ValidatedPool { removed }; if !removed.is_empty() { - log::debug!(target: "txpool", "Enforcing limits: {} dropped", removed.len()); + log::debug!(target: LOG_TARGET, "Enforcing limits: {} dropped", removed.len()); } // run notifications @@ -385,7 +388,7 @@ impl ValidatedPool { // unknown to caller => let's just notify listeners (and issue debug // message) log::warn!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Removing invalid transaction from update: {}", hash, err, @@ -595,14 +598,14 @@ impl ValidatedPool { return vec![] } - log::debug!(target: "txpool", "Removing invalid transactions: {:?}", hashes); + log::debug!(target: LOG_TARGET, "Removing invalid transactions: {:?}", hashes); // temporarily ban invalid transactions self.rotator.ban(&Instant::now(), hashes.iter().cloned()); let invalid = self.pool.write().remove_subtree(hashes); - log::debug!(target: "txpool", "Removed invalid transactions: {:?}", invalid); + log::debug!(target: LOG_TARGET, "Removed invalid transactions: {:?}", invalid); let mut listener = self.listener.write(); for tx in &invalid { @@ -629,7 +632,11 @@ impl ValidatedPool { /// Notify all watchers that transactions in the block with hash have been finalized pub async fn on_block_finalized(&self, block_hash: BlockHash) -> Result<(), B::Error> { - log::trace!(target: "txpool", "Attempting to notify watchers of finalization for {}", block_hash); + log::trace!( + target: LOG_TARGET, + "Attempting to notify watchers of finalization for {}", + block_hash, + ); self.listener.write().finalized(block_hash); Ok(()) } diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 1cd9bef77b..44bda82da3 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -67,6 +67,8 @@ use prometheus_endpoint::Registry as PrometheusRegistry; use sp_blockchain::{HashAndNumber, TreeRoute}; +pub(crate) const LOG_TARGET: &str = "txpool"; + type BoxedReadyIterator = Box>> + Send>; @@ -116,7 +118,7 @@ impl ReadyPoll { while idx < self.pollers.len() { if self.pollers[idx].0 <= number { let poller_sender = self.pollers.swap_remove(idx); - log::debug!(target: "txpool", "Sending ready signal at block {}", number); + log::debug!(target: LOG_TARGET, "Sending ready signal at block {}", number); let _ = poller_sender.1.send(iterator_factory()); } else { idx += 1; @@ -336,7 +338,7 @@ where } if self.ready_poll.lock().updated_at() >= at { - log::trace!(target: "txpool", "Transaction pool already processed block #{}", at); + log::trace!(target: LOG_TARGET, "Transaction pool already processed block #{}", at); let iterator: ReadyIteratorFor = Box::new(self.pool.validated_pool().ready()); return async move { iterator }.boxed() } @@ -554,16 +556,16 @@ async fn prune_known_txs_for_block>(); - log::trace!(target: "txpool", "Pruning transactions: {:?}", hashes); + log::trace!(target: LOG_TARGET, "Pruning transactions: {:?}", hashes); let header = match api.block_header(block_hash) { Ok(Some(h)) => h, Ok(None) => { - log::debug!(target: "txpool", "Could not find header for {:?}.", block_hash); + log::debug!(target: LOG_TARGET, "Could not find header for {:?}.", block_hash); return hashes }, Err(e) => { - log::debug!(target: "txpool", "Error retrieving header for {:?}: {}", block_hash, e); + log::debug!(target: LOG_TARGET, "Error retrieving header for {:?}: {}", block_hash, e); return hashes }, }; @@ -587,7 +589,7 @@ where /// (that have already been enacted) and resubmits transactions that were /// retracted. async fn handle_enactment(&self, tree_route: TreeRoute) { - log::trace!(target: "txpool", "handle_enactment tree_route: {tree_route:?}"); + log::trace!(target: LOG_TARGET, "handle_enactment tree_route: {tree_route:?}"); let pool = self.pool.clone(); let api = self.api.clone(); @@ -595,7 +597,7 @@ where Some(HashAndNumber { hash, number }) => (hash, number), None => { log::warn!( - target: "txpool", + target: LOG_TARGET, "Skipping ChainEvent - no last block in tree route {:?}", tree_route, ); @@ -666,7 +668,7 @@ where if !contains { log::debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}]: Resubmitting from retracted block {:?}", tx_hash, hash, @@ -691,7 +693,7 @@ where .await { log::debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Error re-submitting transactions: {}", hash, e, @@ -742,7 +744,7 @@ where match result { Err(msg) => { - log::debug!(target: "txpool", "{msg}"); + log::debug!(target: LOG_TARGET, "{msg}"); self.enactment_state.lock().force_update(&event); }, Ok(EnactmentAction::Skip) => return, @@ -754,7 +756,7 @@ where if let ChainEvent::Finalized { hash, tree_route } = event { log::trace!( - target: "txpool", + target: LOG_TARGET, "on-finalized enacted: {tree_route:?}, previously finalized: \ {prev_finalized_block:?}", ); @@ -762,7 +764,7 @@ where for hash in tree_route.iter().chain(std::iter::once(&hash)) { if let Err(e) = self.pool.validated_pool().on_block_finalized(*hash).await { log::warn!( - target: "txpool", + target: LOG_TARGET, "Error occurred while attempting to notify watchers about finalization {}: {}", hash, e ) diff --git a/client/transaction-pool/src/revalidation.rs b/client/transaction-pool/src/revalidation.rs index d8c8bea625..99602b50a2 100644 --- a/client/transaction-pool/src/revalidation.rs +++ b/client/transaction-pool/src/revalidation.rs @@ -24,7 +24,10 @@ use std::{ sync::Arc, }; -use crate::graph::{ChainApi, ExtrinsicHash, NumberFor, Pool, ValidatedTransaction}; +use crate::{ + graph::{ChainApi, ExtrinsicHash, NumberFor, Pool, ValidatedTransaction}, + LOG_TARGET, +}; use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender}; use sp_runtime::{ generic::BlockId, @@ -82,13 +85,23 @@ async fn batch_revalidate( for (validation_result, ext_hash, ext) in validation_results { match validation_result { Ok(Err(TransactionValidityError::Invalid(err))) => { - log::debug!(target: "txpool", "[{:?}]: Revalidation: invalid {:?}", ext_hash, err); + log::debug!( + target: LOG_TARGET, + "[{:?}]: Revalidation: invalid {:?}", + ext_hash, + err, + ); invalid_hashes.push(ext_hash); }, Ok(Err(TransactionValidityError::Unknown(err))) => { // skipping unknown, they might be pushed by valid or invalid transaction // when latter resubmitted. - log::trace!(target: "txpool", "[{:?}]: Unknown during revalidation: {:?}", ext_hash, err); + log::trace!( + target: LOG_TARGET, + "[{:?}]: Unknown during revalidation: {:?}", + ext_hash, + err, + ); }, Ok(Ok(validity)) => { revalidated.insert( @@ -105,7 +118,7 @@ async fn batch_revalidate( }, Err(validation_err) => { log::debug!( - target: "txpool", + target: LOG_TARGET, "[{:?}]: Removing due to error during revalidation: {}", ext_hash, validation_err @@ -183,7 +196,7 @@ impl RevalidationWorker { // we don't add something that already scheduled for revalidation if self.members.contains_key(&ext_hash) { log::trace!( - target: "txpool", + target: LOG_TARGET, "[{:?}] Skipped adding for revalidation: Already there.", ext_hash, ); @@ -231,7 +244,7 @@ impl RevalidationWorker { if batch_len > 0 || this.len() > 0 { log::debug!( - target: "txpool", + target: LOG_TARGET, "Revalidated {} transactions. Left in the queue for revalidation: {}.", batch_len, this.len(), @@ -248,7 +261,7 @@ impl RevalidationWorker { if this.members.len() > 0 { log::debug!( - target: "txpool", + target: LOG_TARGET, "Updated revalidation queue at {:?}. Transactions: {:?}", this.best_block, this.members, @@ -320,14 +333,15 @@ where ) { if transactions.len() > 0 { log::debug!( - target: "txpool", "Sent {} transactions to revalidation queue", + target: LOG_TARGET, + "Sent {} transactions to revalidation queue", transactions.len(), ); } if let Some(ref to_worker) = self.background { if let Err(e) = to_worker.unbounded_send(WorkerPayload { at, transactions }) { - log::warn!(target: "txpool", "Failed to update background worker: {:?}", e); + log::warn!(target: LOG_TARGET, "Failed to update background worker: {:?}", e); } } else { let pool = self.pool.clone(); diff --git a/client/transaction-pool/tests/pool.rs b/client/transaction-pool/tests/pool.rs index 27d62c3250..511f6d9e24 100644 --- a/client/transaction-pool/tests/pool.rs +++ b/client/transaction-pool/tests/pool.rs @@ -45,6 +45,8 @@ use substrate_test_runtime_client::{ }; use substrate_test_runtime_transaction_pool::{uxt, TestApi}; +const LOG_TARGET: &str = "txpool"; + fn pool() -> Pool { Pool::new(Default::default(), true.into(), TestApi::with_alice_nonce(209).into()) } @@ -505,7 +507,7 @@ fn fork_aware_finalization() { canon_watchers.push((watcher, header.hash())); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; b1 = header.hash(); block_on(pool.maintain(event)); @@ -521,7 +523,7 @@ fn fork_aware_finalization() { block_on(pool.submit_and_watch(&BlockId::number(1), SOURCE, from_dave.clone())) .expect("1. Imported"); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> C2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C2: {:?} {:?}", header.hash(), header); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; c2 = header.hash(); block_on(pool.maintain(event)); @@ -536,7 +538,7 @@ fn fork_aware_finalization() { assert_eq!(pool.status().ready, 1); let header = pool.api().push_block_with_parent(c2, vec![from_bob.clone()], true); - log::trace!(target:"txpool", ">> D2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> D2: {:?} {:?}", header.hash(), header); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; d2 = header.hash(); block_on(pool.maintain(event)); @@ -550,7 +552,7 @@ fn fork_aware_finalization() { .expect("1.Imported"); assert_eq!(pool.status().ready, 1); let header = pool.api().push_block_with_parent(b1, vec![from_charlie.clone()], true); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1 = header.hash(); canon_watchers.push((watcher, header.hash())); let event = block_event_with_retracted(header.clone(), d2, pool.api()); @@ -568,7 +570,7 @@ fn fork_aware_finalization() { .expect("1. Imported"); assert_eq!(pool.status().ready, 3); let header = pool.api().push_block_with_parent(c1, vec![xt.clone()], true); - log::trace!(target:"txpool", ">> D1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> D1: {:?} {:?}", header.hash(), header); d1 = header.hash(); canon_watchers.push((w, header.hash())); @@ -584,7 +586,7 @@ fn fork_aware_finalization() { // block E1 { let header = pool.api().push_block_with_parent(d1, vec![from_dave, from_bob], true); - log::trace!(target:"txpool", ">> E1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> E1: {:?} {:?}", header.hash(), header); e1 = header.hash(); let event = ChainEvent::NewBestBlock { hash: header.hash(), tree_route: None }; block_on(pool.maintain(event)); @@ -1115,7 +1117,7 @@ fn switching_fork_with_finalized_works() { pool.api() .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1131,7 +1133,7 @@ fn switching_fork_with_finalized_works() { ); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> B2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B2: {:?} {:?}", header.hash(), header); b2_header = header; } @@ -1193,7 +1195,7 @@ fn switching_fork_multiple_times_works() { pool.api() .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1209,7 +1211,7 @@ fn switching_fork_multiple_times_works() { ); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> B2: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B2: {:?} {:?}", header.hash(), header); b2_header = header; } @@ -1306,7 +1308,7 @@ fn two_blocks_delayed_finalization_works() { .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1320,7 +1322,7 @@ fn two_blocks_delayed_finalization_works() { .push_block_with_parent(b1_header.hash(), vec![from_bob.clone()], true); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1_header = header; } @@ -1334,7 +1336,7 @@ fn two_blocks_delayed_finalization_works() { .push_block_with_parent(c1_header.hash(), vec![from_charlie.clone()], true); assert_eq!(pool.status().ready, 3); - log::trace!(target:"txpool", ">> D1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> D1: {:?} {:?}", header.hash(), header); d1_header = header; } @@ -1418,7 +1420,7 @@ fn delayed_finalization_does_not_retract() { .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1432,7 +1434,7 @@ fn delayed_finalization_does_not_retract() { .push_block_with_parent(b1_header.hash(), vec![from_bob.clone()], true); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1_header = header; } @@ -1513,7 +1515,7 @@ fn best_block_after_finalization_does_not_retract() { .push_block_with_parent(a_header.hash(), vec![from_alice.clone()], true); assert_eq!(pool.status().ready, 1); - log::trace!(target:"txpool", ">> B1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> B1: {:?} {:?}", header.hash(), header); b1_header = header; } @@ -1527,7 +1529,7 @@ fn best_block_after_finalization_does_not_retract() { .push_block_with_parent(b1_header.hash(), vec![from_bob.clone()], true); assert_eq!(pool.status().ready, 2); - log::trace!(target:"txpool", ">> C1: {:?} {:?}", header.hash(), header); + log::trace!(target: LOG_TARGET, ">> C1: {:?} {:?}", header.hash(), header); c1_header = header; } From de943ee152ccedc0b418caac6061409431f74a49 Mon Sep 17 00:00:00 2001 From: Marcin S Date: Fri, 20 Jan 2023 11:19:30 +0100 Subject: [PATCH 31/80] Fix potential huge allocation as a result of `validate_block` output (#13183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix potential huge allocation as a result of `validate_block` output * Address review comments; add more tests * Update client/executor/wasmtime/src/runtime.rs * Remove unnecessary comments Co-authored-by: Bastian Köcher --- Cargo.lock | 2 + client/executor/Cargo.toml | 1 + client/executor/runtime-test/Cargo.toml | 1 + client/executor/runtime-test/src/lib.rs | 37 +++++++++- client/executor/src/integration_tests/mod.rs | 71 +++++++++++++++++++- client/executor/wasmtime/src/runtime.rs | 17 ++++- 6 files changed, 125 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dbb046ccd8..348f23d736 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8270,6 +8270,7 @@ name = "sc-executor" version = "0.10.0-dev" dependencies = [ "array-bytes", + "assert_matches", "criterion", "env_logger", "lru", @@ -8842,6 +8843,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-runtime-interface", "sp-std", "substrate-wasm-builder", ] diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 4604b976b4..8bedcd3edc 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -35,6 +35,7 @@ sp-wasm-interface = { version = "7.0.0", path = "../../primitives/wasm-interface [dev-dependencies] array-bytes = "4.1" +assert_matches = "1.3.0" wat = "1.0" sc-runtime-test = { version = "2.0.0", path = "runtime-test" } substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" } diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index e99f3caa94..07626c2343 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] sp-core = { version = "7.0.0", default-features = false, path = "../../../primitives/core" } sp-io = { version = "7.0.0", default-features = false, features = ["improved_panic_error_reporting"], path = "../../../primitives/io" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-runtime-interface = { version = "7.0.0", default-features = false, path = "../../../primitives/runtime-interface" } sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } [build-dependencies] diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index fc98d1909d..0aa30e4bc9 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -29,6 +29,8 @@ use sp_runtime::{ print, traits::{BlakeTwo256, Hash}, }; +#[cfg(not(feature = "std"))] +use sp_runtime_interface::pack_ptr_and_len; extern "C" { #[allow(dead_code)] @@ -38,6 +40,10 @@ extern "C" { fn yet_another_missing_external(); } +#[cfg(not(feature = "std"))] +/// The size of a WASM page in bytes. +const WASM_PAGE_SIZE: usize = 65536; + #[cfg(not(feature = "std"))] /// Mutable static variables should be always observed to have /// the initialized value at the start of a runtime call. @@ -92,7 +98,7 @@ sp_core::wasm_export_functions! { let heap_ptr = heap_base as usize; // Find the next wasm page boundary. - let heap_ptr = round_up_to(heap_ptr, 65536); + let heap_ptr = round_up_to(heap_ptr, WASM_PAGE_SIZE); // Make it an actual pointer let heap_ptr = heap_ptr as *mut u8; @@ -337,3 +343,32 @@ sp_core::wasm_export_functions! { return 1234; } } + +// Returns a huge len. It should result in an error, and not an allocation. +#[no_mangle] +#[cfg(not(feature = "std"))] +pub extern "C" fn test_return_huge_len(_params: *const u8, _len: usize) -> u64 { + pack_ptr_and_len(0, u32::MAX) +} + +// Returns an offset right at the edge of the wasm memory boundary. With length 0, it should +// succeed. +#[no_mangle] +#[cfg(not(feature = "std"))] +pub extern "C" fn test_return_max_memory_offset(_params: *const u8, _len: usize) -> u64 { + pack_ptr_and_len((core::arch::wasm32::memory_size(0) * WASM_PAGE_SIZE) as u32, 0) +} + +// Returns an offset right at the edge of the wasm memory boundary. With length 1, it should fail. +#[no_mangle] +#[cfg(not(feature = "std"))] +pub extern "C" fn test_return_max_memory_offset_plus_one(_params: *const u8, _len: usize) -> u64 { + pack_ptr_and_len((core::arch::wasm32::memory_size(0) * WASM_PAGE_SIZE) as u32, 1) +} + +// Returns an output that overflows the u32 range. It should result in an error. +#[no_mangle] +#[cfg(not(feature = "std"))] +pub extern "C" fn test_return_overflow(_params: *const u8, _len: usize) -> u64 { + pack_ptr_and_len(u32::MAX, 1) +} diff --git a/client/executor/src/integration_tests/mod.rs b/client/executor/src/integration_tests/mod.rs index 25b999f115..22e651abe9 100644 --- a/client/executor/src/integration_tests/mod.rs +++ b/client/executor/src/integration_tests/mod.rs @@ -19,8 +19,13 @@ #[cfg(target_os = "linux")] mod linux; +use assert_matches::assert_matches; use codec::{Decode, Encode}; -use sc_executor_common::{error::Error, runtime_blob::RuntimeBlob, wasm_runtime::WasmModule}; +use sc_executor_common::{ + error::{Error, WasmError}, + runtime_blob::RuntimeBlob, + wasm_runtime::WasmModule, +}; use sc_runtime_test::wasm_binary_unwrap; use sp_core::{ blake2_128, blake2_256, ed25519, map, @@ -781,3 +786,67 @@ fn return_value(wasm_method: WasmExecutionMethod) { (1234u64).encode() ); } + +test_wasm_execution!(return_huge_len); +fn return_huge_len(wasm_method: WasmExecutionMethod) { + let mut ext = TestExternalities::default(); + let mut ext = ext.ext(); + + match call_in_wasm("test_return_huge_len", &[], wasm_method, &mut ext).unwrap_err() { + Error::Runtime => { + assert_matches!(wasm_method, WasmExecutionMethod::Interpreted); + }, + Error::RuntimeConstruction(WasmError::Other(error)) => { + assert_matches!(wasm_method, WasmExecutionMethod::Compiled { .. }); + assert_eq!(error, "output exceeds bounds of wasm memory"); + }, + error => panic!("unexpected error: {:?}", error), + } +} + +test_wasm_execution!(return_max_memory_offset); +fn return_max_memory_offset(wasm_method: WasmExecutionMethod) { + let mut ext = TestExternalities::default(); + let mut ext = ext.ext(); + + assert_eq!( + call_in_wasm("test_return_max_memory_offset", &[], wasm_method, &mut ext).unwrap(), + ().encode() + ); +} + +test_wasm_execution!(return_max_memory_offset_plus_one); +fn return_max_memory_offset_plus_one(wasm_method: WasmExecutionMethod) { + let mut ext = TestExternalities::default(); + let mut ext = ext.ext(); + + match call_in_wasm("test_return_max_memory_offset_plus_one", &[], wasm_method, &mut ext) + .unwrap_err() + { + Error::Runtime => { + assert_matches!(wasm_method, WasmExecutionMethod::Interpreted); + }, + Error::RuntimeConstruction(WasmError::Other(error)) => { + assert_matches!(wasm_method, WasmExecutionMethod::Compiled { .. }); + assert_eq!(error, "output exceeds bounds of wasm memory"); + }, + error => panic!("unexpected error: {:?}", error), + } +} + +test_wasm_execution!(return_overflow); +fn return_overflow(wasm_method: WasmExecutionMethod) { + let mut ext = TestExternalities::default(); + let mut ext = ext.ext(); + + match call_in_wasm("test_return_overflow", &[], wasm_method, &mut ext).unwrap_err() { + Error::Runtime => { + assert_matches!(wasm_method, WasmExecutionMethod::Interpreted); + }, + Error::RuntimeConstruction(WasmError::Other(error)) => { + assert_matches!(wasm_method, WasmExecutionMethod::Compiled { .. }); + assert_eq!(error, "output exceeds bounds of wasm memory"); + }, + error => panic!("unexpected error: {:?}", error), + } +} diff --git a/client/executor/wasmtime/src/runtime.rs b/client/executor/wasmtime/src/runtime.rs index b124fd627d..a45dfa59b9 100644 --- a/client/executor/wasmtime/src/runtime.rs +++ b/client/executor/wasmtime/src/runtime.rs @@ -30,6 +30,7 @@ use sc_executor_common::{ runtime_blob::{ self, DataSegmentsSnapshot, ExposedMutableGlobalsSet, GlobalsSnapshot, RuntimeBlob, }, + util::checked_range, wasm_runtime::{InvokeMethod, WasmInstance, WasmModule}, }; use sp_runtime_interface::unpack_ptr_and_len; @@ -41,7 +42,7 @@ use std::{ Arc, }, }; -use wasmtime::{Engine, Memory, StoreLimits, Table}; +use wasmtime::{AsContext, Engine, Memory, StoreLimits, Table}; pub(crate) struct StoreData { /// The limits we apply to the store. We need to store it here to return a reference to this @@ -793,7 +794,19 @@ fn extract_output_data( output_ptr: u32, output_len: u32, ) -> Result> { + let ctx = instance.store(); + + // Do a length check before allocating. The returned output should not be bigger than the + // available WASM memory. Otherwise, a malicious parachain can trigger a large allocation, + // potentially causing memory exhaustion. + // + // Get the size of the WASM memory in bytes. + let memory_size = ctx.as_context().data().memory().data_size(ctx); + if checked_range(output_ptr as usize, output_len as usize, memory_size).is_none() { + Err(WasmError::Other("output exceeds bounds of wasm memory".into()))? + } let mut output = vec![0; output_len as usize]; - util::read_memory_into(instance.store(), Pointer::new(output_ptr), &mut output)?; + + util::read_memory_into(ctx, Pointer::new(output_ptr), &mut output)?; Ok(output) } From 593c76b7e0249fbacd68b87be71a42a557b47b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 20 Jan 2023 16:59:16 +0100 Subject: [PATCH 32/80] sc-network: Ensure private addresses are disabled if requested (#13185) When running with `--no-private-ipv4` the node should not trying to connect to any private ip addresses. With the switch to libp2p this behavior was broken. Part of this version upgrade was the following pr: https://github.com/libp2p/rust-libp2p/pull/2995. This pr changed the default cache size of `libp2p-identity` from `0` aka disabled to `100`. Together with our implementation that was calling into `identity` to request addresses for a given peer. Before the switch to libp2p 0.50.0 this was returning zero addresses, but now with the cache enabled it started to return addresses. This pr fixes this by only letting discovery return addresses for a peer. It also ensures that we filter private addresses if requested. The cache is also disabled to restore the previous caching behavior, but it will actually not be called anymore. --- client/network/src/peer_info.rs | 12 +++++++----- client/network/src/protocol.rs | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index 97604a82c3..f3402c0af1 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -89,7 +89,9 @@ impl PeerInfoBehaviour { pub fn new(user_agent: String, local_public_key: PublicKey) -> Self { let identify = { let cfg = IdentifyConfig::new("/substrate/1.0".to_string(), local_public_key) - .with_agent_version(user_agent); + .with_agent_version(user_agent) + // We don't need any peer information cached. + .with_cache_size(0); Identify::new(cfg) }; @@ -182,10 +184,10 @@ impl NetworkBehaviour for PeerInfoBehaviour { IntoConnectionHandler::select(self.ping.new_handler(), self.identify.new_handler()) } - fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec { - let mut list = self.ping.addresses_of_peer(peer_id); - list.extend_from_slice(&self.identify.addresses_of_peer(peer_id)); - list + fn addresses_of_peer(&mut self, _: &PeerId) -> Vec { + // Only `Discovery::addresses_of_peer` must be returning addresses to ensure that we + // don't return unwanted addresses. + Vec::new() } fn on_swarm_event(&mut self, event: FromSwarm) { diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index fd25c6526f..cd232334e3 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -965,8 +965,10 @@ where self.behaviour.new_handler() } - fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec { - self.behaviour.addresses_of_peer(peer_id) + fn addresses_of_peer(&mut self, _: &PeerId) -> Vec { + // Only `Discovery::addresses_of_peer` must be returning addresses to ensure that we + // don't return unwanted addresses. + Vec::new() } fn on_swarm_event(&mut self, event: FromSwarm) { From 38ec2d8957d843fa424397f79a484d773eea1454 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Fri, 20 Jan 2023 20:26:12 +0100 Subject: [PATCH 33/80] Warn validators with slow hardware (#12620) * move Metric * run hardware bench if validiator flag is being used * fix rustdoc & update node-template * fix * unused improt * warn * move Requirement * bench_result * ensure_requirements * make the code compile * check if authority * Update client/sysinfo/src/sysinfo.rs Co-authored-by: Oliver Tale-Yazdi * nit fixes * warning signs * Update client/sysinfo/src/sysinfo.rs Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi --- bin/node/cli/src/service.rs | 7 +- client/sysinfo/src/lib.rs | 3 +- client/sysinfo/src/sysinfo.rs | 135 +++++++++++++++++- utils/frame/benchmarking-cli/src/lib.rs | 2 +- .../benchmarking-cli/src/machine/hardware.rs | 91 +----------- .../frame/benchmarking-cli/src/machine/mod.rs | 5 +- 6 files changed, 144 insertions(+), 99 deletions(-) diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index cdee61af3f..ace24f186d 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -21,6 +21,7 @@ //! Service implementation. Specialized wrapper over substrate service. use codec::Encode; +use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use frame_system_rpc_runtime_api::AccountNonceApi; use futures::prelude::*; use kitchensink_runtime::RuntimeApi; @@ -320,7 +321,11 @@ pub fn new_full_base( let hwbench = if !disable_hardware_benchmarks { config.database.path().map(|database_path| { let _ = std::fs::create_dir_all(&database_path); - sc_sysinfo::gather_hwbench(Some(database_path)) + sc_sysinfo::gather_hwbench( + Some(database_path), + SUBSTRATE_REFERENCE_HARDWARE.clone(), + config.role.is_authority(), + ) }) } else { None diff --git a/client/sysinfo/src/lib.rs b/client/sysinfo/src/lib.rs index cef5a4d210..f623bdae53 100644 --- a/client/sysinfo/src/lib.rs +++ b/client/sysinfo/src/lib.rs @@ -29,7 +29,8 @@ mod sysinfo_linux; pub use sysinfo::{ benchmark_cpu, benchmark_disk_random_writes, benchmark_disk_sequential_writes, benchmark_memory, benchmark_sr25519_verify, gather_hwbench, gather_sysinfo, - serialize_throughput, serialize_throughput_option, Throughput, + serialize_throughput, serialize_throughput_option, Metric, Requirement, Requirements, + Throughput, }; /// The operating system part of the current target triplet. diff --git a/client/sysinfo/src/sysinfo.rs b/client/sysinfo/src/sysinfo.rs index c66a6f6a62..800df4b8a4 100644 --- a/client/sysinfo/src/sysinfo.rs +++ b/client/sysinfo/src/sysinfo.rs @@ -21,10 +21,10 @@ use crate::{ExecutionLimit, HwBench}; use sc_telemetry::SysInfo; use sp_core::{sr25519, Pair}; use sp_io::crypto::sr25519_verify; -use sp_std::{fmt, prelude::*}; +use sp_std::{fmt, fmt::Formatter, prelude::*}; use rand::{seq::SliceRandom, Rng, RngCore}; -use serde::Serializer; +use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; use std::{ fs::File, io::{Seek, SeekFrom, Write}, @@ -33,6 +33,43 @@ use std::{ time::{Duration, Instant}, }; +/// A single hardware metric. +#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] +pub enum Metric { + /// SR25519 signature verification. + Sr25519Verify, + /// Blake2-256 hashing algorithm. + Blake2256, + /// Copying data in RAM. + MemCopy, + /// Disk sequential write. + DiskSeqWrite, + /// Disk random write. + DiskRndWrite, +} + +impl Metric { + /// The category of the metric. + pub fn category(&self) -> &'static str { + match self { + Self::Sr25519Verify | Self::Blake2256 => "CPU", + Self::MemCopy => "Memory", + Self::DiskSeqWrite | Self::DiskRndWrite => "Disk", + } + } + + /// The name of the metric. It is always prefixed by the [`self.category()`]. + pub fn name(&self) -> &'static str { + match self { + Self::Sr25519Verify => "SR25519-Verify", + Self::Blake2256 => "BLAKE2-256", + Self::MemCopy => "Copy", + Self::DiskSeqWrite => "Seq Write", + Self::DiskRndWrite => "Rnd Write", + } + } +} + /// The unit in which the [`Throughput`] (bytes per second) is denoted. pub enum Unit { GiBs, @@ -137,6 +174,54 @@ where serializer.serialize_none() } +/// Serializes throughput into MiBs and represents it as `f64`. +fn serialize_throughput_as_f64(throughput: &Throughput, serializer: S) -> Result +where + S: Serializer, +{ + serializer.serialize_f64(throughput.as_mibs()) +} + +struct ThroughputVisitor; +impl<'de> Visitor<'de> for ThroughputVisitor { + type Value = Throughput; + + fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + formatter.write_str("A value that is a f64.") + } + + fn visit_f64(self, value: f64) -> Result + where + E: serde::de::Error, + { + Ok(Throughput::from_mibs(value)) + } +} + +fn deserialize_throughput<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + Ok(deserializer.deserialize_f64(ThroughputVisitor))? +} + +/// Multiple requirements for the hardware. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct Requirements(pub Vec); + +/// A single requirement for the hardware. +#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] +pub struct Requirement { + /// The metric to measure. + pub metric: Metric, + /// The minimal throughput that needs to be archived for this requirement. + #[serde( + serialize_with = "serialize_throughput_as_f64", + deserialize_with = "deserialize_throughput" + )] + pub minimum: Throughput, +} + #[inline(always)] pub(crate) fn benchmark( name: &str, @@ -503,8 +588,14 @@ pub fn benchmark_sr25519_verify(limit: ExecutionLimit) -> Throughput { /// Benchmarks the hardware and returns the results of those benchmarks. /// -/// Optionally accepts a path to a `scratch_directory` to use to benchmark the disk. -pub fn gather_hwbench(scratch_directory: Option<&Path>) -> HwBench { +/// Optionally accepts a path to a `scratch_directory` to use to benchmark the +/// disk. Also accepts the `requirements` for the hardware benchmark and a +/// boolean to specify if the node is an authority. +pub fn gather_hwbench( + scratch_directory: Option<&Path>, + requirements: Requirements, + is_authority: bool, +) -> HwBench { #[allow(unused_mut)] let mut hwbench = HwBench { cpu_hashrate_score: benchmark_cpu(DEFAULT_CPU_EXECUTION_LIMIT), @@ -534,9 +625,45 @@ pub fn gather_hwbench(scratch_directory: Option<&Path>) -> HwBench { }; } + if is_authority { + ensure_requirements(hwbench.clone(), requirements); + } + hwbench } +fn ensure_requirements(hwbench: HwBench, requirements: Requirements) { + let mut failed = 0; + for requirement in requirements.0.iter() { + match requirement.metric { + Metric::Blake2256 => + if requirement.minimum > hwbench.cpu_hashrate_score { + failed += 1; + }, + Metric::MemCopy => + if requirement.minimum > hwbench.memory_memcpy_score { + failed += 1; + }, + Metric::DiskSeqWrite => + if let Some(score) = hwbench.disk_sequential_write_score { + if requirement.minimum > score { + failed += 1; + } + }, + Metric::DiskRndWrite => + if let Some(score) = hwbench.disk_random_write_score { + if requirement.minimum > score { + failed += 1; + } + }, + Metric::Sr25519Verify => {}, + } + } + if failed != 0 { + log::warn!("⚠️ Your hardware performance score was less than expected for role 'Authority'. See https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware"); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/utils/frame/benchmarking-cli/src/lib.rs b/utils/frame/benchmarking-cli/src/lib.rs index a44a208b16..5723a8038f 100644 --- a/utils/frame/benchmarking-cli/src/lib.rs +++ b/utils/frame/benchmarking-cli/src/lib.rs @@ -27,7 +27,7 @@ mod storage; pub use block::BlockCmd; pub use extrinsic::{ExtrinsicBuilder, ExtrinsicCmd, ExtrinsicFactory}; -pub use machine::{MachineCmd, Requirements, SUBSTRATE_REFERENCE_HARDWARE}; +pub use machine::{MachineCmd, SUBSTRATE_REFERENCE_HARDWARE}; pub use overhead::OverheadCmd; pub use pallet::PalletCmd; pub use sc_service::BasePath; diff --git a/utils/frame/benchmarking-cli/src/machine/hardware.rs b/utils/frame/benchmarking-cli/src/machine/hardware.rs index 50c88ec746..318c193d7c 100644 --- a/utils/frame/benchmarking-cli/src/machine/hardware.rs +++ b/utils/frame/benchmarking-cli/src/machine/hardware.rs @@ -18,40 +18,7 @@ //! Contains types to define hardware requirements. use lazy_static::lazy_static; -use sc_sysinfo::Throughput; -use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; -use sp_std::{fmt, fmt::Formatter}; - -/// Serializes throughput into MiBs and represents it as `f64`. -fn serialize_throughput_as_f64(throughput: &Throughput, serializer: S) -> Result -where - S: Serializer, -{ - serializer.serialize_f64(throughput.as_mibs()) -} - -struct ThroughputVisitor; -impl<'de> Visitor<'de> for ThroughputVisitor { - type Value = Throughput; - - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { - formatter.write_str("A value that is a f64.") - } - - fn visit_f64(self, value: f64) -> Result - where - E: serde::de::Error, - { - Ok(Throughput::from_mibs(value)) - } -} - -fn deserialize_throughput<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - Ok(deserializer.deserialize_f64(ThroughputVisitor))? -} +use sc_sysinfo::Requirements; lazy_static! { /// The hardware requirements as measured on reference hardware. @@ -67,62 +34,6 @@ lazy_static! { }; } -/// Multiple requirements for the hardware. -#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] -pub struct Requirements(pub Vec); - -/// A single requirement for the hardware. -#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] -pub struct Requirement { - /// The metric to measure. - pub metric: Metric, - /// The minimal throughput that needs to be archived for this requirement. - #[serde( - serialize_with = "serialize_throughput_as_f64", - deserialize_with = "deserialize_throughput" - )] - pub minimum: Throughput, -} - -/// A single hardware metric. -/// -/// The implementation of these is in `sc-sysinfo`. -#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq)] -pub enum Metric { - /// SR25519 signature verification. - Sr25519Verify, - /// Blake2-256 hashing algorithm. - Blake2256, - /// Copying data in RAM. - MemCopy, - /// Disk sequential write. - DiskSeqWrite, - /// Disk random write. - DiskRndWrite, -} - -impl Metric { - /// The category of the metric. - pub fn category(&self) -> &'static str { - match self { - Self::Sr25519Verify | Self::Blake2256 => "CPU", - Self::MemCopy => "Memory", - Self::DiskSeqWrite | Self::DiskRndWrite => "Disk", - } - } - - /// The name of the metric. It is always prefixed by the [`self::category()`]. - pub fn name(&self) -> &'static str { - match self { - Self::Sr25519Verify => "SR25519-Verify", - Self::Blake2256 => "BLAKE2-256", - Self::MemCopy => "Copy", - Self::DiskSeqWrite => "Seq Write", - Self::DiskRndWrite => "Rnd Write", - } - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/utils/frame/benchmarking-cli/src/machine/mod.rs b/utils/frame/benchmarking-cli/src/machine/mod.rs index 82b4e5be73..bcffef255e 100644 --- a/utils/frame/benchmarking-cli/src/machine/mod.rs +++ b/utils/frame/benchmarking-cli/src/machine/mod.rs @@ -30,11 +30,12 @@ use sc_cli::{CliConfiguration, Result, SharedParams}; use sc_service::Configuration; use sc_sysinfo::{ benchmark_cpu, benchmark_disk_random_writes, benchmark_disk_sequential_writes, - benchmark_memory, benchmark_sr25519_verify, ExecutionLimit, Throughput, + benchmark_memory, benchmark_sr25519_verify, ExecutionLimit, Metric, Requirement, Requirements, + Throughput, }; use crate::shared::check_build_profile; -pub use hardware::{Metric, Requirement, Requirements, SUBSTRATE_REFERENCE_HARDWARE}; +pub use hardware::SUBSTRATE_REFERENCE_HARDWARE; /// Command to benchmark the hardware. /// From 2c16842143b92bbfe333498fe1a6dd97733f2080 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Sat, 21 Jan 2023 00:42:00 +0100 Subject: [PATCH 34/80] Use year 2023 in the License headers (#13193) Signed-off-by: Oliver Tale-Yazdi Signed-off-by: Oliver Tale-Yazdi --- HEADER-APACHE2 | 2 +- HEADER-GPL3 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/HEADER-APACHE2 b/HEADER-APACHE2 index 58baa53894..403497a869 100644 --- a/HEADER-APACHE2 +++ b/HEADER-APACHE2 @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/HEADER-GPL3 b/HEADER-GPL3 index 9412b5a70b..ed7daba723 100644 --- a/HEADER-GPL3 +++ b/HEADER-GPL3 @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify From 355e4a9c87f85637185c0852bda9aeb3db404b6d Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Sat, 21 Jan 2023 11:53:07 +0100 Subject: [PATCH 35/80] Move slow hardware warning print logic to CLI (#13198) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move slow hardware warning print logic to CLI Signed-off-by: Oliver Tale-Yazdi * Update client/sysinfo/src/sysinfo.rs Co-authored-by: Bastian Köcher * fmt Signed-off-by: Oliver Tale-Yazdi Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Bastian Köcher --- bin/node/cli/src/service.rs | 21 ++++++----- client/sysinfo/src/sysinfo.rs | 66 +++++++++++++++-------------------- 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index ace24f186d..d77a333dfa 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -318,18 +318,12 @@ pub fn new_full_base( &sc_consensus_babe::BabeLink, ), ) -> Result { - let hwbench = if !disable_hardware_benchmarks { - config.database.path().map(|database_path| { + let hwbench = (!disable_hardware_benchmarks) + .then_some(config.database.path().map(|database_path| { let _ = std::fs::create_dir_all(&database_path); - sc_sysinfo::gather_hwbench( - Some(database_path), - SUBSTRATE_REFERENCE_HARDWARE.clone(), - config.role.is_authority(), - ) - }) - } else { - None - }; + sc_sysinfo::gather_hwbench(Some(database_path)) + })) + .flatten(); let sc_service::PartialComponents { client, @@ -403,6 +397,11 @@ pub fn new_full_base( if let Some(hwbench) = hwbench { sc_sysinfo::print_hwbench(&hwbench); + if !SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) && role.is_authority() { + log::warn!( + "⚠️ The hardware does not meet the minimal requirements for role 'Authority'." + ); + } if let Some(ref mut telemetry) = telemetry { let telemetry_handle = telemetry.handle(); diff --git a/client/sysinfo/src/sysinfo.rs b/client/sysinfo/src/sysinfo.rs index 800df4b8a4..1fbca7d37e 100644 --- a/client/sysinfo/src/sysinfo.rs +++ b/client/sysinfo/src/sysinfo.rs @@ -591,11 +591,7 @@ pub fn benchmark_sr25519_verify(limit: ExecutionLimit) -> Throughput { /// Optionally accepts a path to a `scratch_directory` to use to benchmark the /// disk. Also accepts the `requirements` for the hardware benchmark and a /// boolean to specify if the node is an authority. -pub fn gather_hwbench( - scratch_directory: Option<&Path>, - requirements: Requirements, - is_authority: bool, -) -> HwBench { +pub fn gather_hwbench(scratch_directory: Option<&Path>) -> HwBench { #[allow(unused_mut)] let mut hwbench = HwBench { cpu_hashrate_score: benchmark_cpu(DEFAULT_CPU_EXECUTION_LIMIT), @@ -625,42 +621,38 @@ pub fn gather_hwbench( }; } - if is_authority { - ensure_requirements(hwbench.clone(), requirements); - } - hwbench } -fn ensure_requirements(hwbench: HwBench, requirements: Requirements) { - let mut failed = 0; - for requirement in requirements.0.iter() { - match requirement.metric { - Metric::Blake2256 => - if requirement.minimum > hwbench.cpu_hashrate_score { - failed += 1; - }, - Metric::MemCopy => - if requirement.minimum > hwbench.memory_memcpy_score { - failed += 1; - }, - Metric::DiskSeqWrite => - if let Some(score) = hwbench.disk_sequential_write_score { - if requirement.minimum > score { - failed += 1; - } - }, - Metric::DiskRndWrite => - if let Some(score) = hwbench.disk_random_write_score { - if requirement.minimum > score { - failed += 1; - } - }, - Metric::Sr25519Verify => {}, +impl Requirements { + /// Whether the hardware requirements are met by the provided benchmark results. + pub fn check_hardware(&self, hwbench: &HwBench) -> bool { + for requirement in self.0.iter() { + match requirement.metric { + Metric::Blake2256 => + if requirement.minimum > hwbench.cpu_hashrate_score { + return false + }, + Metric::MemCopy => + if requirement.minimum > hwbench.memory_memcpy_score { + return false + }, + Metric::DiskSeqWrite => + if let Some(score) = hwbench.disk_sequential_write_score { + if requirement.minimum > score { + return false + } + }, + Metric::DiskRndWrite => + if let Some(score) = hwbench.disk_random_write_score { + if requirement.minimum > score { + return false + } + }, + Metric::Sr25519Verify => {}, + } } - } - if failed != 0 { - log::warn!("⚠️ Your hardware performance score was less than expected for role 'Authority'. See https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware"); + true } } From 79cb2e63312b16dc3e50d6df5283f7f7842f9bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 21 Jan 2023 20:00:24 +0100 Subject: [PATCH 36/80] Fix flaky BABE test (#13199) The `authoring_blocks` test of BABE was calculating the slot based on the timestamp it sometimes failed in CI. The problem is that we combine all the notifications and authoring futures in one big future. This one big future may first polls one authoring future to build a block. Then it polls all notification futures again to import the block. Then some other authoring future is polled and builds on the imported block using the same slot and making the import fail. The solution is that we just artificially increase the slot to make the test work. --- client/consensus/babe/src/tests.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index f74864a003..304bc9fc22 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -432,6 +432,7 @@ async fn run_one_test(mutator: impl Fn(&mut TestHeader, Stage) + Send + Sync + ' .for_each(|_| future::ready(())), ); + let client_clone = client.clone(); babe_futures.push( start_babe(BabeParams { block_import: data.block_import.lock().take().expect("import set up during init"), @@ -439,12 +440,19 @@ async fn run_one_test(mutator: impl Fn(&mut TestHeader, Stage) + Send + Sync + ' client, env: environ, sync_oracle: DummyOracle, - create_inherent_data_providers: Box::new(|_, _| async { - let slot = InherentDataProvider::from_timestamp_and_slot_duration( - Timestamp::current(), - SlotDuration::from_millis(SLOT_DURATION_MS), + create_inherent_data_providers: Box::new(move |parent, _| { + // Get the slot of the parent header and just increase this slot. + // + // Below we will running everything in one big future. If we would use + // time based slot, it can happen that on babe instance imports a block from + // another babe instance and then tries to build a block in the same slot making + // this test fail. + let parent_header = client_clone.header(parent).ok().flatten().unwrap(); + let slot = Slot::from( + find_pre_digest::(&parent_header).unwrap().slot() + 1, ); - Ok((slot,)) + + async move { Ok((InherentDataProvider::new(slot),)) } }), force_authoring: false, backoff_authoring_blocks: Some(BackoffAuthoringOnFinalizedHeadLagging::default()), From 1f70226a61807064f3cf95c616d36094358eeb70 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Sun, 22 Jan 2023 21:34:57 +1300 Subject: [PATCH 37/80] Add debug info in assert_has_event and assert_last_event (#12979) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * improve debug info in assert_has_event and assert_last_event * Apply suggestions from code review Co-authored-by: Bastian Köcher Co-authored-by: Bastian Köcher --- frame/system/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 3909b1e9c5..32627896e8 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1503,13 +1503,21 @@ impl Pallet { /// Assert the given `event` exists. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] pub fn assert_has_event(event: T::RuntimeEvent) { - assert!(Self::events().iter().any(|record| record.event == event)) + let events = Self::events(); + assert!( + events.iter().any(|record| record.event == event), + "expected event {event:?} not found in events {events:?}", + ); } /// Assert the last event equal to the given `event`. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] pub fn assert_last_event(event: T::RuntimeEvent) { - assert_eq!(Self::events().last().expect("events expected").event, event); + let last_event = Self::events().last().expect("events expected").event.clone(); + assert_eq!( + last_event, event, + "expected event {event:?} is not equal to the last event {last_event:?}", + ); } /// Return the chain's current runtime version. From ed3f055907116e7c194c1e5d0f884b8329ba70cb Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 23 Jan 2023 02:07:48 -0500 Subject: [PATCH 38/80] new proc-macro-based benchmarking syntax (#12924) * add stub for new benchmark macro * benchmark syntax * add #[extrinsic call] separator * parse #[benchmark] item as a function * proper emission of error when #[extrinsic_call] annotation is missing * clean up * enclosing module via benchmarks! { } working * use an attribute macro on the module instead of benchmarks! { } * cargo fmt * working component implementation * WIP * working * add syntax for Linear * parsing of param ranges (still need to build tuple though) * params parsing WIP * clean up (don't need extrinsic call name) * use proper Result syntax for BenchmarkDef parsing * proper parsing of Linear<0, 1> style args * successfully parse and make use of linear component ranges :boom: * rename support variable => home because eventually will be moved * compile-time check that param range types implement ParamRange * switch to using balances as example, failing on instance pallet * successfully set up __origin and __call with balances :boom: * clean up * use a module * don't need a variable for transfer * rename benchmark_transfer -> transfer because no longer conflicts * clean up * working with transfer_increasing_users as well :boom: * re-add BareBlock * add comments for undocumented structs+functions+traits * refactor in preparation for removing module requirements * switch to a block instead of a module * use the outer macro pattern to to enable #[benchmarks] aggregation * successfully generate SelectedBenchmark :boom: * implement components for SelectedBenchmark * implement instance for SelectedBenchmark * properly track #[extra] * working impl for fn benchmarks() * run_benchmarks WIP * finish run_benchmark! impl :boom: * import balances transfer_best_case benchmark * import transfer_keep_alive balances pallet benchmark * import set_balance_creating balances pallet benchmark * import set_balance_killing balances pallet benchmark * import force_transfer balances pallet benchmark * add #[extra] annotation and docs to transfer_increasing_users * import transfer_all balances pallet benchmark * import force_unreserve balances pallet benchmark * prepare to implement impl_benchmark_test_suite! * ensure tests cover #[extra] before and after #[benchmark] tag * refactor * clean up * fix * move to outer * switch to benchmarks/instance_benchmarks * test impl almost done, strange compiler error * benchmark test suites working :boom: * clean up * add stub and basic parsing for where_clause * working except where clause and extrinsic calls containing method chains * assume option (2) for now wrt https://github.com/paritytech/substrate/pull/12924#issuecomment-1372938718 * clean up * switch to attribute-style * properly handle where clauses * fix subtle missing where clause, now just MessageQueue issues * fix block formatting in message-queue pallet * switch to block vs non-block parsing of extrinsic call * working now but some benchmark tests failing * message-queue tests working (run order issue fixed) :tada: * add comments and internal docs for fame_support_procedural::benchmark * fix license years * docs for lib.rs * add docs to new support procedural macros * don't allow #[benchmark] outside of benchmarking module * add docs * use benchmark(extra, skip_meta) style args * update docs accordingly * appease clippy * bump ci * add notes about `extra` and `skip_meta` * fix doc tests * re-run CI * use `ignore` instead of `no_run` on doc examples * bump CI * replace some if-lets with if-elses * more refactoring of if-let statements * fix remaining if-lets in BenchmarkDef::from() * fix if-lets in benchmarks() * fix remaining if-lets, use nested find_map for extrinsic call * switch to use #[extrinsic_call] or #[block] situationally * refactor ExtrinsicCallDef => BenchmarkCallDef * update docs with info about #[block] * add macro stub for #[extrinsic_call] * fix docs and add stub for #[block] as well * remove unused extern crate line * fix clippy nits * Use V2 bench syntax in pallet-example-basic Just testing the dev-ex... Signed-off-by: Oliver Tale-Yazdi * carry over comment * use curly-brace style for impl_benchmark_test_suite! * remove unneeded parenthesis * proper handling of _() extrinsic call style * add docs for _() syntax * fix crate access * simplify keyword access Co-authored-by: Keith Yeung * simplify module content destructuring Co-authored-by: Keith Yeung * fix crate access "frame_benchmarking" => "frame-benchmarking", compiles * use _() extrinsic call syntax where possible in balances * simplify attr.path.segments.last() Co-authored-by: Keith Yeung * fix compile error being suppressed * simplify extrinsic call keyword parsing Co-authored-by: Keith Yeung * use ? operator instead of return None Co-authored-by: Keith Yeung * rename generics => type_use_generics rename full_generics => type_impl_generics * simplify extrinsic call extraction with transpose * bump CI * nit * proper handling of too many + too few block/extrinsic call annotations * change to B >= A Co-authored-by: Oliver Tale-Yazdi * remove unneeded ignore Co-authored-by: Oliver Tale-Yazdi * remove another ignore Co-authored-by: Oliver Tale-Yazdi * add ui tests * use _() style extrinsic call on accumulate_dummy Co-authored-by: Oliver Tale-Yazdi * add range check to ParamRange * ui test for bad param ranges * fix failing example * add ignore back to other failing example * tweak expr_call span Co-authored-by: Keith Yeung * fix typo * eliminate a match Co-authored-by: Keith Yeung * change pub fn benchmarks to return Result * fix origin error span * more informative error for invalid benchmark parameter name * fix spans on a few benchmark errors * remove unneeded clone * refactor inner loop of benchmark function parsing * preserve mod attributes * refactor outer loop of benchmark def parsing code, greatly simplified * simplify to use a ? operator when parsing benchmark attr path * fix another ? operator * further simplify benchmark function attr parsing with more ? ops * refactor extrinsic call handling to use if let rather than match * replace is_ok => is_err Co-authored-by: Keith Yeung * re-use name during expansion of benchmark def * remove unneeded clone * fix span for origin missing error * fix missing semi Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi Co-authored-by: Keith Yeung Co-authored-by: parity-processbot <> --- Cargo.lock | 14 + frame/balances/src/benchmarking.rs | 127 ++- frame/examples/basic/src/benchmarking.rs | 62 +- frame/message-queue/src/benchmarking.rs | 217 +++-- frame/support/Cargo.toml | 1 + frame/support/procedural/Cargo.toml | 1 + frame/support/procedural/src/benchmark.rs | 860 ++++++++++++++++++ frame/support/procedural/src/lib.rs | 64 ++ frame/support/src/lib.rs | 223 +++++ frame/support/test/Cargo.toml | 2 + frame/support/test/tests/benchmark_ui.rs | 36 + .../test/tests/benchmark_ui/bad_param_name.rs | 18 + .../tests/benchmark_ui/bad_param_name.stderr | 5 + .../benchmark_ui/bad_param_name_too_long.rs | 14 + .../bad_param_name_too_long.stderr | 5 + .../benchmark_ui/bad_param_name_upper_case.rs | 14 + .../bad_param_name_upper_case.stderr | 5 + .../tests/benchmark_ui/bad_param_range.rs | 16 + .../tests/benchmark_ui/bad_param_range.stderr | 5 + .../test/tests/benchmark_ui/bad_params.rs | 18 + .../test/tests/benchmark_ui/bad_params.stderr | 5 + .../test/tests/benchmark_ui/dup_block.rs | 20 + .../test/tests/benchmark_ui/dup_block.stderr | 5 + .../tests/benchmark_ui/dup_extrinsic_call.rs | 20 + .../benchmark_ui/dup_extrinsic_call.stderr | 5 + .../test/tests/benchmark_ui/extra_extra.rs | 16 + .../tests/benchmark_ui/extra_extra.stderr | 5 + .../tests/benchmark_ui/extra_skip_meta.rs | 16 + .../tests/benchmark_ui/extra_skip_meta.stderr | 5 + .../benchmark_ui/extrinsic_call_out_of_fn.rs | 6 + .../extrinsic_call_out_of_fn.stderr | 7 + .../test/tests/benchmark_ui/missing_call.rs | 13 + .../tests/benchmark_ui/missing_call.stderr | 5 + .../test/tests/benchmark_ui/missing_origin.rs | 16 + .../tests/benchmark_ui/missing_origin.stderr | 5 + .../tests/benchmark_ui/pass/valid_basic.rs | 17 + .../tests/benchmark_ui/unrecognized_option.rs | 16 + .../benchmark_ui/unrecognized_option.stderr | 5 + 38 files changed, 1760 insertions(+), 134 deletions(-) create mode 100644 frame/support/procedural/src/benchmark.rs create mode 100644 frame/support/test/tests/benchmark_ui.rs create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_name.rs create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_name.stderr create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_name_too_long.stderr create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.stderr create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_range.rs create mode 100644 frame/support/test/tests/benchmark_ui/bad_param_range.stderr create mode 100644 frame/support/test/tests/benchmark_ui/bad_params.rs create mode 100644 frame/support/test/tests/benchmark_ui/bad_params.stderr create mode 100644 frame/support/test/tests/benchmark_ui/dup_block.rs create mode 100644 frame/support/test/tests/benchmark_ui/dup_block.stderr create mode 100644 frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs create mode 100644 frame/support/test/tests/benchmark_ui/dup_extrinsic_call.stderr create mode 100644 frame/support/test/tests/benchmark_ui/extra_extra.rs create mode 100644 frame/support/test/tests/benchmark_ui/extra_extra.stderr create mode 100644 frame/support/test/tests/benchmark_ui/extra_skip_meta.rs create mode 100644 frame/support/test/tests/benchmark_ui/extra_skip_meta.stderr create mode 100644 frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs create mode 100644 frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.stderr create mode 100644 frame/support/test/tests/benchmark_ui/missing_call.rs create mode 100644 frame/support/test/tests/benchmark_ui/missing_call.stderr create mode 100644 frame/support/test/tests/benchmark_ui/missing_origin.rs create mode 100644 frame/support/test/tests/benchmark_ui/missing_origin.stderr create mode 100644 frame/support/test/tests/benchmark_ui/pass/valid_basic.rs create mode 100644 frame/support/test/tests/benchmark_ui/unrecognized_option.rs create mode 100644 frame/support/test/tests/benchmark_ui/unrecognized_option.stderr diff --git a/Cargo.lock b/Cargo.lock index 348f23d736..08948ffbd9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1614,6 +1614,17 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "derive-syn-parse" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_builder" version = "0.11.2" @@ -2326,6 +2337,7 @@ dependencies = [ "sp-std", "sp-tracing", "sp-weights", + "static_assertions", "tt-call", ] @@ -2335,6 +2347,7 @@ version = "4.0.0-dev" dependencies = [ "Inflector", "cfg-expr", + "derive-syn-parse", "frame-support-procedural-tools", "itertools", "proc-macro2", @@ -2366,6 +2379,7 @@ dependencies = [ name = "frame-support-test" version = "3.0.0" dependencies = [ + "frame-benchmarking", "frame-support", "frame-support-test-pallet", "frame-system", diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs index 206adba0f0..f85ff43b71 100644 --- a/frame/balances/src/benchmarking.rs +++ b/frame/balances/src/benchmarking.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2020-2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2020-2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,22 +20,25 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; +use crate::Pallet as Balances; -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::{account, impl_benchmark_test_suite, whitelisted_caller}; +use frame_support::benchmarking::*; use frame_system::RawOrigin; -use sp_runtime::traits::Bounded; - -use crate::Pallet as Balances; const SEED: u32 = 0; // existential deposit multiplier const ED_MULTIPLIER: u32 = 10; -benchmarks_instance_pallet! { +#[instance_benchmarks] +mod benchmarks { + use super::*; + // Benchmark `transfer` extrinsic with the worst possible conditions: // * Transfer will kill the sender account. // * Transfer will create the recipient account. - transfer { + #[benchmark] + fn transfer() { let existential_deposit = T::ExistentialDeposit::get(); let caller = whitelisted_caller(); @@ -47,53 +50,66 @@ benchmarks_instance_pallet! { // and reap this user. let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup = T::Lookup::unlookup(recipient.clone()); - let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); - }: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount) - verify { + let transfer_amount = + existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); + + #[extrinsic_call] + _(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); + assert_eq!(Balances::::free_balance(&caller), Zero::zero()); assert_eq!(Balances::::free_balance(&recipient), transfer_amount); } // Benchmark `transfer` with the best possible condition: // * Both accounts exist and will continue to exist. - #[extra] - transfer_best_case { + #[benchmark(extra)] + fn transfer_best_case() { let caller = whitelisted_caller(); let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup = T::Lookup::unlookup(recipient.clone()); - // Give the sender account max funds for transfer (their account will never reasonably be killed). - let _ = as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); + // Give the sender account max funds for transfer (their account will never reasonably be + // killed). + let _ = + as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); // Give the recipient account existential deposit (thus their account already exists). let existential_deposit = T::ExistentialDeposit::get(); - let _ = as Currency<_>>::make_free_balance_be(&recipient, existential_deposit); + let _ = + as Currency<_>>::make_free_balance_be(&recipient, existential_deposit); let transfer_amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); - }: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount) - verify { + + #[extrinsic_call] + transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); + assert!(!Balances::::free_balance(&caller).is_zero()); assert!(!Balances::::free_balance(&recipient).is_zero()); } // Benchmark `transfer_keep_alive` with the worst possible condition: // * The recipient account is created. - transfer_keep_alive { + #[benchmark] + fn transfer_keep_alive() { let caller = whitelisted_caller(); let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup = T::Lookup::unlookup(recipient.clone()); // Give the sender account max funds, thus a transfer will not kill account. - let _ = as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); + let _ = + as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); let existential_deposit = T::ExistentialDeposit::get(); let transfer_amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); - }: _(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount) - verify { + + #[extrinsic_call] + _(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); + assert!(!Balances::::free_balance(&caller).is_zero()); assert_eq!(Balances::::free_balance(&recipient), transfer_amount); } // Benchmark `set_balance` coming from ROOT account. This always creates an account. - set_balance_creating { + #[benchmark] + fn set_balance_creating() { let user: T::AccountId = account("user", 0, SEED); let user_lookup = T::Lookup::unlookup(user.clone()); @@ -101,14 +117,17 @@ benchmarks_instance_pallet! { let existential_deposit = T::ExistentialDeposit::get(); let balance_amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); let _ = as Currency<_>>::make_free_balance_be(&user, balance_amount); - }: set_balance(RawOrigin::Root, user_lookup, balance_amount, balance_amount) - verify { + + #[extrinsic_call] + set_balance(RawOrigin::Root, user_lookup, balance_amount, balance_amount); + assert_eq!(Balances::::free_balance(&user), balance_amount); assert_eq!(Balances::::reserved_balance(&user), balance_amount); } // Benchmark `set_balance` coming from ROOT account. This always kills an account. - set_balance_killing { + #[benchmark] + fn set_balance_killing() { let user: T::AccountId = account("user", 0, SEED); let user_lookup = T::Lookup::unlookup(user.clone()); @@ -116,15 +135,18 @@ benchmarks_instance_pallet! { let existential_deposit = T::ExistentialDeposit::get(); let balance_amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); let _ = as Currency<_>>::make_free_balance_be(&user, balance_amount); - }: set_balance(RawOrigin::Root, user_lookup, Zero::zero(), Zero::zero()) - verify { + + #[extrinsic_call] + set_balance(RawOrigin::Root, user_lookup, Zero::zero(), Zero::zero()); + assert!(Balances::::free_balance(&user).is_zero()); } // Benchmark `force_transfer` extrinsic with the worst possible conditions: // * Transfer will kill the sender account. // * Transfer will create the recipient account. - force_transfer { + #[benchmark] + fn force_transfer() { let existential_deposit = T::ExistentialDeposit::get(); let source: T::AccountId = account("source", 0, SEED); let source_lookup = T::Lookup::unlookup(source.clone()); @@ -133,12 +155,16 @@ benchmarks_instance_pallet! { let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); let _ = as Currency<_>>::make_free_balance_be(&source, balance); - // Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user. + // Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, + // and reap this user. let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup = T::Lookup::unlookup(recipient.clone()); - let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); - }: force_transfer(RawOrigin::Root, source_lookup, recipient_lookup, transfer_amount) - verify { + let transfer_amount = + existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); + + #[extrinsic_call] + _(RawOrigin::Root, source_lookup, recipient_lookup, transfer_amount); + assert_eq!(Balances::::free_balance(&source), Zero::zero()); assert_eq!(Balances::::free_balance(&recipient), transfer_amount); } @@ -146,10 +172,9 @@ benchmarks_instance_pallet! { // This benchmark performs the same operation as `transfer` in the worst case scenario, // but additionally introduces many new users into the storage, increasing the the merkle // trie and PoV size. - #[extra] - transfer_increasing_users { + #[benchmark(extra)] + fn transfer_increasing_users(u: Linear<0, 1_000>) { // 1_000 is not very much, but this upper bound can be controlled by the CLI. - let u in 0 .. 1_000; let existential_deposit = T::ExistentialDeposit::get(); let caller = whitelisted_caller(); @@ -161,17 +186,20 @@ benchmarks_instance_pallet! { // and reap this user. let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup = T::Lookup::unlookup(recipient.clone()); - let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); + let transfer_amount = + existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into(); // Create a bunch of users in storage. - for i in 0 .. u { + for i in 0..u { // The `account` function uses `blake2_256` to generate unique accounts, so these // should be quite random and evenly distributed in the trie. let new_user: T::AccountId = account("new_user", i, SEED); let _ = as Currency<_>>::make_free_balance_be(&new_user, balance); } - }: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount) - verify { + + #[extrinsic_call] + transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount); + assert_eq!(Balances::::free_balance(&caller), Zero::zero()); assert_eq!(Balances::::free_balance(&recipient), transfer_amount); } @@ -179,7 +207,8 @@ benchmarks_instance_pallet! { // Benchmark `transfer_all` with the worst possible condition: // * The recipient account is created // * The sender is killed - transfer_all { + #[benchmark] + fn transfer_all() { let caller = whitelisted_caller(); let recipient: T::AccountId = account("recipient", 0, SEED); let recipient_lookup = T::Lookup::unlookup(recipient.clone()); @@ -188,13 +217,16 @@ benchmarks_instance_pallet! { let existential_deposit = T::ExistentialDeposit::get(); let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); let _ = as Currency<_>>::make_free_balance_be(&caller, balance); - }: _(RawOrigin::Signed(caller.clone()), recipient_lookup, false) - verify { + + #[extrinsic_call] + _(RawOrigin::Signed(caller.clone()), recipient_lookup, false); + assert!(Balances::::free_balance(&caller).is_zero()); assert_eq!(Balances::::free_balance(&recipient), balance); } - force_unreserve { + #[benchmark] + fn force_unreserve() { let user: T::AccountId = account("user", 0, SEED); let user_lookup = T::Lookup::unlookup(user.clone()); @@ -208,15 +240,16 @@ benchmarks_instance_pallet! { assert_eq!(Balances::::reserved_balance(&user), balance); assert!(Balances::::free_balance(&user).is_zero()); - }: _(RawOrigin::Root, user_lookup, balance) - verify { + #[extrinsic_call] + _(RawOrigin::Root, user_lookup, balance); + assert!(Balances::::reserved_balance(&user).is_zero()); assert_eq!(Balances::::free_balance(&user), balance); } - impl_benchmark_test_suite!( + impl_benchmark_test_suite! { Balances, crate::tests_composite::ExtBuilder::default().build(), crate::tests_composite::Test, - ) + } } diff --git a/frame/examples/basic/src/benchmarking.rs b/frame/examples/basic/src/benchmarking.rs index 13f069c23e..699e56685f 100644 --- a/frame/examples/basic/src/benchmarking.rs +++ b/frame/examples/basic/src/benchmarking.rs @@ -15,12 +15,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Benchmarking for pallet-example-basic. +//! Benchmarking for `pallet-example-basic`. +// Only enable this module for benchmarking. #![cfg(feature = "runtime-benchmarks")] use crate::*; -use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_benchmarking::{impl_benchmark_test_suite, whitelisted_caller}; +use frame_support::benchmarking::{benchmarks, Linear}; use frame_system::RawOrigin; // To actually run this benchmark on pallet-example-basic, we need to put this pallet into the @@ -33,14 +35,19 @@ use frame_system::RawOrigin; // Details on using the benchmarks macro can be seen at: // https://paritytech.github.io/substrate/master/frame_benchmarking/trait.Benchmarking.html#tymethod.benchmarks -benchmarks! { +#[benchmarks] +mod benchmarks { + use super::*; + // This will measure the execution time of `set_dummy`. - set_dummy_benchmark { + #[benchmark] + fn set_dummy_benchmark() { // This is the benchmark setup phase. // `set_dummy` is a constant time function, hence we hard-code some random value here. let value = 1000u32.into(); - }: set_dummy(RawOrigin::Root, value) // The execution phase is just running `set_dummy` extrinsic call - verify { + #[extrinsic_call] + set_dummy(RawOrigin::Root, value); // The execution phase is just running `set_dummy` extrinsic call + // This is the optional benchmark verification phase, asserting certain states. assert_eq!(Pallet::::dummy(), Some(value)) } @@ -49,22 +56,43 @@ benchmarks! { // The benchmark execution phase is shorthanded. When the name of the benchmark case is the same // as the extrinsic call. `_(...)` is used to represent the extrinsic name. // The benchmark verification phase is omitted. - accumulate_dummy { + #[benchmark] + fn accumulate_dummy() { let value = 1000u32.into(); // The caller account is whitelisted for DB reads/write by the benchmarking macro. let caller: T::AccountId = whitelisted_caller(); - }: _(RawOrigin::Signed(caller), value) + + // You can use `_` if the name of the Call matches the benchmark name. + #[extrinsic_call] + _(RawOrigin::Signed(caller), value); + } + + /// You can write helper functions in here since its a normal Rust module. + fn setup_vector(len: u32) -> Vec { + let mut vector = Vec::::new(); + for i in (0..len).rev() { + vector.push(i); + } + vector + } // This will measure the execution time of sorting a vector. - sort_vector { - let x in 0 .. 10000; - let mut m = Vec::::new(); - for i in (0..x).rev() { - m.push(i); + // + // Define `x` as a linear component with range `[0, =10_000]`. This means that the benchmarking + // will assume that the weight grows at a linear rate depending on `x`. + #[benchmark] + fn sort_vector(x: Linear<0, 10_000>) { + let mut vector = setup_vector(x); + + // The benchmark execution phase could also be a closure with custom code: + #[block] + { + vector.sort(); } - }: { - // The benchmark execution phase could also be a closure with custom code - m.sort(); + + // Check that it was sorted correctly. This will not be benchmarked and is just for + // verification. + vector.windows(2).for_each(|w| assert!(w[0] <= w[1])); } // This line generates test cases for benchmarking, and could be run by: @@ -75,5 +103,5 @@ benchmarks! { // // The line generates three steps per benchmark, with repeat=1 and the three steps are // [low, mid, high] of the range. - impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test) + impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); } diff --git a/frame/message-queue/src/benchmarking.rs b/frame/message-queue/src/benchmarking.rs index 9cd6b75e4d..9651c81e5e 100644 --- a/frame/message-queue/src/benchmarking.rs +++ b/frame/message-queue/src/benchmarking.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,68 +22,85 @@ use super::{mock_helpers::*, Pallet as MessageQueue, *}; -use frame_benchmarking::{benchmarks, whitelisted_caller}; -use frame_support::traits::Get; +use frame_benchmarking::{impl_benchmark_test_suite, whitelisted_caller}; +use frame_support::{benchmarking::*, traits::Get}; use frame_system::RawOrigin; use sp_std::prelude::*; -benchmarks! { - where_clause { - where - // NOTE: We need to generate multiple origins, therefore Origin is `From`. The - // `PartialEq` is for asserting the outcome of the ring (un)knitting and *could* be - // removed if really necessary. - <::MessageProcessor as ProcessMessage>::Origin: From + PartialEq, - ::Size: From, - } +#[benchmarks( + where + <::MessageProcessor as ProcessMessage>::Origin: From + PartialEq, + ::Size: From, + // NOTE: We need to generate multiple origins, therefore Origin is `From`. The + // `PartialEq` is for asserting the outcome of the ring (un)knitting and *could* be + // removed if really necessary. +)] +mod benchmarks { + use super::*; // Worst case path of `ready_ring_knit`. - ready_ring_knit { - let mid: MessageOriginOf:: = 1.into(); + #[benchmark] + fn ready_ring_knit() { + let mid: MessageOriginOf = 1.into(); build_ring::(&[0.into(), mid.clone(), 2.into()]); unknit::(&mid); assert_ring::(&[0.into(), 2.into()]); let mut neighbours = None; - }: { - neighbours = MessageQueue::::ready_ring_knit(&mid).ok(); - } verify { + + #[block] + { + neighbours = MessageQueue::::ready_ring_knit(&mid).ok(); + } + // The neighbours needs to be modified manually. - BookStateFor::::mutate(&mid, |b| { b.ready_neighbours = neighbours }); + BookStateFor::::mutate(&mid, |b| b.ready_neighbours = neighbours); assert_ring::(&[0.into(), 2.into(), mid]); } // Worst case path of `ready_ring_unknit`. - ready_ring_unknit { + #[benchmark] + fn ready_ring_unknit() { build_ring::(&[0.into(), 1.into(), 2.into()]); assert_ring::(&[0.into(), 1.into(), 2.into()]); - let o: MessageOriginOf:: = 0.into(); + let o: MessageOriginOf = 0.into(); let neighbours = BookStateFor::::get(&o).ready_neighbours.unwrap(); - }: { - MessageQueue::::ready_ring_unknit(&o, neighbours); - } verify { + + #[block] + { + MessageQueue::::ready_ring_unknit(&o, neighbours); + } + assert_ring::(&[1.into(), 2.into()]); } // `service_queues` without any queue processing. - service_queue_base { - }: { - MessageQueue::::service_queue(0.into(), &mut WeightMeter::max_limit(), Weight::MAX) + #[benchmark] + fn service_queue_base() { + #[block] + { + MessageQueue::::service_queue(0.into(), &mut WeightMeter::max_limit(), Weight::MAX); + } } // `service_page` without any message processing but with page completion. - service_page_base_completion { + #[benchmark] + fn service_page_base_completion() { let origin: MessageOriginOf = 0.into(); let page = PageOf::::default(); Pages::::insert(&origin, 0, &page); let mut book_state = single_page_book::(); let mut meter = WeightMeter::max_limit(); let limit = Weight::MAX; - }: { - MessageQueue::::service_page(&origin, &mut book_state, &mut meter, limit) + + #[block] + { + MessageQueue::::service_page(&origin, &mut book_state, &mut meter, limit); + } } // `service_page` without any message processing and without page completion. - service_page_base_no_completion { + #[benchmark] + fn service_page_base_no_completion() { let origin: MessageOriginOf = 0.into(); let mut page = PageOf::::default(); // Mock the storage such that `is_complete` returns `false` but `peek_first` returns `None`. @@ -93,49 +110,73 @@ benchmarks! { let mut book_state = single_page_book::(); let mut meter = WeightMeter::max_limit(); let limit = Weight::MAX; - }: { - MessageQueue::::service_page(&origin, &mut book_state, &mut meter, limit) + + #[block] + { + MessageQueue::::service_page(&origin, &mut book_state, &mut meter, limit); + } } // Processing a single message from a page. - service_page_item { + #[benchmark] + fn service_page_item() { let msg = vec![1u8; MaxMessageLenOf::::get() as usize]; let mut page = page::(&msg.clone()); let mut book = book_for::(&page); assert!(page.peek_first().is_some(), "There is one message"); let mut weight = WeightMeter::max_limit(); - }: { - let status = MessageQueue::::service_page_item(&0u32.into(), 0, &mut book, &mut page, &mut weight, Weight::MAX); - assert_eq!(status, ItemExecutionStatus::Executed(true)); - } verify { + + #[block] + { + let status = MessageQueue::::service_page_item( + &0u32.into(), + 0, + &mut book, + &mut page, + &mut weight, + Weight::MAX, + ); + assert_eq!(status, ItemExecutionStatus::Executed(true)); + } + // Check that it was processed. - assert_last_event::(Event::Processed { - hash: T::Hashing::hash(&msg), origin: 0.into(), - weight_used: 1.into_weight(), success: true - }.into()); + assert_last_event::( + Event::Processed { + hash: T::Hashing::hash(&msg), + origin: 0.into(), + weight_used: 1.into_weight(), + success: true, + } + .into(), + ); let (_, processed, _) = page.peek_index(0).unwrap(); assert!(processed); assert_eq!(book.message_count, 0); } // Worst case for calling `bump_service_head`. - bump_service_head { + #[benchmark] + fn bump_service_head() { setup_bump_service_head::(0.into(), 10.into()); let mut weight = WeightMeter::max_limit(); - }: { - MessageQueue::::bump_service_head(&mut weight); - } verify { + + #[block] + { + MessageQueue::::bump_service_head(&mut weight); + } + assert_eq!(ServiceHead::::get().unwrap(), 10u32.into()); assert_eq!(weight.consumed, T::WeightInfo::bump_service_head()); } - reap_page { + #[benchmark] + fn reap_page() { // Mock the storage to get a *cullable* but not *reapable* page. let origin: MessageOriginOf = 0.into(); let mut book = single_page_book::(); let (page, msgs) = full_page::(); - for p in 0 .. T::MaxStale::get() * T::MaxStale::get() { + for p in 0..T::MaxStale::get() * T::MaxStale::get() { if p == 0 { Pages::::insert(&origin, p, &page); } @@ -148,16 +189,19 @@ benchmarks! { BookStateFor::::insert(&origin, &book); assert!(Pages::::contains_key(&origin, 0)); - }: _(RawOrigin::Signed(whitelisted_caller()), 0u32.into(), 0) - verify { - assert_last_event::(Event::PageReaped{ origin: 0.into(), index: 0 }.into()); + #[extrinsic_call] + _(RawOrigin::Signed(whitelisted_caller()), 0u32.into(), 0); + + assert_last_event::(Event::PageReaped { origin: 0.into(), index: 0 }.into()); assert!(!Pages::::contains_key(&origin, 0)); } // Worst case for `execute_overweight` where the page is removed as completed. // - // The worst case occurs when executing the last message in a page of which all are skipped since it is using `peek_index` which has linear complexities. - execute_overweight_page_removed { + // The worst case occurs when executing the last message in a page of which all are skipped + // since it is using `peek_index` which has linear complexities. + #[benchmark] + fn execute_overweight_page_removed() { let origin: MessageOriginOf = 0.into(); let (mut page, msgs) = full_page::(); // Skip all messages. @@ -168,19 +212,34 @@ benchmarks! { let book = book_for::(&page); Pages::::insert(&origin, 0, &page); BookStateFor::::insert(&origin, &book); - }: { - MessageQueue::::execute_overweight(RawOrigin::Signed(whitelisted_caller()).into(), 0u32.into(), 0u32, ((msgs - 1) as u32).into(), Weight::MAX).unwrap() - } - verify { - assert_last_event::(Event::Processed { - hash: T::Hashing::hash(&((msgs - 1) as u32).encode()), origin: 0.into(), - weight_used: Weight::from_parts(1, 1), success: true - }.into()); + + #[block] + { + MessageQueue::::execute_overweight( + RawOrigin::Signed(whitelisted_caller()).into(), + 0u32.into(), + 0u32, + ((msgs - 1) as u32).into(), + Weight::MAX, + ) + .unwrap(); + } + + assert_last_event::( + Event::Processed { + hash: T::Hashing::hash(&((msgs - 1) as u32).encode()), + origin: 0.into(), + weight_used: Weight::from_parts(1, 1), + success: true, + } + .into(), + ); assert!(!Pages::::contains_key(&origin, 0), "Page must be removed"); } // Worst case for `execute_overweight` where the page is updated. - execute_overweight_page_updated { + #[benchmark] + fn execute_overweight_page_updated() { let origin: MessageOriginOf = 0.into(); let (mut page, msgs) = full_page::(); // Skip all messages. @@ -190,16 +249,34 @@ benchmarks! { let book = book_for::(&page); Pages::::insert(&origin, 0, &page); BookStateFor::::insert(&origin, &book); - }: { - MessageQueue::::execute_overweight(RawOrigin::Signed(whitelisted_caller()).into(), 0u32.into(), 0u32, ((msgs - 1) as u32).into(), Weight::MAX).unwrap() - } - verify { - assert_last_event::(Event::Processed { - hash: T::Hashing::hash(&((msgs - 1) as u32).encode()), origin: 0.into(), - weight_used: Weight::from_parts(1, 1), success: true - }.into()); + + #[block] + { + MessageQueue::::execute_overweight( + RawOrigin::Signed(whitelisted_caller()).into(), + 0u32.into(), + 0u32, + ((msgs - 1) as u32).into(), + Weight::MAX, + ) + .unwrap(); + } + + assert_last_event::( + Event::Processed { + hash: T::Hashing::hash(&((msgs - 1) as u32).encode()), + origin: 0.into(), + weight_used: Weight::from_parts(1, 1), + success: true, + } + .into(), + ); assert!(Pages::::contains_key(&origin, 0), "Page must be updated"); } - impl_benchmark_test_suite!(MessageQueue, crate::mock::new_test_ext::(), crate::integration_test::Test); + impl_benchmark_test_suite! { + MessageQueue, + crate::mock::new_test_ext::(), + crate::integration_test::Test + } } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 4f62ae42ef..ae2fc35897 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -27,6 +27,7 @@ sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../pri sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } sp-weights = { version = "4.0.0", default-features = false, path = "../../primitives/weights" } +static_assertions = "1.1.0" tt-call = "1.0.8" frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "./procedural" } paste = "1.0" diff --git a/frame/support/procedural/Cargo.toml b/frame/support/procedural/Cargo.toml index 06b8056aff..ee1ca4dff8 100644 --- a/frame/support/procedural/Cargo.toml +++ b/frame/support/procedural/Cargo.toml @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] proc-macro = true [dependencies] +derive-syn-parse = "0.1.5" Inflector = "0.11.4" cfg-expr = "0.10.3" itertools = "0.10.3" diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs new file mode 100644 index 0000000000..43e3e47de5 --- /dev/null +++ b/frame/support/procedural/src/benchmark.rs @@ -0,0 +1,860 @@ +// This file is part of Substrate. + +// Copyright (C) 2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Home of the parsing and expansion code for the new pallet benchmarking syntax + +use derive_syn_parse::Parse; +use frame_support_procedural_tools::generate_crate_access_2018; +use proc_macro::TokenStream; +use proc_macro2::{Ident, Span, TokenStream as TokenStream2}; +use quote::{quote, quote_spanned, ToTokens}; +use syn::{ + parenthesized, + parse::{Nothing, ParseStream}, + punctuated::Punctuated, + spanned::Spanned, + token::{Colon2, Comma, Gt, Lt, Paren}, + Attribute, Error, Expr, ExprBlock, ExprCall, ExprPath, FnArg, Item, ItemFn, ItemMod, LitInt, + Pat, Path, PathArguments, PathSegment, Result, Stmt, Token, Type, WhereClause, +}; + +mod keywords { + use syn::custom_keyword; + + custom_keyword!(benchmark); + custom_keyword!(benchmarks); + custom_keyword!(block); + custom_keyword!(extra); + custom_keyword!(extrinsic_call); + custom_keyword!(skip_meta); +} + +/// This represents the raw parsed data for a param definition such as `x: Linear<10, 20>`. +#[derive(Clone)] +struct ParamDef { + name: String, + typ: Type, + start: u32, + end: u32, +} + +/// Allows easy parsing of the `<10, 20>` component of `x: Linear<10, 20>`. +#[derive(Parse)] +struct RangeArgs { + _lt_token: Lt, + start: LitInt, + _comma: Comma, + end: LitInt, + _gt_token: Gt, +} + +#[derive(Clone, Debug)] +struct BenchmarkAttrs { + skip_meta: bool, + extra: bool, +} + +/// Represents a single benchmark option +enum BenchmarkAttrKeyword { + Extra, + SkipMeta, +} + +impl syn::parse::Parse for BenchmarkAttrKeyword { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + if lookahead.peek(keywords::extra) { + let _extra: keywords::extra = input.parse()?; + return Ok(BenchmarkAttrKeyword::Extra) + } else if lookahead.peek(keywords::skip_meta) { + let _skip_meta: keywords::skip_meta = input.parse()?; + return Ok(BenchmarkAttrKeyword::SkipMeta) + } else { + return Err(lookahead.error()) + } + } +} + +impl syn::parse::Parse for BenchmarkAttrs { + fn parse(input: ParseStream) -> syn::Result { + let lookahead = input.lookahead1(); + if !lookahead.peek(Paren) { + let _nothing: Nothing = input.parse()?; + return Ok(BenchmarkAttrs { skip_meta: false, extra: false }) + } + let content; + let _paren: Paren = parenthesized!(content in input); + let mut extra = false; + let mut skip_meta = false; + let args = Punctuated::::parse_terminated(&content)?; + for arg in args.into_iter() { + match arg { + BenchmarkAttrKeyword::Extra => { + if extra { + return Err(content.error("`extra` can only be specified once")) + } + extra = true; + }, + BenchmarkAttrKeyword::SkipMeta => { + if skip_meta { + return Err(content.error("`skip_meta` can only be specified once")) + } + skip_meta = true; + }, + } + } + Ok(BenchmarkAttrs { extra, skip_meta }) + } +} + +/// Represents the parsed extrinsic call for a benchmark +#[derive(Clone)] +enum BenchmarkCallDef { + ExtrinsicCall { origin: Expr, expr_call: ExprCall, attr_span: Span }, // #[extrinsic_call] + Block { block: ExprBlock, attr_span: Span }, // #[block] +} + +impl BenchmarkCallDef { + /// Returns the `span()` for attribute + fn attr_span(&self) -> Span { + match self { + BenchmarkCallDef::ExtrinsicCall { origin: _, expr_call: _, attr_span } => *attr_span, + BenchmarkCallDef::Block { block: _, attr_span } => *attr_span, + } + } +} + +/// Represents a parsed `#[benchmark]` or `#[instance_banchmark]` item. +#[derive(Clone)] +struct BenchmarkDef { + params: Vec, + setup_stmts: Vec, + call_def: BenchmarkCallDef, + verify_stmts: Vec, + extra: bool, + skip_meta: bool, +} + +impl BenchmarkDef { + /// Constructs a [`BenchmarkDef`] by traversing an existing [`ItemFn`] node. + pub fn from(item_fn: &ItemFn, extra: bool, skip_meta: bool) -> Result { + let mut params: Vec = Vec::new(); + + // parse params such as "x: Linear<0, 1>" + for arg in &item_fn.sig.inputs { + let invalid_param = |span| { + return Err(Error::new(span, "Invalid benchmark function param. A valid example would be `x: Linear<5, 10>`.", )) + }; + + let FnArg::Typed(arg) = arg else { return invalid_param(arg.span()) }; + let Pat::Ident(ident) = &*arg.pat else { return invalid_param(arg.span()) }; + + // check param name + let var_span = ident.span(); + let invalid_param_name = || { + return Err(Error::new( + var_span, + "Benchmark parameter names must consist of a single lowercase letter (a-z) and no other characters.", + )) + }; + let name = ident.ident.to_token_stream().to_string(); + if name.len() > 1 { + return invalid_param_name() + }; + let Some(name_char) = name.chars().next() else { return invalid_param_name() }; + if !name_char.is_alphabetic() || !name_char.is_lowercase() { + return invalid_param_name() + } + + // parse type + let typ = &*arg.ty; + let Type::Path(tpath) = typ else { return invalid_param(typ.span()) }; + let Some(segment) = tpath.path.segments.last() else { return invalid_param(typ.span()) }; + let args = segment.arguments.to_token_stream().into(); + let Ok(args) = syn::parse::(args) else { return invalid_param(typ.span()) }; + let Ok(start) = args.start.base10_parse::() else { return invalid_param(args.start.span()) }; + let Ok(end) = args.end.base10_parse::() else { return invalid_param(args.end.span()) }; + + if end < start { + return Err(Error::new( + args.start.span(), + "The start of a `ParamRange` must be less than or equal to the end", + )) + } + + params.push(ParamDef { name, typ: typ.clone(), start, end }); + } + + // #[extrinsic_call] / #[block] handling + let call_defs = item_fn.block.stmts.iter().enumerate().filter_map(|(i, child)| { + if let Stmt::Semi(Expr::Call(expr_call), _semi) = child { + // #[extrinsic_call] case + expr_call.attrs.iter().enumerate().find_map(|(k, attr)| { + let segment = attr.path.segments.last()?; + let _: keywords::extrinsic_call = syn::parse(segment.ident.to_token_stream().into()).ok()?; + let mut expr_call = expr_call.clone(); + + // consume #[extrinsic_call] tokens + expr_call.attrs.remove(k); + + // extract origin from expr_call + let Some(origin) = expr_call.args.first().cloned() else { + return Some(Err(Error::new(expr_call.span(), "Single-item extrinsic calls must specify their origin as the first argument."))) + }; + + Some(Ok((i, BenchmarkCallDef::ExtrinsicCall { origin, expr_call, attr_span: attr.span() }))) + }) + } else if let Stmt::Expr(Expr::Block(block)) = child { + // #[block] case + block.attrs.iter().enumerate().find_map(|(k, attr)| { + let segment = attr.path.segments.last()?; + let _: keywords::block = syn::parse(segment.ident.to_token_stream().into()).ok()?; + let mut block = block.clone(); + + // consume #[block] tokens + block.attrs.remove(k); + + Some(Ok((i, BenchmarkCallDef::Block { block, attr_span: attr.span() }))) + }) + } else { + None + } + }).collect::>>()?; + let (i, call_def) = match &call_defs[..] { + [(i, call_def)] => (*i, call_def.clone()), // = 1 + [] => return Err(Error::new( // = 0 + item_fn.block.brace_token.span, + "No valid #[extrinsic_call] or #[block] annotation could be found in benchmark function body." + )), + _ => return Err(Error::new( // > 1 + call_defs[1].1.attr_span(), + "Only one #[extrinsic_call] or #[block] attribute is allowed per benchmark." + )), + }; + + Ok(BenchmarkDef { + params, + setup_stmts: Vec::from(&item_fn.block.stmts[0..i]), + call_def, + verify_stmts: Vec::from(&item_fn.block.stmts[(i + 1)..item_fn.block.stmts.len()]), + extra, + skip_meta, + }) + } +} + +/// Parses and expands a `#[benchmarks]` or `#[instance_benchmarks]` invocation +pub fn benchmarks( + attrs: TokenStream, + tokens: TokenStream, + instance: bool, +) -> syn::Result { + // gather module info + let module: ItemMod = syn::parse(tokens)?; + let mod_span = module.span(); + let where_clause = match syn::parse::(attrs.clone()) { + Ok(_) => quote!(), + Err(_) => syn::parse::(attrs)?.predicates.to_token_stream(), + }; + let mod_vis = module.vis; + let mod_name = module.ident; + + // consume #[benchmarks] attribute by exclusing it from mod_attrs + let mod_attrs: Vec<&Attribute> = module + .attrs + .iter() + .filter(|attr| syn::parse2::(attr.to_token_stream()).is_err()) + .collect(); + + let mut benchmark_names: Vec = Vec::new(); + let mut extra_benchmark_names: Vec = Vec::new(); + let mut skip_meta_benchmark_names: Vec = Vec::new(); + + let (_brace, mut content) = + module.content.ok_or(syn::Error::new(mod_span, "Module cannot be empty!"))?; + + // find all function defs marked with #[benchmark] + let benchmark_fn_metas = content.iter_mut().filter_map(|stmt| { + // parse as a function def first + let Item::Fn(func) = stmt else { return None }; + + // find #[benchmark] attribute on function def + let benchmark_attr = func.attrs.iter().find_map(|attr| { + let seg = attr.path.segments.last()?; + syn::parse::(seg.ident.to_token_stream().into()).ok()?; + Some(attr) + })?; + + Some((benchmark_attr.clone(), func.clone(), stmt)) + }); + + // parse individual benchmark defs and args + for (benchmark_attr, func, stmt) in benchmark_fn_metas { + // parse any args provided to #[benchmark] + let attr_tokens = benchmark_attr.tokens.to_token_stream().into(); + let benchmark_args: BenchmarkAttrs = syn::parse(attr_tokens)?; + + // parse benchmark def + let benchmark_def = + BenchmarkDef::from(&func, benchmark_args.extra, benchmark_args.skip_meta)?; + + // record benchmark name + let name = &func.sig.ident; + benchmark_names.push(name.clone()); + + // record name sets + if benchmark_def.extra { + extra_benchmark_names.push(name.clone()); + } + if benchmark_def.skip_meta { + skip_meta_benchmark_names.push(name.clone()) + } + + // expand benchmark + let expanded = expand_benchmark(benchmark_def, name, instance, where_clause.clone()); + + // replace original function def with expanded code + *stmt = Item::Verbatim(expanded); + } + + // generics + let type_use_generics = match instance { + false => quote!(T), + true => quote!(T, I), + }; + let type_impl_generics = match instance { + false => quote!(T: Config), + true => quote!(T: Config, I: 'static), + }; + + let krate = generate_crate_access_2018("frame-benchmarking")?; + let support = quote!(#krate::frame_support); + + // benchmark name variables + let benchmark_names_str: Vec = benchmark_names.iter().map(|n| n.to_string()).collect(); + let extra_benchmark_names_str: Vec = + extra_benchmark_names.iter().map(|n| n.to_string()).collect(); + let skip_meta_benchmark_names_str: Vec = + skip_meta_benchmark_names.iter().map(|n| n.to_string()).collect(); + let mut selected_benchmark_mappings: Vec = Vec::new(); + let mut benchmarks_by_name_mappings: Vec = Vec::new(); + let test_idents: Vec = benchmark_names_str + .iter() + .map(|n| Ident::new(format!("test_{}", n).as_str(), Span::call_site())) + .collect(); + for i in 0..benchmark_names.len() { + let name_ident = &benchmark_names[i]; + let name_str = &benchmark_names_str[i]; + let test_ident = &test_idents[i]; + selected_benchmark_mappings.push(quote!(#name_str => SelectedBenchmark::#name_ident)); + benchmarks_by_name_mappings.push(quote!(#name_str => Self::#test_ident())) + } + + // emit final quoted tokens + let res = quote! { + #(#mod_attrs) + * + #mod_vis mod #mod_name { + #(#content) + * + + #[allow(non_camel_case_types)] + enum SelectedBenchmark { + #(#benchmark_names), + * + } + + impl<#type_impl_generics> #krate::BenchmarkingSetup<#type_use_generics> for SelectedBenchmark where #where_clause { + fn components(&self) -> #krate::Vec<(#krate::BenchmarkParameter, u32, u32)> { + match self { + #( + Self::#benchmark_names => { + <#benchmark_names as #krate::BenchmarkingSetup<#type_use_generics>>::components(&#benchmark_names) + } + ) + * + } + } + + fn instance( + &self, + components: &[(#krate::BenchmarkParameter, u32)], + verify: bool, + ) -> Result< + #krate::Box Result<(), #krate::BenchmarkError>>, + #krate::BenchmarkError, + > { + match self { + #( + Self::#benchmark_names => { + <#benchmark_names as #krate::BenchmarkingSetup< + #type_use_generics + >>::instance(&#benchmark_names, components, verify) + } + ) + * + } + } + } + #[cfg(any(feature = "runtime-benchmarks", test))] + impl<#type_impl_generics> #krate::Benchmarking for Pallet<#type_use_generics> + where T: frame_system::Config, #where_clause + { + fn benchmarks( + extra: bool, + ) -> #krate::Vec<#krate::BenchmarkMetadata> { + let mut all_names = #krate::vec![ + #(#benchmark_names_str), + * + ]; + if !extra { + let extra = [ + #(#extra_benchmark_names_str), + * + ]; + all_names.retain(|x| !extra.contains(x)); + } + all_names.into_iter().map(|benchmark| { + let selected_benchmark = match benchmark { + #(#selected_benchmark_mappings), + *, + _ => panic!("all benchmarks should be selectable") + }; + let components = >::components(&selected_benchmark); + #krate::BenchmarkMetadata { + name: benchmark.as_bytes().to_vec(), + components, + } + }).collect::<#krate::Vec<_>>() + } + + fn run_benchmark( + extrinsic: &[u8], + c: &[(#krate::BenchmarkParameter, u32)], + whitelist: &[#krate::TrackedStorageKey], + verify: bool, + internal_repeats: u32, + ) -> Result<#krate::Vec<#krate::BenchmarkResult>, #krate::BenchmarkError> { + let extrinsic = #krate::str::from_utf8(extrinsic).map_err(|_| "`extrinsic` is not a valid utf-8 string!")?; + let selected_benchmark = match extrinsic { + #(#selected_benchmark_mappings), + *, + _ => return Err("Could not find extrinsic.".into()), + }; + let mut whitelist = whitelist.to_vec(); + let whitelisted_caller_key = as #support::storage::StorageMap<_, _,>>::hashed_key_for( + #krate::whitelisted_caller::() + ); + whitelist.push(whitelisted_caller_key.into()); + let transactional_layer_key = #krate::TrackedStorageKey::new( + #support::storage::transactional::TRANSACTION_LEVEL_KEY.into(), + ); + whitelist.push(transactional_layer_key); + #krate::benchmarking::set_whitelist(whitelist); + let mut results: #krate::Vec<#krate::BenchmarkResult> = #krate::Vec::new(); + + // Always do at least one internal repeat... + for _ in 0 .. internal_repeats.max(1) { + // Always reset the state after the benchmark. + #krate::defer!(#krate::benchmarking::wipe_db()); + + // Set up the externalities environment for the setup we want to + // benchmark. + let closure_to_benchmark = < + SelectedBenchmark as #krate::BenchmarkingSetup<#type_use_generics> + >::instance(&selected_benchmark, c, verify)?; + + // Set the block number to at least 1 so events are deposited. + if #krate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); + } + + // Commit the externalities to the database, flushing the DB cache. + // This will enable worst case scenario for reading from the database. + #krate::benchmarking::commit_db(); + + // Reset the read/write counter so we don't count operations in the setup process. + #krate::benchmarking::reset_read_write_count(); + + // Time the extrinsic logic. + #krate::log::trace!( + target: "benchmark", + "Start Benchmark: {} ({:?})", + extrinsic, + c + ); + + let start_pov = #krate::benchmarking::proof_size(); + let start_extrinsic = #krate::benchmarking::current_time(); + + closure_to_benchmark()?; + + let finish_extrinsic = #krate::benchmarking::current_time(); + let end_pov = #krate::benchmarking::proof_size(); + + // Calculate the diff caused by the benchmark. + let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); + let diff_pov = match (start_pov, end_pov) { + (Some(start), Some(end)) => end.saturating_sub(start), + _ => Default::default(), + }; + + // Commit the changes to get proper write count + #krate::benchmarking::commit_db(); + #krate::log::trace!( + target: "benchmark", + "End Benchmark: {} ns", elapsed_extrinsic + ); + let read_write_count = #krate::benchmarking::read_write_count(); + #krate::log::trace!( + target: "benchmark", + "Read/Write Count {:?}", read_write_count + ); + + // Time the storage root recalculation. + let start_storage_root = #krate::benchmarking::current_time(); + #krate::storage_root(#krate::StateVersion::V1); + let finish_storage_root = #krate::benchmarking::current_time(); + let elapsed_storage_root = finish_storage_root - start_storage_root; + + let skip_meta = [ #(#skip_meta_benchmark_names_str),* ]; + let read_and_written_keys = if skip_meta.contains(&extrinsic) { + #krate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] + } else { + #krate::benchmarking::get_read_and_written_keys() + }; + + results.push(#krate::BenchmarkResult { + components: c.to_vec(), + 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, + proof_size: diff_pov, + keys: read_and_written_keys, + }); + } + + return Ok(results); + } + } + + #[cfg(test)] + impl<#type_impl_generics> Pallet<#type_use_generics> where T: ::frame_system::Config, #where_clause { + /// Test a particular benchmark by name. + /// + /// This isn't called `test_benchmark_by_name` just in case some end-user eventually + /// writes a benchmark, itself called `by_name`; the function would be shadowed in + /// that case. + /// + /// This is generally intended to be used by child test modules such as those created + /// by the `impl_benchmark_test_suite` macro. However, it is not an error if a pallet + /// author chooses not to implement benchmarks. + #[allow(unused)] + fn test_bench_by_name(name: &[u8]) -> Result<(), #krate::BenchmarkError> { + let name = #krate::str::from_utf8(name) + .map_err(|_| -> #krate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?; + match name { + #(#benchmarks_by_name_mappings), + *, + _ => Err("Could not find test for requested benchmark.".into()), + } + } + } + } + #mod_vis use #mod_name::*; + }; + Ok(res.into()) +} + +/// Prepares a [`Vec`] to be interpolated by [`quote!`] by creating easily-iterable +/// arrays formatted in such a way that they can be interpolated directly. +struct UnrolledParams { + param_ranges: Vec, + param_names: Vec, + param_types: Vec, +} + +impl UnrolledParams { + /// Constructs an [`UnrolledParams`] from a [`Vec`] + fn from(params: &Vec) -> UnrolledParams { + let param_ranges: Vec = params + .iter() + .map(|p| { + let name = Ident::new(&p.name, Span::call_site()); + let start = p.start; + let end = p.end; + quote!(#name, #start, #end) + }) + .collect(); + let param_names: Vec = params + .iter() + .map(|p| { + let name = Ident::new(&p.name, Span::call_site()); + quote!(#name) + }) + .collect(); + let param_types: Vec = params + .iter() + .map(|p| { + let typ = &p.typ; + quote!(#typ) + }) + .collect(); + UnrolledParams { param_ranges, param_names, param_types } + } +} + +/// Performs expansion of an already-parsed [`BenchmarkDef`]. +fn expand_benchmark( + benchmark_def: BenchmarkDef, + name: &Ident, + is_instance: bool, + where_clause: TokenStream2, +) -> TokenStream2 { + // set up variables needed during quoting + let krate = match generate_crate_access_2018("frame-benchmarking") { + Ok(ident) => ident, + Err(err) => return err.to_compile_error().into(), + }; + let home = quote!(#krate::frame_support::benchmarking); + let codec = quote!(#krate::frame_support::codec); + let traits = quote!(#krate::frame_support::traits); + let setup_stmts = benchmark_def.setup_stmts; + let verify_stmts = benchmark_def.verify_stmts; + let test_ident = Ident::new(format!("test_{}", name.to_string()).as_str(), Span::call_site()); + + // unroll params (prepare for quoting) + let unrolled = UnrolledParams::from(&benchmark_def.params); + let param_names = unrolled.param_names; + let param_ranges = unrolled.param_ranges; + let param_types = unrolled.param_types; + + let type_use_generics = match is_instance { + false => quote!(T), + true => quote!(T, I), + }; + + let type_impl_generics = match is_instance { + false => quote!(T: Config), + true => quote!(T: Config, I: 'static), + }; + + let (pre_call, post_call) = match benchmark_def.call_def { + BenchmarkCallDef::ExtrinsicCall { origin, expr_call, attr_span: _ } => { + let mut expr_call = expr_call.clone(); + + // remove first arg from expr_call + let mut final_args = Punctuated::::new(); + let args: Vec<&Expr> = expr_call.args.iter().collect(); + for arg in &args[1..] { + final_args.push((*(*arg)).clone()); + } + expr_call.args = final_args; + + // determine call name (handles `_` and normal call syntax) + let expr_span = expr_call.span(); + let call_err = || { + quote_spanned!(expr_span=> "Extrinsic call must be a function call or `_`".to_compile_error()).into() + }; + let call_name = match *expr_call.func { + Expr::Path(expr_path) => { + // normal function call + let Some(segment) = expr_path.path.segments.last() else { return call_err(); }; + segment.ident.to_string() + }, + Expr::Verbatim(tokens) => { + // `_` style + // replace `_` with fn name + let Ok(_) = syn::parse::(tokens.to_token_stream().into()) else { return call_err(); }; + name.to_string() + }, + _ => return call_err(), + }; + + // modify extrinsic call to be prefixed with "new_call_variant" + let call_name = format!("new_call_variant_{}", call_name); + let mut punct: Punctuated = Punctuated::new(); + punct.push(PathSegment { + arguments: PathArguments::None, + ident: Ident::new(call_name.as_str(), Span::call_site()), + }); + *expr_call.func = Expr::Path(ExprPath { + attrs: vec![], + qself: None, + path: Path { leading_colon: None, segments: punct }, + }); + + ( + // (pre_call, post_call): + quote! { + let __call = Call::<#type_use_generics>::#expr_call; + let __benchmarked_call_encoded = #codec::Encode::encode(&__call); + }, + quote! { + let __call_decoded = as #codec::Decode> + ::decode(&mut &__benchmarked_call_encoded[..]) + .expect("call is encoded above, encoding must be correct"); + let __origin = #origin.into(); + as #traits::UnfilteredDispatchable>::dispatch_bypass_filter( + __call_decoded, + __origin, + )?; + }, + ) + }, + BenchmarkCallDef::Block { block, attr_span: _ } => (quote!(), quote!(#block)), + }; + + // generate final quoted tokens + let res = quote! { + // compile-time assertions that each referenced param type implements ParamRange + #( + #home::assert_impl_all!(#param_types: #home::ParamRange); + )* + + #[allow(non_camel_case_types)] + struct #name; + + #[allow(unused_variables)] + impl<#type_impl_generics> #krate::BenchmarkingSetup<#type_use_generics> + for #name where #where_clause { + fn components(&self) -> #krate::Vec<(#krate::BenchmarkParameter, u32, u32)> { + #krate::vec! [ + #( + (#krate::BenchmarkParameter::#param_ranges) + ),* + ] + } + + fn instance( + &self, + components: &[(#krate::BenchmarkParameter, u32)], + verify: bool + ) -> Result<#krate::Box Result<(), #krate::BenchmarkError>>, #krate::BenchmarkError> { + #( + // prepare instance #param_names + let #param_names = components.iter() + .find(|&c| c.0 == #krate::BenchmarkParameter::#param_names) + .ok_or("Could not find component during benchmark preparation.")? + .1; + )* + + // benchmark setup code + #( + #setup_stmts + )* + #pre_call + Ok(#krate::Box::new(move || -> Result<(), #krate::BenchmarkError> { + #post_call + if verify { + #( + #verify_stmts + )* + } + Ok(()) + })) + } + } + + #[cfg(test)] + impl<#type_impl_generics> Pallet<#type_use_generics> where T: ::frame_system::Config, #where_clause { + #[allow(unused)] + fn #test_ident() -> Result<(), #krate::BenchmarkError> { + let selected_benchmark = SelectedBenchmark::#name; + let components = < + SelectedBenchmark as #krate::BenchmarkingSetup + >::components(&selected_benchmark); + let execute_benchmark = | + c: #krate::Vec<(#krate::BenchmarkParameter, u32)> + | -> Result<(), #krate::BenchmarkError> { + // Always reset the state after the benchmark. + #krate::defer!(#krate::benchmarking::wipe_db()); + + // Set up the benchmark, return execution + verification function. + let closure_to_verify = < + SelectedBenchmark as #krate::BenchmarkingSetup + >::instance(&selected_benchmark, &c, true)?; + + // Set the block number to at least 1 so events are deposited. + if #krate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); + } + + // Run execution + verification + closure_to_verify() + }; + + if components.is_empty() { + execute_benchmark(Default::default())?; + } else { + let num_values: u32 = if let Ok(ev) = std::env::var("VALUES_PER_COMPONENT") { + ev.parse().map_err(|_| { + #krate::BenchmarkError::Stop( + "Could not parse env var `VALUES_PER_COMPONENT` as u32." + ) + })? + } else { + 6 + }; + + if num_values < 2 { + return Err("`VALUES_PER_COMPONENT` must be at least 2".into()); + } + + for (name, low, high) in components.clone().into_iter() { + // Test the lowest, highest (if its different from the lowest) + // and up to num_values-2 more equidistant values in between. + // For 0..10 and num_values=6 this would mean: [0, 2, 4, 6, 8, 10] + + let mut values = #krate::vec![low]; + let diff = (high - low).min(num_values - 1); + let slope = (high - low) as f32 / diff as f32; + + for i in 1..=diff { + let value = ((low as f32 + slope * i as f32) as u32) + .clamp(low, high); + values.push(value); + } + + for component_value in values { + // Select the max value for all the other components. + let c: #krate::Vec<(#krate::BenchmarkParameter, u32)> = components + .iter() + .map(|(n, _, h)| + if *n == name { + (*n, component_value) + } else { + (*n, *h) + } + ) + .collect(); + + execute_benchmark(c)?; + } + } + } + return Ok(()); + } + } + }; + res +} diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 41dbc4ee95..9bdbbd1f27 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -19,6 +19,7 @@ #![recursion_limit = "512"] +mod benchmark; mod clone_no_bound; mod construct_runtime; mod crate_version; @@ -479,6 +480,69 @@ pub fn pallet(attr: TokenStream, item: TokenStream) -> TokenStream { pallet::pallet(attr, item) } +/// An attribute macro that can be attached to a (non-empty) module declaration. Doing so will +/// designate that module as a benchmarking module. +/// +/// See `frame_support::benchmarking` for more info. +#[proc_macro_attribute] +pub fn benchmarks(attr: TokenStream, tokens: TokenStream) -> TokenStream { + match benchmark::benchmarks(attr, tokens, false) { + Ok(tokens) => tokens, + Err(err) => err.to_compile_error().into(), + } +} + +/// An attribute macro that can be attached to a (non-empty) module declaration. Doing so will +/// designate that module as an instance benchmarking module. +/// +/// See `frame_support::benchmarking` for more info. +#[proc_macro_attribute] +pub fn instance_benchmarks(attr: TokenStream, tokens: TokenStream) -> TokenStream { + match benchmark::benchmarks(attr, tokens, true) { + Ok(tokens) => tokens, + Err(err) => err.to_compile_error().into(), + } +} + +/// An attribute macro used to declare a benchmark within a benchmarking module. Must be +/// attached to a function definition containing an `#[extrinsic_call]` or `#[block]` +/// attribute. +/// +/// See `frame_support::benchmarking` for more info. +#[proc_macro_attribute] +pub fn benchmark(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { + quote!(compile_error!( + "`#[benchmark]` must be in a module labeled with #[benchmarks] or #[instance_benchmarks]." + )) + .into() +} + +/// An attribute macro used to specify the extrinsic call inside a benchmark function, and also +/// used as a boundary designating where the benchmark setup code ends, and the benchmark +/// verification code begins. +/// +/// See `frame_support::benchmarking` for more info. +#[proc_macro_attribute] +pub fn extrinsic_call(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { + quote!(compile_error!( + "`#[extrinsic_call]` must be in a benchmark function definition labeled with `#[benchmark]`." + );) + .into() +} + +/// An attribute macro used to specify that a block should be the measured portion of the +/// enclosing benchmark function, This attribute is also used as a boundary designating where +/// the benchmark setup code ends, and the benchmark verification code begins. +/// +/// See `frame_support::benchmarking` for more info. +#[proc_macro_attribute] +pub fn block(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { + quote!(compile_error!( + "`#[block]` must be in a benchmark function definition labeled with `#[benchmark]`." + )) + .into() +} + /// Execute the annotated function in a new storage transaction. /// /// The return type of the annotated function must be `Result`. All changes to storage performed diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 902893972f..40bc878cff 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2745,5 +2745,228 @@ pub mod pallet_macros { }; } +/// Contains macros, structs, and traits associated with v2 of the pallet benchmarking syntax. +/// This module contains macros, structs, and traits associated with v2 of the pallet +/// benchmarking syntax. +/// +/// The [`benchmarking::benchmarks`] and [`benchmarking::instance_benchmarks`] macros can be +/// used to designate a module as a benchmarking module that can contain benchmarks and +/// benchmark tests. The `#[benchmarks]` variant will set up a regular, non-instance +/// benchmarking module, and the `#[instance_benchmarks]` variant will set up the module in +/// instance benchmarking mode. +/// +/// Benchmarking modules should be gated behind a `#[cfg(feature = "runtime-benchmarks")]` +/// feature gate to ensure benchmarking code that is only compiled when the +/// `runtime-benchmarks` feature is enabled is not referenced. +/// +/// The following is the general syntax for a benchmarks (or instance benchmarks) module: +/// +/// ## General Syntax +/// +/// ```ignore +/// #![cfg(feature = "runtime-benchmarks")] +/// +/// use super::{mock_helpers::*, Pallet as MyPallet}; +/// use frame_support::benchmarking::*; +/// use frame_benchmarking::whitelisted_caller; +/// +/// #[benchmarks] +/// mod benchmarks { +/// use super::*; +/// +/// #[benchmark] +/// fn bench_name_1(x: Linear<7, 1_000>, y: Linear<1_000, 100_0000>) { +/// // setup code +/// let z = x + y; +/// let caller = whitelisted_caller(); +/// +/// #[extrinsic_call] +/// extrinsic_name(SystemOrigin::Signed(caller), other, arguments); +/// +/// // verification code +/// assert_eq!(MyPallet::::my_var(), z); +/// } +/// +/// #[benchmark] +/// fn bench_name_2() { +/// // setup code +/// let caller = whitelisted_caller(); +/// +/// #[block] +/// { +/// something(some, thing); +/// my_extrinsic(RawOrigin::Signed(caller), some, argument); +/// something_else(foo, bar); +/// } +/// +/// // verification code +/// assert_eq!(MyPallet::::something(), 37); +/// } +/// } +/// ``` +/// +/// ## Benchmark Definitions +/// +/// Within a `#[benchmarks]` or `#[instance_benchmarks]` module, you can define individual +/// benchmarks using the `#[benchmark]` attribute, as shown in the example above. +/// +/// The `#[benchmark]` attribute expects a function definition with a blank return type and +/// zero or more arguments whose names are valid `frame_benchmarking::BenchmarkParamater` +/// parameters, such as `x`, `y`, `a`, `b`, etc., and whose param types must implement +/// [`benchmarking::ParamRange`]. At the moment the only valid type that implements +/// [`benchmarking::ParamRange`] is [`benchmarking::Linear`]. +/// +/// The valid syntax for defining a `Linear` is `Linear` where `A`, and `B` are +/// valid integer literals (that fit in a `u32`), such that `B` >= `A`. +/// +/// Note that the benchmark function definition does not actually expand as a function +/// definition, but rather is used to automatically create a number of impls and structs +/// required by the benchmarking engine. For this reason, the visibility of the function +/// definition as well as the return type are not used for any purpose and are discarded by the +/// expansion code. +/// +/// Also note that the `// setup code` and `// verification code` comments shown above are not +/// required and are included simply for demonstration purposes. +/// +/// ### `#[extrinsic_call]` and `#[block]` +/// +/// Within the benchmark function body, either an `#[extrinsic_call]` or a `#[block]` +/// annotation is required. These attributes should be attached to a block (shown in +/// `bench_name_2` above) or a one-line function call (shown in `bench_name_1` above, in `syn` +/// parlance this should be an `ExprCall`), respectively. +/// +/// The `#[block]` syntax is broad and will benchmark any code contained within the block the +/// attribute is attached to. If `#[block]` is attached to something other than a block, a +/// compiler error will be emitted. +/// +/// The one-line `#[extrinsic_call]` syntax must consist of a function call to an extrinsic, +/// where the first argument is the origin. If `#[extrinsic_call]` is attached to an item that +/// doesn't meet these requirements, a compiler error will be emitted. +/// +/// As a short-hand, you may substitute the name of the extrinsic call with `_`, such as the +/// following: +/// +/// ```ignore +/// #[extrinsic_call] +/// _(RawOrigin::Signed(whitelisted_caller()), 0u32.into(), 0); +/// ``` +/// +/// The underscore will be substituted with the name of the benchmark (i.e. the name of the +/// function in the benchmark function definition). +/// +/// Regardless of whether `#[extrinsic_call]` or `#[block]` is used, this attribute also serves +/// the purpose of designating the boundary between the setup code portion of the benchmark +/// (everything before the `#[extrinsic_call]` or `#[block]` attribute) and the verification +/// stage (everything after the item that the `#[extrinsic_call]` or `#[block]` attribute is +/// attached to). The setup code section should contain any code that needs to execute before +/// the measured portion of the benchmark executes. The verification section is where you can +/// perform assertions to verify that the extrinsic call (or whatever is happening in your +/// block, if you used the `#[block]` syntax) executed successfully. +/// +/// Note that neither `#[extrinsic_call]` nor `#[block]` are real attribute macros and are +/// instead consumed by the outer macro pattern as part of the enclosing benchmark function +/// definition. This is why we are able to use `#[extrinsic_call]` and `#[block]` within a +/// function definition even though this behavior has not been stabilized +/// yet—`#[extrinsic_call]` and `#[block]` are parsed and consumed as part of the benchmark +/// definition parsing code, so they never expand as their own attribute macros. +/// +/// ### Optional Attributes +/// +/// The keywords `extra` and `skip_meta` can be provided as optional arguments to the +/// `#[benchmark]` attribute, i.e. `#[benchmark(extra, skip_meta)]`. Including either of these +/// will enable the `extra` or `skip_meta` option, respectively. These options enable the same +/// behavior they did in the old benchmarking syntax in `frame_benchmarking`, namely: +/// +/// #### `extra` +/// +/// Specifies that this benchmark should not normally run. To run benchmarks marked with +/// `extra`, you will need to invoke the `frame-benchmarking-cli` with `--extra`. +/// +/// #### `skip_meta` +/// +/// Specifies that the benchmarking framework should not analyze the storage keys that +/// benchmarked code read or wrote. This useful to suppress the prints in the form of unknown +/// 0x… in case a storage key that does not have metadata. Note that this skips the analysis +/// of all accesses, not just ones without metadata. +/// +/// ## Where Clause +/// +/// Some pallets require a where clause specifying constraints on their generics to make +/// writing benchmarks feasible. To accomodate this situation, you can provide such a where +/// clause as the (only) argument to the `#[benchmarks]` or `#[instance_benchmarks]` attribute +/// macros. Below is an example of this taken from the `message-queue` pallet. +/// +/// ```ignore +/// #[benchmarks( +/// where +/// <::MessageProcessor as ProcessMessage>::Origin: From + PartialEq, +/// ::Size: From, +/// )] +/// mod benchmarks { +/// use super::*; +/// // ... +/// } +/// ``` +/// +/// ## Benchmark Tests +/// +/// Benchmark tests can be generated using the old syntax in `frame_benchmarking`, +/// including the `frame_benchmarking::impl_benchmark_test_suite` macro. +/// +/// An example is shown below (taken from the `message-queue` pallet's `benchmarking` module): +/// ```ignore +/// #[benchmarks] +/// mod benchmarks { +/// use super::*; +/// // ... +/// impl_benchmark_test_suite!( +/// MessageQueue, +/// crate::mock::new_test_ext::(), +/// crate::integration_test::Test +/// ); +/// } +/// ``` +pub mod benchmarking { + pub use frame_support_procedural::{ + benchmark, benchmarks, block, extrinsic_call, instance_benchmarks, + }; + + // Used in #[benchmark] implementation to ensure that benchmark function arguments + // implement [`ParamRange`]. + #[doc(hidden)] + pub use static_assertions::assert_impl_all; + + /// Used by the new benchmarking code to specify that a benchmarking variable is linear + /// over some specified range, i.e. `Linear<0, 1_000>` means that the corresponding variable + /// is allowed to range from `0` to `1000`, inclusive. + /// + /// See [`frame_support::benchmarking`] for more info. + pub struct Linear; + + /// Trait that must be implemented by all structs that can be used as parameter range types + /// in the new benchmarking code (i.e. `Linear<0, 1_000>`). Right now there is just + /// [`Linear`] but this could later be extended to support additional non-linear parameter + /// ranges. + /// + /// See [`frame_support::benchmarking`] for more info. + pub trait ParamRange { + /// Represents the (inclusive) starting number of this [`ParamRange`]. + fn start(&self) -> u32; + + /// Represents the (inclusive) ending number of this [`ParamRange`] + fn end(&self) -> u32; + } + + impl ParamRange for Linear { + fn start(&self) -> u32 { + return A + } + + fn end(&self) -> u32 { + return B + } + } +} + // Generate a macro that will enable/disable code based on `std` feature being active. sp_core::generate_feature_enabled_macro!(std_enabled, feature = "std", $); diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index fc211d7713..90ef243eed 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -19,6 +19,7 @@ sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../../ sp-io = { version = "7.0.0", path = "../../../primitives/io", default-features = false } sp-state-machine = { version = "0.13.0", optional = true, path = "../../../primitives/state-machine" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../" } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../benchmarking" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../../primitives/runtime" } sp-core = { version = "7.0.0", default-features = false, path = "../../../primitives/core" } sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } @@ -36,6 +37,7 @@ std = [ "serde/std", "codec/std", "scale-info/std", + "frame-benchmarking/std", "frame-support/std", "frame-system/std", "sp-core/std", diff --git a/frame/support/test/tests/benchmark_ui.rs b/frame/support/test/tests/benchmark_ui.rs new file mode 100644 index 0000000000..243030bd07 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui.rs @@ -0,0 +1,36 @@ +// This file is part of Substrate. + +// Copyright (C) 2020-2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[rustversion::attr(not(stable), ignore)] +#[cfg(not(feature = "disable-ui-tests"))] +#[test] +fn benchmark_ui() { + // Only run the ui tests when `RUN_UI_TESTS` is set. + if std::env::var("RUN_UI_TESTS").is_err() { + return + } + + // As trybuild is using `cargo check`, we don't need the real WASM binaries. + std::env::set_var("SKIP_WASM_BUILD", "1"); + + // Deny all warnings since we emit warnings as part of a Pallet's UI. + std::env::set_var("RUSTFLAGS", "--deny warnings"); + + let t = trybuild::TestCases::new(); + t.compile_fail("tests/benchmark_ui/*.rs"); + t.pass("tests/benchmark_ui/pass/*.rs"); +} diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name.rs b/frame/support/test/tests/benchmark_ui/bad_param_name.rs new file mode 100644 index 0000000000..ad4db4f0a4 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_name.rs @@ -0,0 +1,18 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench(winton: Linear<1, 2>) { + let a = 2 + 2; + #[block] + {} + assert_eq!(a, 4); + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name.stderr b/frame/support/test/tests/benchmark_ui/bad_param_name.stderr new file mode 100644 index 0000000000..4e2d63a6b5 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_name.stderr @@ -0,0 +1,5 @@ +error: Benchmark parameter names must consist of a single lowercase letter (a-z) and no other characters. + --> tests/benchmark_ui/bad_param_name.rs:10:11 + | +10 | fn bench(winton: Linear<1, 2>) { + | ^^^^^^ diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs b/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs new file mode 100644 index 0000000000..50e4dc6fd4 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs @@ -0,0 +1,14 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + #[benchmark] + fn bench(xx: Linear<1, 2>) { + #[block] + {} + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.stderr b/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.stderr new file mode 100644 index 0000000000..32f6bf8e47 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.stderr @@ -0,0 +1,5 @@ +error: Benchmark parameter names must consist of a single lowercase letter (a-z) and no other characters. + --> tests/benchmark_ui/bad_param_name_too_long.rs:8:11 + | +8 | fn bench(xx: Linear<1, 2>) { + | ^^ diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs b/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs new file mode 100644 index 0000000000..0270582b3b --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs @@ -0,0 +1,14 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + #[benchmark] + fn bench(D: Linear<1, 2>) { + #[block] + {} + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.stderr b/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.stderr new file mode 100644 index 0000000000..48dd41d326 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.stderr @@ -0,0 +1,5 @@ +error: Benchmark parameter names must consist of a single lowercase letter (a-z) and no other characters. + --> tests/benchmark_ui/bad_param_name_upper_case.rs:8:11 + | +8 | fn bench(D: Linear<1, 2>) { + | ^ diff --git a/frame/support/test/tests/benchmark_ui/bad_param_range.rs b/frame/support/test/tests/benchmark_ui/bad_param_range.rs new file mode 100644 index 0000000000..aabb9fa740 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_range.rs @@ -0,0 +1,16 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench(x: Linear<3, 1>) { + #[block] + {} + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/bad_param_range.stderr b/frame/support/test/tests/benchmark_ui/bad_param_range.stderr new file mode 100644 index 0000000000..1347af0a07 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_param_range.stderr @@ -0,0 +1,5 @@ +error: The start of a `ParamRange` must be less than or equal to the end + --> tests/benchmark_ui/bad_param_range.rs:10:21 + | +10 | fn bench(x: Linear<3, 1>) { + | ^ diff --git a/frame/support/test/tests/benchmark_ui/bad_params.rs b/frame/support/test/tests/benchmark_ui/bad_params.rs new file mode 100644 index 0000000000..a0c9236982 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_params.rs @@ -0,0 +1,18 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench(y: Linear<1, 2>, x: u32) { + let a = 2 + 2; + #[block] + {} + assert_eq!(a, 4); + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/bad_params.stderr b/frame/support/test/tests/benchmark_ui/bad_params.stderr new file mode 100644 index 0000000000..068eaedd53 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/bad_params.stderr @@ -0,0 +1,5 @@ +error: Invalid benchmark function param. A valid example would be `x: Linear<5, 10>`. + --> tests/benchmark_ui/bad_params.rs:10:31 + | +10 | fn bench(y: Linear<1, 2>, x: u32) { + | ^^^ diff --git a/frame/support/test/tests/benchmark_ui/dup_block.rs b/frame/support/test/tests/benchmark_ui/dup_block.rs new file mode 100644 index 0000000000..4c4a8fc11d --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/dup_block.rs @@ -0,0 +1,20 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench() { + let a = 2 + 2; + #[block] + {} + #[block] + {} + assert_eq!(a, 4); + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/dup_block.stderr b/frame/support/test/tests/benchmark_ui/dup_block.stderr new file mode 100644 index 0000000000..3d73c3d660 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/dup_block.stderr @@ -0,0 +1,5 @@ +error: Only one #[extrinsic_call] or #[block] attribute is allowed per benchmark. + --> tests/benchmark_ui/dup_block.rs:14:3 + | +14 | #[block] + | ^ diff --git a/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs b/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs new file mode 100644 index 0000000000..1a91b7c16d --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs @@ -0,0 +1,20 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench() { + let a = 2 + 2; + #[extrinsic_call] + _(stuff); + #[extrinsic_call] + _(other_stuff); + assert_eq!(a, 4); + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.stderr b/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.stderr new file mode 100644 index 0000000000..593f7072bf --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.stderr @@ -0,0 +1,5 @@ +error: Only one #[extrinsic_call] or #[block] attribute is allowed per benchmark. + --> tests/benchmark_ui/dup_extrinsic_call.rs:14:3 + | +14 | #[extrinsic_call] + | ^ diff --git a/frame/support/test/tests/benchmark_ui/extra_extra.rs b/frame/support/test/tests/benchmark_ui/extra_extra.rs new file mode 100644 index 0000000000..021106c7af --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/extra_extra.rs @@ -0,0 +1,16 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark(extra, extra)] + fn bench() { + #[block] + {} + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/extra_extra.stderr b/frame/support/test/tests/benchmark_ui/extra_extra.stderr new file mode 100644 index 0000000000..bf36b4f080 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/extra_extra.stderr @@ -0,0 +1,5 @@ +error: unexpected end of input, `extra` can only be specified once + --> tests/benchmark_ui/extra_extra.rs:9:26 + | +9 | #[benchmark(extra, extra)] + | ^ diff --git a/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs b/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs new file mode 100644 index 0000000000..1940f4cf1f --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs @@ -0,0 +1,16 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark(skip_meta, skip_meta)] + fn bench() { + #[block] + {} + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/extra_skip_meta.stderr b/frame/support/test/tests/benchmark_ui/extra_skip_meta.stderr new file mode 100644 index 0000000000..4d48a8ad77 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/extra_skip_meta.stderr @@ -0,0 +1,5 @@ +error: unexpected end of input, `skip_meta` can only be specified once + --> tests/benchmark_ui/extra_skip_meta.rs:9:34 + | +9 | #[benchmark(skip_meta, skip_meta)] + | ^ diff --git a/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs b/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs new file mode 100644 index 0000000000..4cb6bfc34c --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs @@ -0,0 +1,6 @@ +use frame_support::benchmarking::*; + +#[extrinsic_call] +mod stuff {} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.stderr b/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.stderr new file mode 100644 index 0000000000..c5194d7a66 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.stderr @@ -0,0 +1,7 @@ +error: `#[extrinsic_call]` must be in a benchmark function definition labeled with `#[benchmark]`. + --> tests/benchmark_ui/extrinsic_call_out_of_fn.rs:3:1 + | +3 | #[extrinsic_call] + | ^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `extrinsic_call` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/benchmark_ui/missing_call.rs b/frame/support/test/tests/benchmark_ui/missing_call.rs new file mode 100644 index 0000000000..7437049354 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/missing_call.rs @@ -0,0 +1,13 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench() {} +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/missing_call.stderr b/frame/support/test/tests/benchmark_ui/missing_call.stderr new file mode 100644 index 0000000000..3b55f77d42 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/missing_call.stderr @@ -0,0 +1,5 @@ +error: No valid #[extrinsic_call] or #[block] annotation could be found in benchmark function body. + --> tests/benchmark_ui/missing_call.rs:10:13 + | +10 | fn bench() {} + | ^^ diff --git a/frame/support/test/tests/benchmark_ui/missing_origin.rs b/frame/support/test/tests/benchmark_ui/missing_origin.rs new file mode 100644 index 0000000000..aad91bc79f --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/missing_origin.rs @@ -0,0 +1,16 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark] + fn bench() { + #[extrinsic_call] + thing(); + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/missing_origin.stderr b/frame/support/test/tests/benchmark_ui/missing_origin.stderr new file mode 100644 index 0000000000..0e72bff474 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/missing_origin.stderr @@ -0,0 +1,5 @@ +error: Single-item extrinsic calls must specify their origin as the first argument. + --> tests/benchmark_ui/missing_origin.rs:12:3 + | +12 | thing(); + | ^^^^^ diff --git a/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs b/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs new file mode 100644 index 0000000000..5c84d7f76d --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs @@ -0,0 +1,17 @@ +use frame_support::benchmarking::*; +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark(skip_meta, extra)] + fn bench() { + let a = 2 + 2; + #[block] + {} + assert_eq!(a, 4); + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/unrecognized_option.rs b/frame/support/test/tests/benchmark_ui/unrecognized_option.rs new file mode 100644 index 0000000000..4c2cea139f --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/unrecognized_option.rs @@ -0,0 +1,16 @@ +use frame_support::benchmarking::*; +#[allow(unused_imports)] +use frame_support_test::Config; + +#[benchmarks] +mod benches { + use super::*; + + #[benchmark(skip_meta, extra, bad)] + fn bench() { + #[block] + {} + } +} + +fn main() {} diff --git a/frame/support/test/tests/benchmark_ui/unrecognized_option.stderr b/frame/support/test/tests/benchmark_ui/unrecognized_option.stderr new file mode 100644 index 0000000000..5cebe9eab0 --- /dev/null +++ b/frame/support/test/tests/benchmark_ui/unrecognized_option.stderr @@ -0,0 +1,5 @@ +error: expected `extra` or `skip_meta` + --> tests/benchmark_ui/unrecognized_option.rs:9:32 + | +9 | #[benchmark(skip_meta, extra, bad)] + | ^^^ From d0a2c4ab86232a9a762d03f559715a14727bef3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 23 Jan 2023 12:35:04 +0100 Subject: [PATCH 39/80] Rename `*-private-ipv4` to `*-private-ip` CLI args (#13208) * Rename `*-private-ipv4` to `*-private-ip` CLI args Renames the `*-private-ipv4` to `*-private-ip` in the CLI interface. The old names are staying as alias, thus it will not break for anyone. Besides that it also fixes the naming in the rest of the code. * FMT --- client/cli/src/params/network_params.rs | 18 ++++++++--------- client/network/common/src/config.rs | 4 ++-- client/network/src/config.rs | 2 +- client/network/src/discovery.rs | 26 ++++++++++++------------- client/network/src/service.rs | 10 +++++++--- client/service/test/src/lib.rs | 2 +- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/client/cli/src/params/network_params.rs b/client/cli/src/params/network_params.rs index 5580dea45b..984789da75 100644 --- a/client/cli/src/params/network_params.rs +++ b/client/cli/src/params/network_params.rs @@ -68,18 +68,18 @@ pub struct NetworkParams { #[arg(long, value_name = "PORT", conflicts_with_all = &[ "listen_addr" ])] pub port: Option, - /// Always forbid connecting to private IPv4 addresses (as specified in + /// Always forbid connecting to private IPv4/IPv6 addresses (as specified in /// [RFC1918](https://tools.ietf.org/html/rfc1918)), unless the address was passed with /// `--reserved-nodes` or `--bootnodes`. Enabled by default for chains marked as "live" in /// their chain specifications. - #[arg(long, conflicts_with_all = &["allow_private_ipv4"])] - pub no_private_ipv4: bool, + #[arg(long, alias = "no-private-ipv4", conflicts_with_all = &["allow_private_ip"])] + pub no_private_ip: bool, - /// Always accept connecting to private IPv4 addresses (as specified in + /// Always accept connecting to private IPv4/IPv6 addresses (as specified in /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Enabled by default for chains marked as /// "local" in their chain specifications, or when `--dev` is passed. - #[arg(long, conflicts_with_all = &["no_private_ipv4"])] - pub allow_private_ipv4: bool, + #[arg(long, alias = "allow-private-ipv4", conflicts_with_all = &["no_private_ip"])] + pub allow_private_ip: bool, /// Specify the number of outgoing connections we're trying to maintain. #[arg(long, value_name = "COUNT", default_value_t = 15)] @@ -200,8 +200,8 @@ impl NetworkParams { self.discover_local || is_dev || matches!(chain_type, ChainType::Local | ChainType::Development); - let allow_private_ipv4 = match (self.allow_private_ipv4, self.no_private_ipv4) { - (true, true) => unreachable!("`*_private_ipv4` flags are mutually exclusive; qed"), + let allow_private_ip = match (self.allow_private_ip, self.no_private_ip) { + (true, true) => unreachable!("`*_private_ip` flags are mutually exclusive; qed"), (true, false) => true, (false, true) => false, (false, false) => @@ -231,7 +231,7 @@ impl NetworkParams { client_version: client_id.to_string(), transport: TransportConfig::Normal { enable_mdns: !is_dev && !self.no_mdns, - allow_private_ipv4, + allow_private_ip, }, max_parallel_downloads: self.max_parallel_downloads, enable_dht_random_walk: !self.reserved_only, diff --git a/client/network/common/src/config.rs b/client/network/common/src/config.rs index 96c7c11ec2..c35d8a42a8 100644 --- a/client/network/common/src/config.rs +++ b/client/network/common/src/config.rs @@ -301,10 +301,10 @@ pub enum TransportConfig { /// and connect to them if they support the same chain. enable_mdns: bool, - /// If true, allow connecting to private IPv4 addresses (as defined in + /// If true, allow connecting to private IPv4/IPv6 addresses (as defined in /// [RFC1918](https://tools.ietf.org/html/rfc1918)). Irrelevant for addresses that have /// been passed in `::sc_network::config::NetworkConfiguration::boot_nodes`. - allow_private_ipv4: bool, + allow_private_ip: bool, }, /// Only allow connections within the same process. diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 52993e2519..8ca8d75f16 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -223,7 +223,7 @@ impl NetworkConfiguration { extra_sets: Vec::new(), client_version: client_version.into(), node_name: node_name.into(), - transport: TransportConfig::Normal { enable_mdns: false, allow_private_ipv4: true }, + transport: TransportConfig::Normal { enable_mdns: false, allow_private_ip: true }, max_parallel_downloads: 5, sync_mode: SyncMode::Full, enable_dht_random_walk: true, diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 5421db8194..7329ebf15c 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -96,7 +96,7 @@ pub struct DiscoveryConfig { local_peer_id: PeerId, permanent_addresses: Vec<(PeerId, Multiaddr)>, dht_random_walk: bool, - allow_private_ipv4: bool, + allow_private_ip: bool, allow_non_globals_in_dht: bool, discovery_only_if_under_num: u64, enable_mdns: bool, @@ -111,7 +111,7 @@ impl DiscoveryConfig { local_peer_id: local_public_key.to_peer_id(), permanent_addresses: Vec::new(), dht_random_walk: true, - allow_private_ipv4: true, + allow_private_ip: true, allow_non_globals_in_dht: false, discovery_only_if_under_num: std::u64::MAX, enable_mdns: false, @@ -142,9 +142,9 @@ impl DiscoveryConfig { self } - /// Should private IPv4 addresses be reported? - pub fn allow_private_ipv4(&mut self, value: bool) -> &mut Self { - self.allow_private_ipv4 = value; + /// Should private IPv4/IPv6 addresses be reported? + pub fn allow_private_ip(&mut self, value: bool) -> &mut Self { + self.allow_private_ip = value; self } @@ -189,7 +189,7 @@ impl DiscoveryConfig { local_peer_id, permanent_addresses, dht_random_walk, - allow_private_ipv4, + allow_private_ip, allow_non_globals_in_dht, discovery_only_if_under_num, enable_mdns, @@ -231,7 +231,7 @@ impl DiscoveryConfig { pending_events: VecDeque::new(), local_peer_id, num_connections: 0, - allow_private_ipv4, + allow_private_ip, discovery_only_if_under_num, mdns: if enable_mdns { match TokioMdns::new(mdns::Config::default()) { @@ -278,9 +278,9 @@ pub struct DiscoveryBehaviour { local_peer_id: PeerId, /// Number of nodes we're currently connected to. num_connections: u64, - /// If false, `addresses_of_peer` won't return any private IPv4 address, except for the ones - /// stored in `permanent_addresses` or `ephemeral_addresses`. - allow_private_ipv4: bool, + /// If false, `addresses_of_peer` won't return any private IPv4/IPv6 address, except for the + /// ones stored in `permanent_addresses` or `ephemeral_addresses`. + allow_private_ip: bool, /// Number of active connections over which we interrupt the discovery process. discovery_only_if_under_num: u64, /// Should non-global addresses be added to the DHT? @@ -506,7 +506,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { list_to_filter.extend(mdns.addresses_of_peer(peer_id)); } - if !self.allow_private_ipv4 { + if !self.allow_private_ip { list_to_filter.retain(|addr| match addr.iter().next() { Some(Protocol::Ip4(addr)) if !IpNetwork::from(addr).is_global() => false, Some(Protocol::Ip6(addr)) if !IpNetwork::from(addr).is_global() => false, @@ -947,7 +947,7 @@ mod tests { let mut config = DiscoveryConfig::new(keypair.public()); config .with_permanent_addresses(first_swarm_peer_id_and_addr.clone()) - .allow_private_ipv4(true) + .allow_private_ip(true) .allow_non_globals_in_dht(true) .discovery_limit(50) .with_kademlia(genesis_hash, fork_id, &protocol_id); @@ -1065,7 +1065,7 @@ mod tests { let keypair = Keypair::generate_ed25519(); let mut config = DiscoveryConfig::new(keypair.public()); config - .allow_private_ipv4(true) + .allow_private_ip(true) .allow_non_globals_in_dht(true) .discovery_limit(50) .with_kademlia(supported_genesis_hash, None, &supported_protocol_id); diff --git a/client/network/src/service.rs b/client/network/src/service.rs index f943a03f50..f3afb58e8e 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -291,11 +291,15 @@ where match params.network_config.transport { TransportConfig::MemoryOnly => { config.with_mdns(false); - config.allow_private_ipv4(false); + config.allow_private_ip(false); }, - TransportConfig::Normal { enable_mdns, allow_private_ipv4, .. } => { + TransportConfig::Normal { + enable_mdns, + allow_private_ip: allow_private_ipv4, + .. + } => { config.with_mdns(enable_mdns); - config.allow_private_ipv4(allow_private_ipv4); + config.allow_private_ip(allow_private_ipv4); }, } diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index 5f75e3521e..6533fe1396 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -220,7 +220,7 @@ fn node_config< ); network_config.transport = - TransportConfig::Normal { enable_mdns: false, allow_private_ipv4: true }; + TransportConfig::Normal { enable_mdns: false, allow_private_ip: true }; Configuration { impl_name: String::from("network-test-impl"), From e72f72fc9f493d5219328158f182b1b99f2f0208 Mon Sep 17 00:00:00 2001 From: Koute Date: Mon, 23 Jan 2023 23:08:51 +0900 Subject: [PATCH 40/80] Remove dead code (#13213) --- client/db/src/storage_cache.rs | 1975 -------------------------------- 1 file changed, 1975 deletions(-) delete mode 100644 client/db/src/storage_cache.rs diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs deleted file mode 100644 index 474599e5d7..0000000000 --- a/client/db/src/storage_cache.rs +++ /dev/null @@ -1,1975 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Global state cache. Maintains recently queried/committed state values -//! Tracks changes over the span of a few recent blocks and handles forks -//! by tracking/removing cache entries for conflicting changes. - -use crate::{stats::StateUsageStats, utils::Meta}; -use hash_db::Hasher; -use linked_hash_map::{Entry, LinkedHashMap}; -use log::trace; -use parking_lot::{RwLock, RwLockUpgradableReadGuard}; -use sp_core::{hexdisplay::HexDisplay, storage::ChildInfo}; -use sp_runtime::{ - traits::{Block as BlockT, HashFor, Header, NumberFor}, - StateVersion, -}; -use sp_state_machine::{ - backend::Backend as StateBackend, ChildStorageCollection, StorageCollection, StorageKey, - StorageValue, TrieBackend, -}; -use std::{ - collections::{HashMap, HashSet, VecDeque}, - hash::Hash as StdHash, - sync::Arc, -}; - -const STATE_CACHE_BLOCKS: usize = 12; - -type ChildStorageKey = (Vec, Vec); - -/// Shared canonical state cache. -pub struct Cache { - /// Storage cache. `None` indicates that key is known to be missing. - lru_storage: LRUMap>, - /// Storage hashes cache. `None` indicates that key is known to be missing. - lru_hashes: LRUMap>, - /// Storage cache for child trie. `None` indicates that key is known to be missing. - lru_child_storage: LRUMap>, - /// Information on the modifications in recently committed blocks; specifically which keys - /// changed in which block. Ordered by block number. - modifications: VecDeque>, -} - -struct LRUMap(LinkedHashMap, usize, usize); - -/// Internal trait similar to `heapsize` but using a simple estimation. -/// -/// This should not be made public, it is an implementation detail trait. -trait EstimateSize { - /// Return a size estimation of the additional size needed to cache this struct (in bytes). - fn estimate_size(&self) -> usize; -} - -impl EstimateSize for Vec { - fn estimate_size(&self) -> usize { - self.capacity() - } -} - -impl EstimateSize for Option> { - fn estimate_size(&self) -> usize { - self.as_ref().map(|v| v.capacity()).unwrap_or(0) - } -} - -struct OptionHOut>(Option); - -impl> EstimateSize for OptionHOut { - fn estimate_size(&self) -> usize { - // capacity would be better - self.0.as_ref().map(|v| v.as_ref().len()).unwrap_or(0) - } -} - -impl EstimateSize for (T, T) { - fn estimate_size(&self) -> usize { - self.0.estimate_size() + self.1.estimate_size() - } -} - -impl LRUMap { - fn remove(&mut self, k: &K) { - let map = &mut self.0; - let storage_used_size = &mut self.1; - if let Some(v) = map.remove(k) { - *storage_used_size -= k.estimate_size(); - *storage_used_size -= v.estimate_size(); - } - } - - fn add(&mut self, k: K, v: V) { - let lmap = &mut self.0; - let storage_used_size = &mut self.1; - let limit = self.2; - let klen = k.estimate_size(); - *storage_used_size += v.estimate_size(); - // TODO assert k v size fit into limit?? to avoid insert remove? - match lmap.entry(k) { - Entry::Occupied(mut entry) => { - // note that in this case we are not running pure lru as - // it would require to remove first - *storage_used_size -= entry.get().estimate_size(); - entry.insert(v); - }, - Entry::Vacant(entry) => { - *storage_used_size += klen; - entry.insert(v); - }, - }; - - while *storage_used_size > limit { - if let Some((k, v)) = lmap.pop_front() { - *storage_used_size -= k.estimate_size(); - *storage_used_size -= v.estimate_size(); - } else { - // can happen fairly often as we get value from multiple lru - // and only remove from a single lru - break - } - } - } - - fn get(&mut self, k: &Q) -> Option<&mut V> - where - K: std::borrow::Borrow, - Q: StdHash + Eq, - { - self.0.get_refresh(k) - } - - fn used_size(&self) -> usize { - self.1 - } - fn clear(&mut self) { - self.0.clear(); - self.1 = 0; - } -} - -impl Cache { - /// Returns the used memory size of the storage cache in bytes. - pub fn used_storage_cache_size(&self) -> usize { - self.lru_storage.used_size() + self.lru_child_storage.used_size() - // ignore small hashes storage and self.lru_hashes.used_size() - } - - /// Synchronize the shared cache with the best block state. - /// - /// This function updates the shared cache by removing entries - /// that are invalidated by chain reorganization. It should be called - /// externally when chain reorg happens without importing a new block. - pub fn sync(&mut self, enacted: &[B::Hash], retracted: &[B::Hash]) { - trace!("Syncing shared cache, enacted = {:?}, retracted = {:?}", enacted, retracted); - - // Purge changes from re-enacted and retracted blocks. - let mut clear = false; - for block in enacted { - clear = clear || { - if let Some(m) = self.modifications.iter_mut().find(|m| &m.hash == block) { - trace!("Reverting enacted block {:?}", block); - m.is_canon = true; - for a in &m.storage { - trace!("Reverting enacted key {:?}", HexDisplay::from(a)); - self.lru_storage.remove(a); - self.lru_hashes.remove(a); - } - for a in &m.child_storage { - trace!("Reverting enacted child key {:?}", a); - self.lru_child_storage.remove(a); - } - false - } else { - true - } - }; - } - - for block in retracted { - clear = clear || { - if let Some(m) = self.modifications.iter_mut().find(|m| &m.hash == block) { - trace!("Retracting block {:?}", block); - m.is_canon = false; - for a in &m.storage { - trace!("Retracted key {:?}", HexDisplay::from(a)); - self.lru_storage.remove(a); - self.lru_hashes.remove(a); - } - for a in &m.child_storage { - trace!("Retracted child key {:?}", a); - self.lru_child_storage.remove(a); - } - false - } else { - true - } - }; - } - if clear { - // We don't know anything about the block; clear everything - trace!("Wiping cache"); - self.lru_storage.clear(); - self.lru_child_storage.clear(); - self.lru_hashes.clear(); - self.modifications.clear(); - } - } -} - -pub type SharedCache = Arc>>; - -/// Fix lru storage size for hash (small 64ko). -const FIX_LRU_HASH_SIZE: usize = 65_536; - -/// Create a new shared cache instance with given max memory usage. -pub fn new_shared_cache( - shared_cache_size: usize, - child_ratio: (usize, usize), -) -> SharedCache { - let top = child_ratio.1.saturating_sub(child_ratio.0); - Arc::new(RwLock::new(Cache { - lru_storage: LRUMap(LinkedHashMap::new(), 0, shared_cache_size * top / child_ratio.1), - lru_hashes: LRUMap(LinkedHashMap::new(), 0, FIX_LRU_HASH_SIZE), - lru_child_storage: LRUMap( - LinkedHashMap::new(), - 0, - shared_cache_size * child_ratio.0 / child_ratio.1, - ), - modifications: VecDeque::new(), - })) -} - -#[derive(Debug)] -/// Accumulates a list of storage changed in a block. -struct BlockChanges { - /// Block number. - number: B::Number, - /// Block hash. - hash: B::Hash, - /// Parent block hash. - parent: B::Hash, - /// A set of modified storage keys. - storage: HashSet, - /// A set of modified child storage keys. - child_storage: HashSet, - /// Block is part of the canonical chain. - is_canon: bool, -} - -/// Cached values specific to a state. -struct LocalCache { - /// Storage cache. - /// - /// `None` indicates that key is known to be missing. - storage: HashMap>, - /// Storage hashes cache. - /// - /// `None` indicates that key is known to be missing. - hashes: HashMap>, - /// Child storage cache. - /// - /// `None` indicates that key is known to be missing. - child_storage: HashMap>, -} - -/// Cache changes. -pub struct CacheChanges { - /// Shared canonical state cache. - shared_cache: SharedCache, - /// Local cache of values for this state. - local_cache: RwLock>>, - /// Hash of the block on top of which this instance was created or - /// `None` if cache is disabled - pub parent_hash: Option, -} - -/// State cache abstraction. -/// -/// Manages shared global state cache which reflects the canonical -/// state as it is on the disk. -/// -/// A instance of `CachingState` may be created as canonical or not. -/// For canonical instances local cache is accumulated and applied -/// in `sync_cache` along with the change overlay. -/// For non-canonical clones local cache and changes are dropped. -pub struct CachingState { - /// Usage statistics - usage: StateUsageStats, - /// State machine registered stats - overlay_stats: sp_state_machine::StateMachineStats, - /// Backing state. - state: S, - /// Cache data. - cache: CacheChanges, -} - -impl std::fmt::Debug for CachingState { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Block {:?}", self.cache.parent_hash) - } -} - -impl CacheChanges { - /// Propagate local cache into the shared cache and synchronize - /// the shared cache with the best block state. - /// - /// This function updates the shared cache by removing entries - /// that are invalidated by chain reorganization. `sync_cache` - /// should be called after the block has been committed and the - /// blockchain route has been calculated. - pub fn sync_cache( - &mut self, - enacted: &[B::Hash], - retracted: &[B::Hash], - changes: StorageCollection, - child_changes: ChildStorageCollection, - commit_hash: Option, - commit_number: Option>, - is_best: bool, - ) { - let mut cache = self.shared_cache.write(); - trace!( - "Syncing cache, id = (#{:?}, {:?}), parent={:?}, best={}", - commit_number, - commit_hash, - self.parent_hash, - is_best, - ); - let cache = &mut *cache; - // Filter out committing block if any. - let mut enacted: Vec<_> = enacted - .iter() - .filter(|h| commit_hash.as_ref().map_or(true, |p| *h != p)) - .cloned() - .collect(); - - let mut retracted = std::borrow::Cow::Borrowed(retracted); - if let Some(commit_hash) = &commit_hash { - if let Some(m) = cache.modifications.iter_mut().find(|m| &m.hash == commit_hash) { - if m.is_canon != is_best { - // Same block comitted twice with different state changes. - // Treat it as reenacted/retracted. - if is_best { - enacted.push(*commit_hash); - } else { - retracted.to_mut().push(*commit_hash); - } - } - } - } - cache.sync(&enacted, &retracted); - // Propagate cache only if committing on top of the latest canonical state - // blocks are ordered by number and only one block with a given number is marked as - // canonical (contributed to canonical state cache) - if self.parent_hash.is_some() { - let mut local_cache = self.local_cache.write(); - if is_best { - trace!( - "Committing {} local, {} hashes, {} modified root entries, {} modified child entries", - local_cache.storage.len(), - local_cache.hashes.len(), - changes.len(), - child_changes.iter().map(|v|v.1.len()).sum::(), - ); - for (k, v) in local_cache.storage.drain() { - cache.lru_storage.add(k, v); - } - for (k, v) in local_cache.child_storage.drain() { - cache.lru_child_storage.add(k, v); - } - for (k, v) in local_cache.hashes.drain() { - cache.lru_hashes.add(k, OptionHOut(v)); - } - } - } - - if let (Some(ref number), Some(ref hash), Some(ref parent)) = - (commit_number, commit_hash, self.parent_hash) - { - if cache.modifications.len() == STATE_CACHE_BLOCKS { - cache.modifications.pop_back(); - } - let mut modifications = HashSet::new(); - let mut child_modifications = HashSet::new(); - child_changes.into_iter().for_each(|(sk, changes)| { - for (k, v) in changes.into_iter() { - let k = (sk.clone(), k); - if is_best { - cache.lru_child_storage.add(k.clone(), v); - } - child_modifications.insert(k); - } - }); - for (k, v) in changes.into_iter() { - if is_best { - cache.lru_hashes.remove(&k); - cache.lru_storage.add(k.clone(), v); - } - modifications.insert(k); - } - - // Save modified storage. These are ordered by the block number in reverse. - let block_changes = BlockChanges { - storage: modifications, - child_storage: child_modifications, - number: *number, - hash: *hash, - is_canon: is_best, - parent: *parent, - }; - let insert_at = cache - .modifications - .iter() - .enumerate() - .find(|(_, m)| m.number < *number) - .map(|(i, _)| i); - trace!("Inserting modifications at {:?}", insert_at); - if let Some(insert_at) = insert_at { - cache.modifications.insert(insert_at, block_changes); - } else { - cache.modifications.push_back(block_changes); - } - } - } -} - -impl>, B: BlockT> CachingState { - /// Create a new instance wrapping generic State and shared cache. - pub(crate) fn new( - state: S, - shared_cache: SharedCache, - parent_hash: Option, - ) -> Self { - CachingState { - usage: StateUsageStats::new(), - overlay_stats: sp_state_machine::StateMachineStats::default(), - state, - cache: CacheChanges { - shared_cache, - local_cache: RwLock::new(LocalCache { - storage: Default::default(), - hashes: Default::default(), - child_storage: Default::default(), - }), - parent_hash, - }, - } - } - - /// Check if the key can be returned from cache by matching current block parent hash against - /// canonical state and filtering out entries modified in later blocks. - fn is_allowed( - key: Option<&[u8]>, - child_key: Option<&ChildStorageKey>, - parent_hash: &Option, - modifications: &VecDeque>, - ) -> bool { - let mut parent = match *parent_hash { - None => { - trace!( - "Cache lookup skipped for {:?}: no parent hash", - key.as_ref().map(HexDisplay::from) - ); - return false - }, - Some(ref parent) => parent, - }; - // Ignore all storage entries modified in later blocks. - // Modifications contains block ordered by the number - // We search for our parent in that list first and then for - // all its parents until we hit the canonical block, - // checking against all the intermediate modifications. - for m in modifications { - if &m.hash == parent { - if m.is_canon { - return true - } - parent = &m.parent; - } - if let Some(key) = key { - if m.storage.contains(key) { - trace!( - "Cache lookup skipped for {:?}: modified in a later block", - HexDisplay::from(&key) - ); - return false - } - } - if let Some(child_key) = child_key { - if m.child_storage.contains(child_key) { - trace!("Cache lookup skipped for {:?}: modified in a later block", child_key); - return false - } - } - } - trace!( - "Cache lookup skipped for {:?}: parent hash is unknown", - key.as_ref().map(HexDisplay::from), - ); - false - } -} - -impl>, B: BlockT> StateBackend> for CachingState { - type Error = S::Error; - type Transaction = S::Transaction; - type TrieBackendStorage = S::TrieBackendStorage; - - fn storage(&self, key: &[u8]) -> Result>, Self::Error> { - let local_cache = self.cache.local_cache.upgradable_read(); - // Note that local cache makes that lru is not refreshed - if let Some(entry) = local_cache.storage.get(key).cloned() { - trace!("Found in local cache: {:?}", HexDisplay::from(&key)); - self.usage.tally_key_read(key, entry.as_ref(), true); - - return Ok(entry) - } - { - let cache = self.cache.shared_cache.upgradable_read(); - if Self::is_allowed(Some(key), None, &self.cache.parent_hash, &cache.modifications) { - let mut cache = RwLockUpgradableReadGuard::upgrade(cache); - if let Some(entry) = cache.lru_storage.get(key).map(|a| a.clone()) { - trace!("Found in shared cache: {:?}", HexDisplay::from(&key)); - self.usage.tally_key_read(key, entry.as_ref(), true); - return Ok(entry) - } - } - } - trace!("Cache miss: {:?}", HexDisplay::from(&key)); - let value = self.state.storage(key)?; - RwLockUpgradableReadGuard::upgrade(local_cache) - .storage - .insert(key.to_vec(), value.clone()); - self.usage.tally_key_read(key, value.as_ref(), false); - Ok(value) - } - - fn storage_hash(&self, key: &[u8]) -> Result, Self::Error> { - let local_cache = self.cache.local_cache.upgradable_read(); - if let Some(entry) = local_cache.hashes.get(key).cloned() { - trace!("Found hash in local cache: {:?}", HexDisplay::from(&key)); - return Ok(entry) - } - { - let cache = self.cache.shared_cache.upgradable_read(); - if Self::is_allowed(Some(key), None, &self.cache.parent_hash, &cache.modifications) { - let mut cache = RwLockUpgradableReadGuard::upgrade(cache); - if let Some(entry) = cache.lru_hashes.get(key).map(|a| a.0) { - trace!("Found hash in shared cache: {:?}", HexDisplay::from(&key)); - return Ok(entry) - } - } - } - trace!("Cache hash miss: {:?}", HexDisplay::from(&key)); - let hash = self.state.storage_hash(key)?; - RwLockUpgradableReadGuard::upgrade(local_cache) - .hashes - .insert(key.to_vec(), hash); - Ok(hash) - } - - fn child_storage( - &self, - child_info: &ChildInfo, - key: &[u8], - ) -> Result>, Self::Error> { - let key = (child_info.storage_key().to_vec(), key.to_vec()); - let local_cache = self.cache.local_cache.upgradable_read(); - if let Some(entry) = local_cache.child_storage.get(&key).cloned() { - trace!("Found in local cache: {:?}", key); - return Ok(self.usage.tally_child_key_read(&key, entry, true)) - } - { - let cache = self.cache.shared_cache.upgradable_read(); - if Self::is_allowed(None, Some(&key), &self.cache.parent_hash, &cache.modifications) { - let mut cache = RwLockUpgradableReadGuard::upgrade(cache); - if let Some(entry) = cache.lru_child_storage.get(&key).map(|a| a.clone()) { - trace!("Found in shared cache: {:?}", key); - return Ok(self.usage.tally_child_key_read(&key, entry, true)) - } - } - } - trace!("Cache miss: {:?}", key); - let value = self.state.child_storage(child_info, &key.1[..])?; - - // just pass it through the usage counter - let value = self.usage.tally_child_key_read(&key, value, false); - - RwLockUpgradableReadGuard::upgrade(local_cache) - .child_storage - .insert(key, value.clone()); - Ok(value) - } - - fn exists_storage(&self, key: &[u8]) -> Result { - Ok(self.storage(key)?.is_some()) - } - - fn exists_child_storage( - &self, - child_info: &ChildInfo, - key: &[u8], - ) -> Result { - self.state.exists_child_storage(child_info, key) - } - - fn apply_to_key_values_while, Vec) -> bool>( - &self, - child_info: Option<&ChildInfo>, - prefix: Option<&[u8]>, - start_at: Option<&[u8]>, - f: F, - allow_missing: bool, - ) -> Result { - self.state - .apply_to_key_values_while(child_info, prefix, start_at, f, allow_missing) - } - - fn apply_to_keys_while bool>( - &self, - child_info: Option<&ChildInfo>, - prefix: Option<&[u8]>, - start_at: Option<&[u8]>, - f: F, - ) { - self.state.apply_to_keys_while(child_info, prefix, start_at, f) - } - - fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { - self.state.next_storage_key(key) - } - - fn next_child_storage_key( - &self, - child_info: &ChildInfo, - key: &[u8], - ) -> Result>, Self::Error> { - self.state.next_child_storage_key(child_info, key) - } - - fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { - self.state.for_keys_with_prefix(prefix, f) - } - - fn for_key_values_with_prefix(&self, prefix: &[u8], f: F) { - self.state.for_key_values_with_prefix(prefix, f) - } - - fn for_child_keys_with_prefix( - &self, - child_info: &ChildInfo, - prefix: &[u8], - f: F, - ) { - self.state.for_child_keys_with_prefix(child_info, prefix, f) - } - - fn storage_root<'a>( - &self, - delta: impl Iterator)>, - state_version: StateVersion, - ) -> (B::Hash, Self::Transaction) - where - B::Hash: Ord, - { - self.state.storage_root(delta, state_version) - } - - fn child_storage_root<'a>( - &self, - child_info: &ChildInfo, - delta: impl Iterator)>, - state_version: StateVersion, - ) -> (B::Hash, bool, Self::Transaction) - where - B::Hash: Ord, - { - self.state.child_storage_root(child_info, delta, state_version) - } - - fn pairs(&self) -> Vec<(Vec, Vec)> { - self.state.pairs() - } - - fn keys(&self, prefix: &[u8]) -> Vec> { - self.state.keys(prefix) - } - - fn child_keys(&self, child_info: &ChildInfo, prefix: &[u8]) -> Vec> { - self.state.child_keys(child_info, prefix) - } - - fn as_trie_backend(&self) -> Option<&TrieBackend>> { - self.state.as_trie_backend() - } - - fn register_overlay_stats(&self, stats: &sp_state_machine::StateMachineStats) { - self.overlay_stats.add(stats); - } - - fn usage_info(&self) -> sp_state_machine::UsageInfo { - let mut info = self.usage.take(); - info.include_state_machine_states(&self.overlay_stats); - info - } -} - -/// Extended [`CachingState`] that will sync the caches on drop. -pub struct SyncingCachingState { - /// The usage statistics of the backend. These will be updated on drop. - state_usage: Arc, - /// Reference to the meta db. - meta: Arc, Block::Hash>>>, - /// Mutex to lock get exlusive access to the backend. - lock: Arc>, - /// The wrapped caching state. - /// - /// This is required to be a `Option`, because sometimes we want to extract - /// the cache changes and Rust does not allow to move fields from types that - /// implement `Drop`. - caching_state: Option>, - /// Disable syncing of the cache. This is by default always `false`. However, - /// we need to disable syncing when this is a state in a - /// [`BlockImportOperation`](crate::BlockImportOperation). The import operation - /// takes care to sync the cache and more importantly we want to prevent a dead - /// lock. - disable_syncing: bool, -} - -impl SyncingCachingState { - /// Create new automatic syncing state. - pub fn new( - caching_state: CachingState, - state_usage: Arc, - meta: Arc, B::Hash>>>, - lock: Arc>, - ) -> Self { - Self { caching_state: Some(caching_state), state_usage, meta, lock, disable_syncing: false } - } - - /// Returns the reference to the internal [`CachingState`]. - fn caching_state(&self) -> &CachingState { - self.caching_state - .as_ref() - .expect("`caching_state` is always valid for the lifetime of the object; qed") - } - - /// Convert `Self` into the cache changes. - pub fn into_cache_changes(mut self) -> CacheChanges { - self.caching_state - .take() - .expect("`caching_state` is always valid for the lifetime of the object; qed") - .cache - } - - /// Disable syncing the cache on drop. - pub fn disable_syncing(&mut self) { - self.disable_syncing = true; - } -} - -impl std::fmt::Debug for SyncingCachingState { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.caching_state().fmt(f) - } -} - -impl>, B: BlockT> StateBackend> - for SyncingCachingState -{ - type Error = S::Error; - type Transaction = S::Transaction; - type TrieBackendStorage = S::TrieBackendStorage; - - fn storage(&self, key: &[u8]) -> Result>, Self::Error> { - self.caching_state().storage(key) - } - - fn storage_hash(&self, key: &[u8]) -> Result, Self::Error> { - self.caching_state().storage_hash(key) - } - - fn child_storage( - &self, - child_info: &ChildInfo, - key: &[u8], - ) -> Result>, Self::Error> { - self.caching_state().child_storage(child_info, key) - } - - fn exists_storage(&self, key: &[u8]) -> Result { - self.caching_state().exists_storage(key) - } - - fn exists_child_storage( - &self, - child_info: &ChildInfo, - key: &[u8], - ) -> Result { - self.caching_state().exists_child_storage(child_info, key) - } - - fn apply_to_key_values_while, Vec) -> bool>( - &self, - child_info: Option<&ChildInfo>, - prefix: Option<&[u8]>, - start_at: Option<&[u8]>, - f: F, - allow_missing: bool, - ) -> Result { - self.caching_state().apply_to_key_values_while( - child_info, - prefix, - start_at, - f, - allow_missing, - ) - } - - fn apply_to_keys_while bool>( - &self, - child_info: Option<&ChildInfo>, - prefix: Option<&[u8]>, - start_at: Option<&[u8]>, - f: F, - ) { - self.caching_state().apply_to_keys_while(child_info, prefix, start_at, f) - } - - fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { - self.caching_state().next_storage_key(key) - } - - fn next_child_storage_key( - &self, - child_info: &ChildInfo, - key: &[u8], - ) -> Result>, Self::Error> { - self.caching_state().next_child_storage_key(child_info, key) - } - - fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { - self.caching_state().for_keys_with_prefix(prefix, f) - } - - fn for_key_values_with_prefix(&self, prefix: &[u8], f: F) { - self.caching_state().for_key_values_with_prefix(prefix, f) - } - - fn for_child_keys_with_prefix( - &self, - child_info: &ChildInfo, - prefix: &[u8], - f: F, - ) { - self.caching_state().for_child_keys_with_prefix(child_info, prefix, f) - } - - fn storage_root<'a>( - &self, - delta: impl Iterator)>, - state_version: StateVersion, - ) -> (B::Hash, Self::Transaction) - where - B::Hash: Ord, - { - self.caching_state().storage_root(delta, state_version) - } - - fn child_storage_root<'a>( - &self, - child_info: &ChildInfo, - delta: impl Iterator)>, - state_version: StateVersion, - ) -> (B::Hash, bool, Self::Transaction) - where - B::Hash: Ord, - { - self.caching_state().child_storage_root(child_info, delta, state_version) - } - - fn pairs(&self) -> Vec<(Vec, Vec)> { - self.caching_state().pairs() - } - - fn keys(&self, prefix: &[u8]) -> Vec> { - self.caching_state().keys(prefix) - } - - fn child_keys(&self, child_info: &ChildInfo, prefix: &[u8]) -> Vec> { - self.caching_state().child_keys(child_info, prefix) - } - - fn as_trie_backend(&self) -> Option<&TrieBackend>> { - self.caching_state - .as_ref() - .expect("`caching_state` is valid for the lifetime of the object; qed") - .as_trie_backend() - } - - fn register_overlay_stats(&self, stats: &sp_state_machine::StateMachineStats) { - self.caching_state().register_overlay_stats(stats); - } - - fn usage_info(&self) -> sp_state_machine::UsageInfo { - self.caching_state().usage_info() - } -} - -impl Drop for SyncingCachingState { - fn drop(&mut self) { - if self.disable_syncing { - return - } - - if let Some(mut caching_state) = self.caching_state.take() { - let _lock = self.lock.read(); - - self.state_usage.merge_sm(caching_state.usage.take()); - if let Some(hash) = caching_state.cache.parent_hash { - let is_best = self.meta.read().best_hash == hash; - caching_state.cache.sync_cache(&[], &[], vec![], vec![], None, None, is_best); - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use sp_runtime::{ - testing::{Block as RawBlock, ExtrinsicWrapper, H256}, - traits::BlakeTwo256, - }; - use sp_state_machine::InMemoryBackend; - - type Block = RawBlock>; - - #[test] - fn smoke() { - // init_log(); - let root_parent = H256::random(); - let key = H256::random()[..].to_vec(); - let h0 = H256::random(); - let h1a = H256::random(); - let h1b = H256::random(); - let h2a = H256::random(); - let h2b = H256::random(); - let h3a = H256::random(); - let h3b = H256::random(); - - let shared = new_shared_cache::(256 * 1024, (0, 1)); - - // blocks [ 3a(c) 2a(c) 2b 1b 1a(c) 0 ] - // state [ 5 5 4 3 2 2 ] - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![2]))], - vec![], - Some(h0), - Some(0), - true, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h0)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h1a), Some(1), true); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h0)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![3]))], - vec![], - Some(h1b), - Some(1), - false, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1b)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![4]))], - vec![], - Some(h2b), - Some(2), - false, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1a)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![5]))], - vec![], - Some(h2a), - Some(2), - true, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2a)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h3a), Some(3), true); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h3a)); - assert_eq!(s.storage(&key).unwrap().unwrap(), vec![5]); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1a)); - assert!(s.storage(&key).unwrap().is_none()); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2b)); - assert!(s.storage(&key).unwrap().is_none()); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1b)); - assert!(s.storage(&key).unwrap().is_none()); - - // reorg to 3b - // blocks [ 3b(c) 3a 2a 2b(c) 1b 1a 0 ] - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2b)); - s.cache.sync_cache( - &[h1b, h2b, h3b], - &[h1a, h2a, h3a], - vec![], - vec![], - Some(h3b), - Some(3), - true, - ); - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h3a)); - assert!(s.storage(&key).unwrap().is_none()); - } - - #[test] - fn simple_fork() { - sp_tracing::try_init_simple(); - - let root_parent = H256::random(); - let key = H256::random()[..].to_vec(); - let h1 = H256::random(); - let h2a = H256::random(); - let h2b = H256::random(); - let h3b = H256::random(); - - let shared = new_shared_cache::(256 * 1024, (0, 1)); - - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![2]))], - vec![], - Some(h1), - Some(1), - true, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2a), Some(2), true); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![3]))], - vec![], - Some(h2b), - Some(2), - false, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2b)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![3]))], - vec![], - Some(h3b), - Some(2), - false, - ); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2a)); - assert_eq!(s.storage(&key).unwrap().unwrap(), vec![2]); - } - - #[test] - fn double_fork() { - let root_parent = H256::random(); - let key = H256::random()[..].to_vec(); - let h1 = H256::random(); - let h2a = H256::random(); - let h2b = H256::random(); - let h3a = H256::random(); - let h3b = H256::random(); - - let shared = new_shared_cache::(256 * 1024, (0, 1)); - - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h1), Some(1), true); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2a), Some(2), true); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2a)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![2]))], - vec![], - Some(h3a), - Some(3), - true, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2b), Some(2), false); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h2b)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![3]))], - vec![], - Some(h3b), - Some(3), - false, - ); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h3a)); - assert_eq!(s.storage(&key).unwrap().unwrap(), vec![2]); - } - - #[test] - fn reverts_storage_hash() { - let root_parent = H256::random(); - let key = H256::random()[..].to_vec(); - let h1a = H256::random(); - let h1b = H256::random(); - - let shared = new_shared_cache::(256 * 1024, (0, 1)); - let mut backend = InMemoryBackend::::default(); - backend.insert( - std::iter::once((None, vec![(key.clone(), Some(vec![1]))])), - Default::default(), - ); - - let mut s = CachingState::new(backend.clone(), shared.clone(), Some(root_parent)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![2]))], - vec![], - Some(h1a), - Some(1), - true, - ); - - let mut s = CachingState::new(backend.clone(), shared.clone(), Some(root_parent)); - s.cache.sync_cache(&[], &[h1a], vec![], vec![], Some(h1b), Some(1), true); - - let s = CachingState::new(backend.clone(), shared.clone(), Some(h1b)); - assert_eq!(s.storage_hash(&key).unwrap().unwrap(), BlakeTwo256::hash(&vec![1])); - } - - #[test] - fn should_track_used_size_correctly() { - let root_parent = H256::random(); - let shared = new_shared_cache::(109, ((109 - 36), 109)); - let h0 = H256::random(); - - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - - let key = H256::random()[..].to_vec(); - let s_key = H256::random()[..].to_vec(); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![1, 2, 3]))], - vec![], - Some(h0), - Some(0), - true, - ); - // 32 key, 3 byte size - assert_eq!(shared.read().used_storage_cache_size(), 35 /* bytes */); - - let key = H256::random()[..].to_vec(); - s.cache.sync_cache( - &[], - &[], - vec![], - vec![(s_key.clone(), vec![(key.clone(), Some(vec![1, 2]))])], - Some(h0), - Some(0), - true, - ); - // 35 + (2 * 32) key, 2 byte size - assert_eq!(shared.read().used_storage_cache_size(), 101 /* bytes */); - } - - #[test] - fn should_remove_lru_items_based_on_tracking_used_size() { - let root_parent = H256::random(); - let shared = new_shared_cache::(36 * 3, (2, 3)); - let h0 = H256::random(); - - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - - let key = H256::random()[..].to_vec(); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![1, 2, 3, 4]))], - vec![], - Some(h0), - Some(0), - true, - ); - // 32 key, 4 byte size - assert_eq!(shared.read().used_storage_cache_size(), 36 /* bytes */); - - let key = H256::random()[..].to_vec(); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![1, 2]))], - vec![], - Some(h0), - Some(0), - true, - ); - // 32 key, 2 byte size - assert_eq!(shared.read().used_storage_cache_size(), 34 /* bytes */); - } - - #[test] - fn fix_storage_mismatch_issue() { - sp_tracing::try_init_simple(); - let root_parent = H256::random(); - - let key = H256::random()[..].to_vec(); - - let h0 = H256::random(); - let h1 = H256::random(); - - let shared = new_shared_cache::(256 * 1024, (0, 1)); - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![2]))], - vec![], - Some(h0), - Some(0), - true, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h0)); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![3]))], - vec![], - Some(h1), - Some(1), - true, - ); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - assert_eq!(s.storage(&key).unwrap(), Some(vec![3])); - - // Restart (or unknown block?), clear caches. - { - let mut cache = s.cache.shared_cache.write(); - let cache = &mut *cache; - cache.lru_storage.clear(); - cache.lru_hashes.clear(); - cache.lru_child_storage.clear(); - cache.modifications.clear(); - } - - // New value is written because of cache miss. - s.cache.local_cache.write().storage.insert(key.clone(), Some(vec![42])); - - // New value is propagated. - s.cache.sync_cache(&[], &[], vec![], vec![], None, None, true); - - let s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - assert_eq!(s.storage(&key).unwrap(), None); - } - - #[test] - fn same_block_no_changes() { - sp_tracing::try_init_simple(); - - let root_parent = H256::random(); - let key = H256::random()[..].to_vec(); - let h1 = H256::random(); - let h2 = H256::random(); - - let shared = new_shared_cache::(256 * 1024, (0, 1)); - - let mut s = CachingState::new( - InMemoryBackend::::default(), - shared.clone(), - Some(root_parent), - ); - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![1]))], - vec![], - Some(h1), - Some(1), - true, - ); - assert_eq!(shared.write().lru_storage.get(&key).unwrap(), &Some(vec![1])); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - - // commit as non-best - s.cache.sync_cache( - &[], - &[], - vec![(key.clone(), Some(vec![2]))], - vec![], - Some(h2), - Some(2), - false, - ); - - assert_eq!(shared.write().lru_storage.get(&key).unwrap(), &Some(vec![1])); - - let mut s = - CachingState::new(InMemoryBackend::::default(), shared.clone(), Some(h1)); - - // commit again as best with no changes - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2), Some(2), true); - assert_eq!(s.storage(&key).unwrap(), None); - } -} - -#[cfg(test)] -mod qc { - use std::collections::{hash_map::Entry, HashMap}; - - use quickcheck::{quickcheck, Arbitrary, TestResult}; - - use super::*; - use sp_runtime::{ - testing::{Block as RawBlock, ExtrinsicWrapper, H256}, - traits::BlakeTwo256, - }; - use sp_state_machine::InMemoryBackend; - - type Block = RawBlock>; - - type KeySet = Vec<(Vec, Option>)>; - - type KeyMap = HashMap, Option>>; - - #[derive(Debug, Clone)] - struct Node { - hash: H256, - #[allow(unused)] - parent: H256, - state: KeyMap, - changes: KeySet, - } - - impl Node { - fn new_next(&self, hash: H256, changes: KeySet) -> Self { - let mut state = self.state.clone(); - - for (k, v) in self.state.iter() { - state.insert(k.clone(), v.clone()); - } - for (k, v) in changes.clone().into_iter() { - state.insert(k, v); - } - - Self { hash, parent: self.hash, changes, state } - } - - fn new(hash: H256, parent: H256, changes: KeySet) -> Self { - let mut state = KeyMap::new(); - - for (k, v) in changes.clone().into_iter() { - state.insert(k, v); - } - - Self { hash, parent, state, changes } - } - - fn purge(&mut self, other_changes: &KeySet) { - for (k, _) in other_changes.iter() { - self.state.remove(k); - } - } - } - - #[derive(Debug, Clone)] - enum Action { - Next { hash: H256, changes: KeySet }, - Fork { depth: usize, hash: H256, changes: KeySet }, - ReorgWithImport { depth: usize, hash: H256 }, - FinalizationReorg { fork_depth: usize, depth: usize }, - } - - impl Arbitrary for Action { - fn arbitrary(gen: &mut quickcheck::Gen) -> Self { - let path = u8::arbitrary(gen); - let buf = (0..32).map(|_| u8::arbitrary(gen)).collect::>(); - - match path { - 0..=175 => Action::Next { - hash: H256::from_slice(&buf[..]), - changes: { - let mut set = Vec::new(); - for _ in 0..::arbitrary(gen) / (64 * 256 * 256 * 256) { - set.push((vec![u8::arbitrary(gen)], Some(vec![u8::arbitrary(gen)]))); - } - set - }, - }, - 176..=220 => Action::Fork { - hash: H256::from_slice(&buf[..]), - depth: ((u8::arbitrary(gen)) / 32) as usize, - changes: { - let mut set = Vec::new(); - for _ in 0..::arbitrary(gen) / (64 * 256 * 256 * 256) { - set.push((vec![u8::arbitrary(gen)], Some(vec![u8::arbitrary(gen)]))); - } - set - }, - }, - 221..=240 => { - Action::ReorgWithImport { - hash: H256::from_slice(&buf[..]), - depth: ((u8::arbitrary(gen)) / 32) as usize, // 0-7 - } - }, - _ => { - Action::FinalizationReorg { - fork_depth: ((u8::arbitrary(gen)) / 32) as usize, // 0-7 - depth: ((u8::arbitrary(gen)) / 64) as usize, // 0-3 - } - }, - } - } - } - - struct Mutator { - shared: SharedCache, - canon: Vec, - forks: HashMap>, - } - - impl Mutator { - fn new_empty() -> Self { - let shared = new_shared_cache::(256 * 1024, (0, 1)); - - Self { shared, canon: vec![], forks: HashMap::new() } - } - - fn head_state(&self, hash: H256) -> CachingState, Block> { - CachingState::new( - InMemoryBackend::::default(), - self.shared.clone(), - Some(hash), - ) - } - - fn canon_head_state(&self) -> CachingState, Block> { - self.head_state(self.canon.last().expect("Expected to be one commit").hash) - } - - fn mutate_static( - &mut self, - action: Action, - ) -> CachingState, Block> { - self.mutate(action) - .expect("Expected to provide only valid actions to the mutate_static") - } - - fn canon_len(&self) -> usize { - return self.canon.len() - } - - fn head_storage_ref(&self) -> &KeyMap { - &self.canon.last().expect("Expected to be one commit").state - } - - fn key_permutations() -> Vec> { - (0u8..255).map(|x| vec![x]).collect() - } - - fn mutate( - &mut self, - action: Action, - ) -> Result, Block>, ()> { - let state = match action { - Action::Fork { depth, hash, changes } => { - let pos = self.canon.len() as isize - depth as isize; - if pos < 0 || self.canon.len() == 0 || pos >= (self.canon.len() - 1) as isize - // no fork on top also, thus len-1 - { - return Err(()) - } - - let pos = pos as usize; - - let fork_at = self.canon[pos].hash; - - let (total_h, parent) = match self.forks.entry(fork_at) { - Entry::Occupied(occupied) => { - let chain = occupied.into_mut(); - let parent = - chain.last().expect("No empty forks are ever created").clone(); - let mut node = parent.new_next(hash, changes.clone()); - - for earlier in chain.iter() { - node.purge(&earlier.changes.clone()); - } - - chain.push(node); - - (pos + chain.len(), parent.hash) - }, - Entry::Vacant(vacant) => { - let canon_parent = &self.canon[pos]; - vacant.insert(vec![canon_parent.new_next(hash, changes.clone())]); - - (pos + 1, fork_at) - }, - }; - - let mut state = CachingState::new( - InMemoryBackend::::default(), - self.shared.clone(), - Some(parent), - ); - - state.cache.sync_cache( - &[], - &[], - changes, - vec![], - Some(hash), - Some(total_h as u64), - false, - ); - - state - }, - Action::Next { hash, changes } => { - let (next, parent_hash) = match self.canon.last() { - None => { - let parent_hash = H256::from(&[0u8; 32]); - (Node::new(hash, parent_hash, changes.clone()), parent_hash) - }, - Some(parent) => (parent.new_next(hash, changes.clone()), parent.hash), - }; - - // delete cache entries for earlier - for node in self.canon.iter_mut() { - node.purge(&next.changes); - if let Some(fork) = self.forks.get_mut(&node.hash) { - for node in fork.iter_mut() { - node.purge(&next.changes); - } - } - } - - let mut state = CachingState::new( - InMemoryBackend::::default(), - self.shared.clone(), - Some(parent_hash), - ); - - state.cache.sync_cache( - &[], - &[], - next.changes.clone(), - vec![], - Some(hash), - Some(self.canon.len() as u64 + 1), - true, - ); - - self.canon.push(next); - - state - }, - Action::ReorgWithImport { depth, hash } => { - let pos = self.canon.len() as isize - depth as isize; - if pos < 0 || pos + 1 >= self.canon.len() as isize { - return Err(()) - } - let fork_at = self.canon[pos as usize].hash; - let pos = pos as usize; - - match self.forks.get_mut(&fork_at) { - Some(chain) => { - let mut new_fork = self.canon.drain(pos + 1..).collect::>(); - - let retracted: Vec = - new_fork.iter().map(|node| node.hash).collect(); - let enacted: Vec = chain.iter().map(|node| node.hash).collect(); - - std::mem::swap(chain, &mut new_fork); - - let mut node = new_fork - .last() - .map(|node| node.new_next(hash, vec![])) - .expect("No empty fork ever created!"); - - for invalidators in chain.iter().chain(new_fork.iter()) { - node.purge(&invalidators.changes); - } - - self.canon.extend(new_fork.into_iter()); - - self.canon.push(node); - - let mut state = CachingState::new( - InMemoryBackend::::default(), - self.shared.clone(), - Some(fork_at), - ); - - let height = pos as u64 + enacted.len() as u64 + 2; - state.cache.sync_cache( - &enacted[..], - &retracted[..], - vec![], - vec![], - Some(hash), - Some(height), - true, - ); - - state - }, - None => { - return Err(()) // no reorg without a fork atm! - }, - } - }, - Action::FinalizationReorg { fork_depth, depth } => { - let pos = self.canon.len() as isize - fork_depth as isize; - if pos < 0 || pos + 1 >= self.canon.len() as isize { - return Err(()) - } - let fork_at = self.canon[pos as usize].hash; - let pos = pos as usize; - - match self.forks.get_mut(&fork_at) { - Some(fork_chain) => { - let sync_pos = fork_chain.len() as isize - - fork_chain.len() as isize - depth as isize; - if sync_pos < 0 || sync_pos >= fork_chain.len() as isize { - return Err(()) - } - let sync_pos = sync_pos as usize; - - let mut new_fork = self.canon.drain(pos + 1..).collect::>(); - - let retracted: Vec = - new_fork.iter().map(|node| node.hash).collect(); - let enacted: Vec = fork_chain - .iter() - .take(sync_pos + 1) - .map(|node| node.hash) - .collect(); - - std::mem::swap(fork_chain, &mut new_fork); - - self.shared.write().sync(&retracted, &enacted); - - self.head_state( - self.canon - .last() - .expect("wasn't forking to emptiness so there should be one!") - .hash, - ) - }, - None => { - return Err(()) // no reorg to nothing pls! - }, - } - }, - }; - - Ok(state) - } - } - - #[test] - fn smoke() { - let key = H256::random()[..].to_vec(); - let h0 = H256::random(); - let h1a = H256::random(); - let h1b = H256::random(); - let h2a = H256::random(); - let h2b = H256::random(); - let h3a = H256::random(); - let h3b = H256::random(); - - let mut mutator = Mutator::new_empty(); - mutator - .mutate_static(Action::Next { hash: h0, changes: vec![(key.clone(), Some(vec![2]))] }); - mutator.mutate_static(Action::Next { hash: h1a, changes: vec![] }); - mutator.mutate_static(Action::Fork { - depth: 2, - hash: h1b, - changes: vec![(key.clone(), Some(vec![3]))], - }); - mutator.mutate_static(Action::Fork { - depth: 2, - hash: h2b, - changes: vec![(key.clone(), Some(vec![4]))], - }); - mutator - .mutate_static(Action::Next { hash: h2a, changes: vec![(key.clone(), Some(vec![5]))] }); - mutator.mutate_static(Action::Next { hash: h3a, changes: vec![] }); - - assert_eq!( - mutator.head_state(h3a).storage(&key).unwrap().expect("there should be a value"), - vec![5] - ); - assert!(mutator.head_state(h1a).storage(&key).unwrap().is_none()); - assert!(mutator.head_state(h2b).storage(&key).unwrap().is_none()); - assert!(mutator.head_state(h1b).storage(&key).unwrap().is_none()); - - mutator.mutate_static(Action::ReorgWithImport { depth: 4, hash: h3b }); - assert!(mutator.head_state(h3a).storage(&key).unwrap().is_none()); - } - - fn is_head_match(mutator: &Mutator) -> bool { - let head_state = mutator.canon_head_state(); - - for key in Mutator::key_permutations() { - match (head_state.storage(&key).unwrap(), mutator.head_storage_ref().get(&key)) { - (Some(x), Some(y)) => - if Some(&x) != y.as_ref() { - eprintln!("{:?} != {:?}", x, y); - return false - }, - (None, Some(_y)) => { - // TODO: cache miss is not tracked atm - }, - (Some(x), None) => { - eprintln!("{:?} != ", x); - return false - }, - _ => continue, - } - } - true - } - - fn is_canon_match(mutator: &Mutator) -> bool { - for node in mutator.canon.iter() { - let head_state = mutator.head_state(node.hash); - for key in Mutator::key_permutations() { - match (head_state.storage(&key).unwrap(), node.state.get(&key)) { - (Some(x), Some(y)) => - if Some(&x) != y.as_ref() { - eprintln!("at [{}]: {:?} != {:?}", node.hash, x, y); - return false - }, - (None, Some(_y)) => { - // cache miss is not tracked atm - }, - (Some(x), None) => { - eprintln!("at [{}]: {:?} != ", node.hash, x); - return false - }, - _ => continue, - } - } - } - true - } - - #[test] - fn reorg() { - let key = H256::random()[..].to_vec(); - let h0 = H256::random(); - let h1 = H256::random(); - let h2 = H256::random(); - let h1b = H256::random(); - let h2b = H256::random(); - - let mut mutator = Mutator::new_empty(); - mutator.mutate_static(Action::Next { hash: h0, changes: vec![] }); - mutator.mutate_static(Action::Next { hash: h1, changes: vec![] }); - mutator - .mutate_static(Action::Next { hash: h2, changes: vec![(key.clone(), Some(vec![2]))] }); - mutator.mutate_static(Action::Fork { - depth: 2, - hash: h1b, - changes: vec![(key.clone(), Some(vec![3]))], - }); - mutator.mutate_static(Action::ReorgWithImport { depth: 2, hash: h2b }); - - assert!(is_head_match(&mutator)) - } - - fn key(k: u8) -> Vec { - vec![k] - } - fn val(v: u8) -> Option> { - Some(vec![v]) - } - fn keyval(k: u8, v: u8) -> KeySet { - vec![(key(k), val(v))] - } - - #[test] - fn reorg2() { - let h0 = H256::random(); - let h1a = H256::random(); - let h1b = H256::random(); - let h2b = H256::random(); - let h2a = H256::random(); - let h3a = H256::random(); - - let mut mutator = Mutator::new_empty(); - mutator.mutate_static(Action::Next { hash: h0, changes: keyval(1, 1) }); - mutator.mutate_static(Action::Next { hash: h1a, changes: keyval(1, 1) }); - mutator.mutate_static(Action::Fork { depth: 2, hash: h1b, changes: keyval(2, 2) }); - - mutator.mutate_static(Action::Next { hash: h2a, changes: keyval(3, 3) }); - mutator.mutate_static(Action::Next { hash: h3a, changes: keyval(4, 4) }); - mutator.mutate_static(Action::ReorgWithImport { depth: 4, hash: h2b }); - - assert!(is_head_match(&mutator)) - } - - #[test] - fn fork2() { - let h1 = H256::random(); - let h2a = H256::random(); - let h2b = H256::random(); - let h3a = H256::random(); - let h3b = H256::random(); - - let mut mutator = Mutator::new_empty(); - mutator.mutate_static(Action::Next { hash: h1, changes: vec![] }); - mutator.mutate_static(Action::Next { hash: h2a, changes: vec![] }); - mutator.mutate_static(Action::Next { hash: h3a, changes: keyval(1, 1) }); - - mutator.mutate_static(Action::Fork { depth: 2, hash: h2b, changes: vec![] }); - mutator.mutate_static(Action::Fork { depth: 2, hash: h3b, changes: keyval(1, 2) }); - - assert!(is_head_match(&mutator)) - } - - #[test] - fn fork3() { - let h1 = H256::random(); - let h2a = H256::random(); - let h2b = H256::random(); - let h3a = H256::random(); - - let mut mutator = Mutator::new_empty(); - mutator.mutate_static(Action::Next { hash: h1, changes: keyval(1, 1) }); - mutator.mutate_static(Action::Next { hash: h2a, changes: keyval(2, 2) }); - mutator.mutate_static(Action::Next { hash: h3a, changes: keyval(3, 3) }); - - mutator.mutate_static(Action::Fork { depth: 2, hash: h2b, changes: keyval(1, 3) }); - - assert!(is_canon_match(&mutator)) - } - - quickcheck! { - fn head_complete(actions: Vec) -> TestResult { - let mut mutator = Mutator::new_empty(); - - for action in actions.into_iter() { - if let Err(_) = mutator.mutate(action) { - return TestResult::discard(); - } - } - - if mutator.canon_len() == 0 { - return TestResult::discard(); - } - - TestResult::from_bool(is_head_match(&mutator)) - } - - fn canon_complete(actions: Vec) -> TestResult { - let mut mutator = Mutator::new_empty(); - - for action in actions.into_iter() { - if let Err(_) = mutator.mutate(action) { - return TestResult::discard(); - } - } - - if mutator.canon_len() == 0 { - return TestResult::discard(); - } - - TestResult::from_bool(is_canon_match(&mutator)) - } - } -} From 419b840fa1f170a1c2027b63310549d1bf6d2ed0 Mon Sep 17 00:00:00 2001 From: Roman Useinov Date: Mon, 23 Jan 2023 15:32:09 +0100 Subject: [PATCH 41/80] [Fix] CountedMap::set now takes Counter into account (#13214) * [Fix] CountedMap::set now takes Counter into account * introduce tests for StorageMap --- .../support/src/storage/types/counted_map.rs | 55 ++++++++++++++++++- frame/support/src/storage/types/map.rs | 42 ++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/frame/support/src/storage/types/counted_map.rs b/frame/support/src/storage/types/counted_map.rs index 8c19434767..3361c4093d 100644 --- a/frame/support/src/storage/types/counted_map.rs +++ b/frame/support/src/storage/types/counted_map.rs @@ -134,7 +134,10 @@ where /// Store or remove the value to be associated with `key` so that `get` returns the `query`. pub fn set>(key: KeyArg, q: QueryKind::Query) { - ::Map::set(key, q) + match QueryKind::from_query_to_optional_value(q) { + Some(v) => Self::insert(key, v), + None => Self::remove(key), + } } /// Swap the values of two keys. @@ -745,6 +748,22 @@ mod test { // Test initialize_counter. assert_eq!(A::initialize_counter(), 2); + + // Set non-existing. + A::set(30, 100); + + assert_eq!(A::contains_key(30), true); + assert_eq!(A::get(30), 100); + assert_eq!(A::try_get(30), Ok(100)); + assert_eq!(A::count(), 3); + + // Set existing. + A::set(30, 101); + + assert_eq!(A::contains_key(30), true); + assert_eq!(A::get(30), 101); + assert_eq!(A::try_get(30), Ok(101)); + assert_eq!(A::count(), 3); }) } @@ -976,6 +995,40 @@ mod test { // Test initialize_counter. assert_eq!(B::initialize_counter(), 2); + + // Set non-existing. + B::set(30, Some(100)); + + assert_eq!(B::contains_key(30), true); + assert_eq!(B::get(30), Some(100)); + assert_eq!(B::try_get(30), Ok(100)); + assert_eq!(B::count(), 3); + + // Set existing. + B::set(30, Some(101)); + + assert_eq!(B::contains_key(30), true); + assert_eq!(B::get(30), Some(101)); + assert_eq!(B::try_get(30), Ok(101)); + assert_eq!(B::count(), 3); + + // Unset existing. + B::set(30, None); + + assert_eq!(B::contains_key(30), false); + assert_eq!(B::get(30), None); + assert_eq!(B::try_get(30), Err(())); + + assert_eq!(B::count(), 2); + + // Unset non-existing. + B::set(31, None); + + assert_eq!(B::contains_key(31), false); + assert_eq!(B::get(31), None); + assert_eq!(B::try_get(31), Err(())); + + assert_eq!(B::count(), 2); }) } diff --git a/frame/support/src/storage/types/map.rs b/frame/support/src/storage/types/map.rs index 0f89e2378a..3e2b744d72 100644 --- a/frame/support/src/storage/types/map.rs +++ b/frame/support/src/storage/types/map.rs @@ -627,6 +627,48 @@ mod test { assert_eq!(AValueQueryWithAnOnEmpty::take(2), 97); assert_eq!(A::contains_key(2), false); + // Set non-existing. + B::set(30, 100); + + assert_eq!(B::contains_key(30), true); + assert_eq!(B::get(30), 100); + assert_eq!(B::try_get(30), Ok(100)); + + // Set existing. + B::set(30, 101); + + assert_eq!(B::contains_key(30), true); + assert_eq!(B::get(30), 101); + assert_eq!(B::try_get(30), Ok(101)); + + // Set non-existing. + A::set(30, Some(100)); + + assert_eq!(A::contains_key(30), true); + assert_eq!(A::get(30), Some(100)); + assert_eq!(A::try_get(30), Ok(100)); + + // Set existing. + A::set(30, Some(101)); + + assert_eq!(A::contains_key(30), true); + assert_eq!(A::get(30), Some(101)); + assert_eq!(A::try_get(30), Ok(101)); + + // Unset existing. + A::set(30, None); + + assert_eq!(A::contains_key(30), false); + assert_eq!(A::get(30), None); + assert_eq!(A::try_get(30), Err(())); + + // Unset non-existing. + A::set(31, None); + + assert_eq!(A::contains_key(31), false); + assert_eq!(A::get(31), None); + assert_eq!(A::try_get(31), Err(())); + B::insert(2, 10); assert_eq!(A::migrate_key::(2), Some(10)); assert_eq!(A::contains_key(2), true); From 52d72b396393696fefd2cb50cd6a48707675ee60 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Mon, 23 Jan 2023 16:39:11 +0100 Subject: [PATCH 42/80] debug assert events at genesis (#13217) --- frame/system/src/lib.rs | 14 ++++++++++++++ frame/system/src/tests.rs | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 32627896e8..4bd5cf6298 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1247,6 +1247,8 @@ impl Pallet { } /// Deposits an event into this block's event record. + /// + /// NOTE: Events not registered at the genesis block and quietly omitted. pub fn deposit_event(event: impl Into) { Self::deposit_event_indexed(&[], event.into()); } @@ -1256,6 +1258,8 @@ impl Pallet { /// /// This will update storage entries that correspond to the specified topics. /// It is expected that light-clients could subscribe to this topics. + /// + /// NOTE: Events not registered at the genesis block and quietly omitted. pub fn deposit_event_indexed(topics: &[T::Hash], event: T::RuntimeEvent) { let block_number = Self::block_number(); // Don't populate events on genesis. @@ -1445,8 +1449,14 @@ impl Pallet { /// NOTE: This should only be used in tests. Reading events from the runtime can have a large /// impact on the PoV size of a block. Users should use alternative and well bounded storage /// items for any behavior like this. + /// + /// NOTE: Events not registered at the genesis block and quietly omitted. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] pub fn events() -> Vec> { + debug_assert!( + !Self::block_number().is_zero(), + "events not registered at the genesis block" + ); // Dereferencing the events here is fine since we are not in the // memory-restricted runtime. Self::read_events_no_consensus().map(|e| *e).collect() @@ -1501,6 +1511,8 @@ impl Pallet { } /// Assert the given `event` exists. + /// + /// NOTE: Events not registered at the genesis block and quietly omitted. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] pub fn assert_has_event(event: T::RuntimeEvent) { let events = Self::events(); @@ -1511,6 +1523,8 @@ impl Pallet { } /// Assert the last event equal to the given `event`. + /// + /// NOTE: Events not registered at the genesis block and quietly omitted. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] pub fn assert_last_event(event: T::RuntimeEvent) { let last_event = Self::events().last().expect("events expected").event.clone(); diff --git a/frame/system/src/tests.rs b/frame/system/src/tests.rs index c42131c450..8223f66744 100644 --- a/frame/system/src/tests.rs +++ b/frame/system/src/tests.rs @@ -627,7 +627,8 @@ fn events_not_emitted_during_genesis() { assert!(System::block_number().is_zero()); let mut account_data = AccountInfo::default(); System::on_created_account(Default::default(), &mut account_data); - assert!(System::events().is_empty()); + // No events registered at the genesis block + assert!(!System::read_events_no_consensus().any(|_| true)); // Events will be emitted starting on block 1 System::set_block_number(1); System::on_created_account(Default::default(), &mut account_data); From 9052607ad7a808e7a5e9e735460840a15d48aee7 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Tue, 24 Jan 2023 13:52:01 +0100 Subject: [PATCH 43/80] BlockId removal: refactor: CallExecutor trait (#13173) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BlockId removal: refactor: CallExecutor trait It changes the arguments of CallExecutor methods: - `call`, 'contextual_call', 'runtime_version', 'prove_execution' from: `BlockId` to: `Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * Apply suggestions from code review Co-authored-by: Bastian Köcher * ".git/.scripts/commands/fmt/fmt.sh" Co-authored-by: Bastian Köcher Co-authored-by: command-bot <> --- client/api/src/call_executor.rs | 10 ++-- client/finality-grandpa/src/lib.rs | 6 +-- .../rpc-spec-v2/src/chain_head/chain_head.rs | 2 +- client/rpc/src/state/state_full.rs | 2 +- client/service/src/client/call_executor.rs | 54 +++++++++---------- client/service/src/client/client.rs | 11 ++-- client/service/src/client/wasm_substitutes.rs | 20 +++---- primitives/version/src/lib.rs | 6 +-- 8 files changed, 55 insertions(+), 56 deletions(-) diff --git a/client/api/src/call_executor.rs b/client/api/src/call_executor.rs index 7a42385010..74a2b8b855 100644 --- a/client/api/src/call_executor.rs +++ b/client/api/src/call_executor.rs @@ -19,7 +19,7 @@ //! A method call executor interface. use sc_executor::{RuntimeVersion, RuntimeVersionOf}; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::traits::Block as BlockT; use sp_state_machine::{ExecutionStrategy, OverlayedChanges, StorageProof}; use std::cell::RefCell; @@ -54,7 +54,7 @@ pub trait CallExecutor: RuntimeVersionOf { /// No changes are made. fn call( &self, - id: &BlockId, + at_hash: B::Hash, method: &str, call_data: &[u8], strategy: ExecutionStrategy, @@ -67,7 +67,7 @@ pub trait CallExecutor: RuntimeVersionOf { /// of the execution context. fn contextual_call( &self, - at: &BlockId, + at_hash: B::Hash, method: &str, call_data: &[u8], changes: &RefCell, @@ -83,14 +83,14 @@ pub trait CallExecutor: RuntimeVersionOf { /// Extract RuntimeVersion of given block /// /// No changes are made. - fn runtime_version(&self, id: &BlockId) -> Result; + fn runtime_version(&self, at_hash: B::Hash) -> Result; /// Prove the execution of the given `method`. /// /// No changes are made. fn prove_execution( &self, - at: &BlockId, + at_hash: B::Hash, method: &str, call_data: &[u8], ) -> Result<(Vec, StorageProof), sp_blockchain::Error>; diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 8758efef60..15d689e917 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -464,10 +464,10 @@ pub trait GenesisAuthoritySetProvider { fn get(&self) -> Result; } -impl GenesisAuthoritySetProvider - for Arc> +impl GenesisAuthoritySetProvider for Arc where E: CallExecutor, + Client: ExecutorProvider + HeaderBackend, { fn get(&self) -> Result { // This implementation uses the Grandpa runtime API instead of reading directly from the @@ -475,7 +475,7 @@ where // the chain, whereas the runtime API is backwards compatible. self.executor() .call( - &BlockId::Number(Zero::zero()), + self.expect_block_hash_from_id(&BlockId::Number(Zero::zero()))?, "GrandpaApi_grandpa_authorities", &[], ExecutionStrategy::NativeElseWasm, diff --git a/client/rpc-spec-v2/src/chain_head/chain_head.rs b/client/rpc-spec-v2/src/chain_head/chain_head.rs index c63d373e04..2a9cabaf2b 100644 --- a/client/rpc-spec-v2/src/chain_head/chain_head.rs +++ b/client/rpc-spec-v2/src/chain_head/chain_head.rs @@ -744,7 +744,7 @@ where let res = client .executor() .call( - &BlockId::Hash(hash), + hash, &function, &call_parameters, client.execution_extensions().strategies().other, diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index d8fe39030a..58dfd9ea87 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -203,7 +203,7 @@ where self.client .executor() .call( - &BlockId::Hash(block), + block, &method, &call_data, self.client.execution_extensions().strategies().other, diff --git a/client/service/src/client/call_executor.rs b/client/service/src/client/call_executor.rs index 7ee19671dd..7906d62240 100644 --- a/client/service/src/client/call_executor.rs +++ b/client/service/src/client/call_executor.rs @@ -81,13 +81,13 @@ where fn check_override<'a>( &'a self, onchain_code: RuntimeCode<'a>, - id: &BlockId, + hash: ::Hash, ) -> sp_blockchain::Result<(RuntimeCode<'a>, RuntimeVersion)> where Block: BlockT, B: backend::Backend, { - let on_chain_version = self.on_chain_runtime_version(id)?; + let on_chain_version = self.on_chain_runtime_version(hash)?; let code_and_version = if let Some(d) = self.wasm_override.as_ref().as_ref().and_then(|o| { o.get( &on_chain_version.spec_version, @@ -95,18 +95,18 @@ where &on_chain_version.spec_name, ) }) { - log::debug!(target: "wasm_overrides", "using WASM override for block {}", id); + log::debug!(target: "wasm_overrides", "using WASM override for block {}", hash); d } else if let Some(s) = self.wasm_substitutes - .get(on_chain_version.spec_version, onchain_code.heap_pages, id) + .get(on_chain_version.spec_version, onchain_code.heap_pages, hash) { - log::debug!(target: "wasm_substitutes", "Using WASM substitute for block {:?}", id); + log::debug!(target: "wasm_substitutes", "Using WASM substitute for block {:?}", hash); s } else { log::debug!( target: "wasm_overrides", - "Neither WASM override nor substitute available for block {id}, using onchain code", + "Neither WASM override nor substitute available for block {hash}, using onchain code", ); (onchain_code, on_chain_version) }; @@ -115,14 +115,10 @@ where } /// Returns the on chain runtime version. - fn on_chain_runtime_version( - &self, - id: &BlockId, - ) -> sp_blockchain::Result { + fn on_chain_runtime_version(&self, hash: Block::Hash) -> sp_blockchain::Result { let mut overlay = OverlayedChanges::default(); - let at_hash = self.backend.blockchain().expect_block_hash_from_id(id)?; - let state = self.backend.state_at(at_hash)?; + let state = self.backend.state_at(hash)?; let mut cache = StorageTransactionCache::::default(); let mut ext = Ext::new(&mut overlay, &mut cache, &state, None); let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&state); @@ -166,21 +162,21 @@ where fn call( &self, - at: &BlockId, + at_hash: Block::Hash, method: &str, call_data: &[u8], strategy: ExecutionStrategy, ) -> sp_blockchain::Result> { let mut changes = OverlayedChanges::default(); - let at_hash = self.backend.blockchain().expect_block_hash_from_id(at)?; - let at_number = self.backend.blockchain().expect_block_number_from_id(at)?; + let at_number = + self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(at_hash))?; let state = self.backend.state_at(at_hash)?; let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&state); let runtime_code = state_runtime_code.runtime_code().map_err(sp_blockchain::Error::RuntimeCode)?; - let runtime_code = self.check_override(runtime_code, at)?.0; + let runtime_code = self.check_override(runtime_code, at_hash)?.0; let extensions = self.execution_extensions.extensions( at_hash, @@ -206,7 +202,7 @@ where fn contextual_call( &self, - at: &BlockId, + at_hash: Block::Hash, method: &str, call_data: &[u8], changes: &RefCell, @@ -216,8 +212,8 @@ where ) -> Result, sp_blockchain::Error> { let mut storage_transaction_cache = storage_transaction_cache.map(|c| c.borrow_mut()); - let at_hash = self.backend.blockchain().expect_block_hash_from_id(at)?; - let at_number = self.backend.blockchain().expect_block_number_from_id(at)?; + let at_number = + self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(at_hash))?; let state = self.backend.state_at(at_hash)?; let (execution_manager, extensions) = @@ -232,7 +228,7 @@ where let runtime_code = state_runtime_code.runtime_code().map_err(sp_blockchain::Error::RuntimeCode)?; - let runtime_code = self.check_override(runtime_code, at)?.0; + let runtime_code = self.check_override(runtime_code, at_hash)?.0; match recorder { Some(recorder) => { @@ -275,24 +271,23 @@ where .map_err(Into::into) } - fn runtime_version(&self, id: &BlockId) -> sp_blockchain::Result { - let at_hash = self.backend.blockchain().expect_block_hash_from_id(id)?; + fn runtime_version(&self, at_hash: Block::Hash) -> sp_blockchain::Result { let state = self.backend.state_at(at_hash)?; let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(&state); let runtime_code = state_runtime_code.runtime_code().map_err(sp_blockchain::Error::RuntimeCode)?; - self.check_override(runtime_code, id).map(|(_, v)| v) + self.check_override(runtime_code, at_hash).map(|(_, v)| v) } fn prove_execution( &self, - at: &BlockId, + at_hash: Block::Hash, method: &str, call_data: &[u8], ) -> sp_blockchain::Result<(Vec, StorageProof)> { - let at_hash = self.backend.blockchain().expect_block_hash_from_id(at)?; - let at_number = self.backend.blockchain().expect_block_number_from_id(at)?; + let at_number = + self.backend.blockchain().expect_block_number_from_id(&BlockId::Hash(at_hash))?; let state = self.backend.state_at(at_hash)?; let trie_backend = state.as_trie_backend(); @@ -300,7 +295,7 @@ where let state_runtime_code = sp_state_machine::backend::BackendRuntimeCode::new(trie_backend); let runtime_code = state_runtime_code.runtime_code().map_err(sp_blockchain::Error::RuntimeCode)?; - let runtime_code = self.check_override(runtime_code, at)?.0; + let runtime_code = self.check_override(runtime_code, at_hash)?.0; sp_state_machine::prove_execution_on_trie_backend( trie_backend, @@ -340,7 +335,7 @@ where E: CodeExecutor + RuntimeVersionOf + Clone + 'static, Block: BlockT, { - fn runtime_version(&self, at: &BlockId) -> Result { + fn runtime_version(&self, at: Block::Hash) -> Result { CallExecutor::runtime_version(self, at).map_err(|e| e.to_string()) } } @@ -359,6 +354,7 @@ where #[cfg(test)] mod tests { use super::*; + use backend::Backend; use sc_client_api::in_mem; use sc_executor::{NativeElseWasmExecutor, WasmExecutionMethod}; use sp_core::{ @@ -432,7 +428,7 @@ mod tests { }; let check = call_executor - .check_override(onchain_code, &BlockId::Number(Default::default())) + .check_override(onchain_code, backend.blockchain().info().genesis_hash) .expect("RuntimeCode override") .0; diff --git a/client/service/src/client/client.rs b/client/service/src/client/client.rs index d32baa671f..6a75fad628 100644 --- a/client/service/src/client/client.rs +++ b/client/service/src/client/client.rs @@ -493,7 +493,8 @@ where /// Get the RuntimeVersion at a given block. pub fn runtime_version_at(&self, id: &BlockId) -> sp_blockchain::Result { - CallExecutor::runtime_version(&self.executor, id) + let hash = self.backend.blockchain().expect_block_hash_from_id(id)?; + CallExecutor::runtime_version(&self.executor, hash) } /// Apply a checked and validated block to an operation. If a justification is provided @@ -1241,7 +1242,7 @@ where method: &str, call_data: &[u8], ) -> sp_blockchain::Result<(Vec, StorageProof)> { - self.executor.prove_execution(&BlockId::Hash(hash), method, call_data) + self.executor.prove_execution(hash, method, call_data) } fn read_proof_collection( @@ -1726,9 +1727,10 @@ where &self, params: CallApiAtParams, ) -> Result, sp_api::ApiError> { + let at_hash = self.expect_block_hash_from_id(params.at)?; self.executor .contextual_call( - params.at, + at_hash, params.function, ¶ms.arguments, params.overlayed_changes, @@ -1740,7 +1742,8 @@ where } fn runtime_version_at(&self, at: &BlockId) -> Result { - CallExecutor::runtime_version(&self.executor, at).map_err(Into::into) + let hash = self.backend.blockchain().expect_block_hash_from_id(at)?; + CallExecutor::runtime_version(&self.executor, hash).map_err(Into::into) } fn state_at(&self, at: &BlockId) -> Result { diff --git a/client/service/src/client/wasm_substitutes.rs b/client/service/src/client/wasm_substitutes.rs index a7a3b2cbb2..ed931d3dae 100644 --- a/client/service/src/client/wasm_substitutes.rs +++ b/client/service/src/client/wasm_substitutes.rs @@ -22,10 +22,7 @@ use sc_client_api::backend; use sc_executor::RuntimeVersionOf; use sp_blockchain::{HeaderBackend, Result}; use sp_core::traits::{FetchRuntimeCode, RuntimeCode, WrappedRuntimeCode}; -use sp_runtime::{ - generic::BlockId, - traits::{Block as BlockT, NumberFor}, -}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; use sp_state_machine::BasicExternalities; use sp_version::RuntimeVersion; use std::{ @@ -54,10 +51,13 @@ impl WasmSubstitute { RuntimeCode { code_fetcher: self, hash: self.hash.clone(), heap_pages } } - /// Returns `true` when the substitute matches for the given `block_id`. - fn matches(&self, block_id: &BlockId, backend: &impl backend::Backend) -> bool { - let requested_block_number = - backend.blockchain().block_number_from_id(block_id).ok().flatten(); + /// Returns `true` when the substitute matches for the given `hash`. + fn matches( + &self, + hash: ::Hash, + backend: &impl backend::Backend, + ) -> bool { + let requested_block_number = backend.blockchain().number(hash).ok().flatten(); Some(self.block_number) <= requested_block_number } @@ -147,10 +147,10 @@ where &self, spec: u32, pages: Option, - block_id: &BlockId, + hash: Block::Hash, ) -> Option<(RuntimeCode<'_>, RuntimeVersion)> { let s = self.substitutes.get(&spec)?; - s.matches(block_id, &*self.backend) + s.matches(hash, &*self.backend) .then(|| (s.runtime_code(pages), s.version.clone())) } diff --git a/primitives/version/src/lib.rs b/primitives/version/src/lib.rs index 0bd62f0bac..37bb15afb2 100644 --- a/primitives/version/src/lib.rs +++ b/primitives/version/src/lib.rs @@ -48,7 +48,7 @@ pub use sp_runtime::{create_runtime_str, StateVersion}; pub use sp_std; #[cfg(feature = "std")] -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::traits::Block as BlockT; #[cfg(feature = "std")] pub mod embed; @@ -370,14 +370,14 @@ pub trait GetNativeVersion { #[cfg(feature = "std")] pub trait GetRuntimeVersionAt { /// Returns the version of runtime at the given block. - fn runtime_version(&self, at: &BlockId) -> Result; + fn runtime_version(&self, at: ::Hash) -> Result; } #[cfg(feature = "std")] impl, Block: BlockT> GetRuntimeVersionAt for std::sync::Arc { - fn runtime_version(&self, at: &BlockId) -> Result { + fn runtime_version(&self, at: ::Hash) -> Result { (&**self).runtime_version(at) } } From ca5a505b7085f7af51eb76c686cc80b55bf6d5ed Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Tue, 24 Jan 2023 14:26:04 +0100 Subject: [PATCH 44/80] service: storage monitor added (#13082) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * service: storage monitor added Storage monitor added. It uses `notify` create to get notifications about any changes to monitored path (which is database path). Notifications are consumed in essential task which terminates when available storage space drops below given threshold. Closes: #12399 * Cargo.lock updated * misspell * fs events throttling added * minor updates * filter out non mutating events * misspell * ".git/.scripts/commands/fmt/fmt.sh" * Update client/service/src/storage_monitor.rs Co-authored-by: Anton * storage-monitor crate added * cleanup: configuration + service builder * storage_monitor in custom service (wip) * copy-paste bad desc fixed * notify removed * storage_monitor added to node * fix for clippy * publish = false * Update bin/node/cli/src/command.rs Co-authored-by: Dmitry Markin * Apply suggestions from code review Co-authored-by: Bastian Köcher * crate name: storage-monitor -> sc-storage-monitor * error handling improved * Apply suggestions from code review Co-authored-by: Bastian Köcher * publish=false removed Co-authored-by: command-bot <> Co-authored-by: Anton Co-authored-by: Dmitry Markin Co-authored-by: Bastian Köcher --- Cargo.lock | 31 +++++ Cargo.toml | 1 + bin/node/cli/Cargo.toml | 2 + bin/node/cli/src/cli.rs | 4 + bin/node/cli/src/command.rs | 3 +- bin/node/cli/src/service.rs | 19 ++- client/cli/src/params/database_params.rs | 4 +- client/service/Cargo.toml | 1 + client/service/src/error.rs | 3 + client/storage-monitor/Cargo.toml | 20 +++ client/storage-monitor/src/lib.rs | 149 +++++++++++++++++++++++ 11 files changed, 227 insertions(+), 10 deletions(-) create mode 100644 client/storage-monitor/Cargo.toml create mode 100644 client/storage-monitor/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 08948ffbd9..214c4f72c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4665,6 +4665,20 @@ dependencies = [ "memoffset 0.6.5", ] +[[package]] +name = "nix" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694" +dependencies = [ + "bitflags", + "cfg-if", + "libc", + "memoffset 0.7.1", + "pin-utils", + "static_assertions", +] + [[package]] name = "node-bench" version = "0.9.0-dev" @@ -4752,6 +4766,7 @@ dependencies = [ "sc-rpc", "sc-service", "sc-service-test", + "sc-storage-monitor", "sc-sync-state-rpc", "sc-sysinfo", "sc-telemetry", @@ -8895,6 +8910,7 @@ dependencies = [ "sc-rpc", "sc-rpc-server", "sc-rpc-spec-v2", + "sc-storage-monitor", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -8973,6 +8989,21 @@ dependencies = [ "sp-core", ] +[[package]] +name = "sc-storage-monitor" +version = "0.1.0" +dependencies = [ + "clap 4.0.32", + "futures", + "log", + "nix 0.26.1", + "sc-client-db", + "sc-utils", + "sp-core", + "thiserror", + "tokio", +] + [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 8f55d8e527..f7eedadd1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ members = [ "client/service", "client/service/test", "client/state-db", + "client/storage-monitor", "client/sysinfo", "client/sync-state-rpc", "client/telemetry", diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 4d9279b857..8a883ee011 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -81,6 +81,7 @@ sc-executor = { version = "0.10.0-dev", path = "../../../client/executor" } sc-authority-discovery = { version = "0.10.0-dev", path = "../../../client/authority-discovery" } sc-sync-state-rpc = { version = "0.10.0-dev", path = "../../../client/sync-state-rpc" } sc-sysinfo = { version = "6.0.0-dev", path = "../../../client/sysinfo" } +sc-storage-monitor = { version = "0.1.0", path = "../../../client/storage-monitor" } # frame dependencies frame-system = { version = "4.0.0-dev", path = "../../../frame/system" } @@ -138,6 +139,7 @@ substrate-frame-cli = { version = "4.0.0-dev", optional = true, path = "../../.. try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" } sc-cli = { version = "0.10.0-dev", path = "../../../client/cli", optional = true } pallet-balances = { version = "4.0.0-dev", path = "../../../frame/balances" } +sc-storage-monitor = { version = "0.1.0", path = "../../../client/storage-monitor" } [features] default = ["cli"] diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index bb7f8a4c60..7bea336c8e 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -36,6 +36,10 @@ pub struct Cli { /// telemetry, if telemetry is enabled. #[arg(long)] pub no_hardware_benchmarks: bool, + + #[allow(missing_docs)] + #[clap(flatten)] + pub storage_monitor: sc_storage_monitor::StorageMonitorParams, } /// Possible subcommands of the main binary. diff --git a/bin/node/cli/src/command.rs b/bin/node/cli/src/command.rs index fd464bbc91..2ed8a2c754 100644 --- a/bin/node/cli/src/command.rs +++ b/bin/node/cli/src/command.rs @@ -87,8 +87,7 @@ pub fn run() -> Result<()> { None => { let runner = cli.create_runner(&cli.run)?; runner.run_node_until_exit(|config| async move { - service::new_full(config, cli.no_hardware_benchmarks) - .map_err(sc_cli::Error::Service) + service::new_full(config, cli).map_err(sc_cli::Error::Service) }) }, Some(Subcommand::Inspect(cmd)) => { diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index d77a333dfa..e329087947 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -20,6 +20,7 @@ //! Service implementation. Specialized wrapper over substrate service. +use crate::Cli; use codec::Encode; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use frame_system_rpc_runtime_api::AccountNonceApi; @@ -556,12 +557,18 @@ pub fn new_full_base( } /// Builds a new service for a full client. -pub fn new_full( - config: Configuration, - disable_hardware_benchmarks: bool, -) -> Result { - new_full_base(config, disable_hardware_benchmarks, |_, _| ()) - .map(|NewFullBase { task_manager, .. }| task_manager) +pub fn new_full(config: Configuration, cli: Cli) -> Result { + let database_source = config.database.clone(); + let task_manager = new_full_base(config, cli.no_hardware_benchmarks, |_, _| ()) + .map(|NewFullBase { task_manager, .. }| task_manager)?; + + sc_storage_monitor::StorageMonitorService::try_spawn( + cli.storage_monitor, + database_source, + &task_manager.spawn_essential_handle(), + )?; + + Ok(task_manager) } #[cfg(test)] diff --git a/client/cli/src/params/database_params.rs b/client/cli/src/params/database_params.rs index fdd3622580..06a154fd60 100644 --- a/client/cli/src/params/database_params.rs +++ b/client/cli/src/params/database_params.rs @@ -19,7 +19,7 @@ use crate::arg_enums::Database; use clap::Args; -/// Parameters for block import. +/// Parameters for database #[derive(Debug, Clone, PartialEq, Args)] pub struct DatabaseParams { /// Select database backend to use. @@ -32,7 +32,7 @@ pub struct DatabaseParams { } impl DatabaseParams { - /// Limit the memory the database cache can use. + /// Database backend pub fn database(&self) -> Option { self.database } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 6122895d23..b4ce3bbbb7 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -73,6 +73,7 @@ sc-offchain = { version = "4.0.0-dev", path = "../offchain" } prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.10.0-dev" } sc-tracing = { version = "4.0.0-dev", path = "../tracing" } sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" } +sc-storage-monitor = { version = "0.1.0", path = "../storage-monitor" } tracing = "0.1.29" tracing-futures = { version = "0.2.4" } async-trait = "0.1.57" diff --git a/client/service/src/error.rs b/client/service/src/error.rs index 001a83922d..ec29511939 100644 --- a/client/service/src/error.rs +++ b/client/service/src/error.rs @@ -48,6 +48,9 @@ pub enum Error { #[error(transparent)] Telemetry(#[from] sc_telemetry::Error), + #[error(transparent)] + Storage(#[from] sc_storage_monitor::Error), + #[error("Best chain selection strategy (SelectChain) is not provided.")] SelectChainRequired, diff --git a/client/storage-monitor/Cargo.toml b/client/storage-monitor/Cargo.toml new file mode 100644 index 0000000000..2ba24f9e2e --- /dev/null +++ b/client/storage-monitor/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "sc-storage-monitor" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2021" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" +repository = "https://github.com/paritytech/substrate" +description = "Storage monitor service for substrate" +homepage = "https://substrate.io" + +[dependencies] +clap = { version = "4.0.9", features = ["derive", "string"] } +futures = "0.3.21" +log = "0.4.17" +nix = { version = "0.26.1", features = ["fs"] } +sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../db" } +sc-utils = { version = "4.0.0-dev", path = "../utils" } +sp-core = { version = "7.0.0", path = "../../primitives/core" } +tokio = "1.22.0" +thiserror = "1.0.30" diff --git a/client/storage-monitor/src/lib.rs b/client/storage-monitor/src/lib.rs new file mode 100644 index 0000000000..39bd15675b --- /dev/null +++ b/client/storage-monitor/src/lib.rs @@ -0,0 +1,149 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use clap::Args; +use nix::{errno::Errno, sys::statvfs::statvfs}; +use sc_client_db::DatabaseSource; +use sp_core::traits::SpawnEssentialNamed; +use std::{ + path::{Path, PathBuf}, + time::Duration, +}; + +const LOG_TARGET: &str = "storage-monitor"; + +/// Error type used in this crate. +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("IO Error")] + IOError(#[from] Errno), + #[error("Out of storage space: available {0}MB, required {1}MB")] + StorageOutOfSpace(u64, u64), +} + +/// Parameters used to create the storage monitor. +#[derive(Default, Debug, Clone, Args)] +pub struct StorageMonitorParams { + /// Required available space on database storage. If available space for DB storage drops below + /// the given threshold, node will be gracefully terminated. If `0` is given monitoring will be + /// disabled. + #[arg(long = "db-storage-threshold", value_name = "MB", default_value_t = 1000)] + pub threshold: u64, + + /// How often available space is polled. + #[arg(long = "db-storage-polling-period", value_name = "SECONDS", default_value_t = 5, value_parser = clap::value_parser!(u32).range(1..))] + pub polling_period: u32, +} + +/// Storage monitor service: checks the available space for the filesystem for fiven path. +pub struct StorageMonitorService { + /// watched path + path: PathBuf, + /// number of megabytes that shall be free on the filesystem for watched path + threshold: u64, + /// storage space polling period (seconds) + polling_period: u32, +} + +impl StorageMonitorService { + /// Creates new StorageMonitorService for given client config + pub fn try_spawn( + parameters: StorageMonitorParams, + database: DatabaseSource, + spawner: &impl SpawnEssentialNamed, + ) -> Result<(), Error> { + Ok(match (parameters.threshold, database.path()) { + (0, _) => { + log::info!( + target: LOG_TARGET, + "StorageMonitorService: threshold `0` given, storage monitoring disabled", + ); + }, + (_, None) => { + log::warn!( + target: LOG_TARGET, + "StorageMonitorService: no database path to observe", + ); + }, + (threshold, Some(path)) => { + log::debug!( + target: LOG_TARGET, + "Initializing StorageMonitorService for db path: {:?}", + path, + ); + + Self::check_free_space(&path, threshold)?; + + let storage_monitor_service = StorageMonitorService { + path: path.to_path_buf(), + threshold, + polling_period: parameters.polling_period, + }; + + spawner.spawn_essential( + "storage-monitor", + None, + Box::pin(storage_monitor_service.run()), + ); + }, + }) + } + + /// Main monitoring loop, intended to be spawned as essential task. Quits if free space drop + /// below threshold. + async fn run(self) { + loop { + tokio::time::sleep(Duration::from_secs(self.polling_period.into())).await; + if Self::check_free_space(&self.path, self.threshold).is_err() { + break + }; + } + } + + /// Returns free space in MB, or error if statvfs failed. + fn free_space(path: &Path) -> Result { + statvfs(path) + .map(|stats| stats.blocks_available() * stats.block_size() / 1_000_000) + .map_err(Error::from) + } + + /// Checks if the amount of free space for given `path` is above given `threshold`. + /// If it dropped below, error is returned. + /// System errors are silently ignored. + fn check_free_space(path: &Path, threshold: u64) -> Result<(), Error> { + match StorageMonitorService::free_space(path) { + Ok(available_space) => { + log::trace!( + target: LOG_TARGET, + "free: {available_space} , threshold: {threshold}.", + ); + + if available_space < threshold { + log::error!(target: LOG_TARGET, "Available space {available_space}MB for path `{}` dropped below threshold: {threshold}MB , terminating...", path.display()); + Err(Error::StorageOutOfSpace(available_space, threshold)) + } else { + Ok(()) + } + }, + Err(e) => { + log::error!(target: LOG_TARGET, "Could not read available space: {:?}.", e); + Err(e) + }, + } + } +} From 84af67204b422fc2b7d05db55cb75eb2d941246b Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:55:42 +0100 Subject: [PATCH 45/80] beefy: Add LOG_TARGET constant (#13222) * LOG_TARGET const * fmt --- client/beefy/src/aux_schema.rs | 6 +- client/beefy/src/communication/gossip.rs | 15 ++- .../incoming_requests_handler.rs | 8 +- .../src/communication/request_response/mod.rs | 2 + .../outgoing_requests_engine.rs | 41 +++--- client/beefy/src/import.rs | 11 +- client/beefy/src/keystore.rs | 9 +- client/beefy/src/lib.rs | 33 +++-- client/beefy/src/round.rs | 10 +- client/beefy/src/worker.rs | 120 ++++++++++-------- 10 files changed, 153 insertions(+), 102 deletions(-) diff --git a/client/beefy/src/aux_schema.rs b/client/beefy/src/aux_schema.rs index 67deee19b5..fafa9948c5 100644 --- a/client/beefy/src/aux_schema.rs +++ b/client/beefy/src/aux_schema.rs @@ -18,7 +18,7 @@ //! Schema for BEEFY state persisted in the aux-db. -use crate::worker::PersistedState; +use crate::{worker::PersistedState, LOG_TARGET}; use codec::{Decode, Encode}; use log::{info, trace}; use sc_client_api::{backend::AuxStore, Backend}; @@ -31,7 +31,7 @@ const WORKER_STATE: &[u8] = b"beefy_voter_state"; const CURRENT_VERSION: u32 = 1; pub(crate) fn write_current_version(backend: &B) -> ClientResult<()> { - info!(target: "beefy", "🥩 write aux schema version {:?}", CURRENT_VERSION); + info!(target: LOG_TARGET, "🥩 write aux schema version {:?}", CURRENT_VERSION); AuxStore::insert_aux(backend, &[(VERSION_KEY, CURRENT_VERSION.encode().as_slice())], &[]) } @@ -40,7 +40,7 @@ pub(crate) fn write_voter_state( backend: &B, state: &PersistedState, ) -> ClientResult<()> { - trace!(target: "beefy", "🥩 persisting {:?}", state); + trace!(target: LOG_TARGET, "🥩 persisting {:?}", state); backend.insert_aux(&[(WORKER_STATE, state.encode().as_slice())], &[]) } diff --git a/client/beefy/src/communication/gossip.rs b/client/beefy/src/communication/gossip.rs index bbc35ac8e5..116a6286ed 100644 --- a/client/beefy/src/communication/gossip.rs +++ b/client/beefy/src/communication/gossip.rs @@ -28,7 +28,7 @@ use log::{debug, trace}; use parking_lot::{Mutex, RwLock}; use wasm_timer::Instant; -use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore}; +use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore, LOG_TARGET}; use beefy_primitives::{ crypto::{Public, Signature}, VoteMessage, @@ -122,7 +122,7 @@ where /// /// Noting round will start a live `round`. pub(crate) fn note_round(&self, round: NumberFor) { - debug!(target: "beefy", "🥩 About to note gossip round #{}", round); + debug!(target: LOG_TARGET, "🥩 About to note gossip round #{}", round); self.known_votes.write().insert(round); } @@ -130,7 +130,7 @@ where /// /// This can be called once round is complete so we stop gossiping for it. pub(crate) fn conclude_round(&self, round: NumberFor) { - debug!(target: "beefy", "🥩 About to drop gossip round #{}", round); + debug!(target: LOG_TARGET, "🥩 About to drop gossip round #{}", round); self.known_votes.write().conclude(round); } } @@ -174,7 +174,10 @@ where return ValidationResult::ProcessAndKeep(self.topic) } else { // TODO: report peer - debug!(target: "beefy", "🥩 Bad signature on message: {:?}, from: {:?}", msg, sender); + debug!( + target: LOG_TARGET, + "🥩 Bad signature on message: {:?}, from: {:?}", msg, sender + ); } } @@ -192,7 +195,7 @@ where let round = msg.commitment.block_number; let expired = !known_votes.is_live(&round); - trace!(target: "beefy", "🥩 Message for round #{} expired: {}", round, expired); + trace!(target: LOG_TARGET, "🥩 Message for round #{} expired: {}", round, expired); expired }) @@ -226,7 +229,7 @@ where let round = msg.commitment.block_number; let allowed = known_votes.is_live(&round); - trace!(target: "beefy", "🥩 Message for round #{} allowed: {}", round, allowed); + trace!(target: LOG_TARGET, "🥩 Message for round #{} allowed: {}", round, allowed); allowed }) diff --git a/client/beefy/src/communication/request_response/incoming_requests_handler.rs b/client/beefy/src/communication/request_response/incoming_requests_handler.rs index 9f02b7162b..d3be73dc06 100644 --- a/client/beefy/src/communication/request_response/incoming_requests_handler.rs +++ b/client/beefy/src/communication/request_response/incoming_requests_handler.rs @@ -30,7 +30,7 @@ use sp_runtime::traits::Block; use std::{marker::PhantomData, sync::Arc}; use crate::communication::request_response::{ - on_demand_justifications_protocol_config, Error, JustificationRequest, + on_demand_justifications_protocol_config, Error, JustificationRequest, BEEFY_SYNC_LOG_TARGET, }; /// A request coming in, including a sender for sending responses. @@ -174,21 +174,21 @@ where /// Run [`BeefyJustifsRequestHandler`]. pub async fn run(mut self) { - trace!(target: "beefy::sync", "🥩 Running BeefyJustifsRequestHandler"); + trace!(target: BEEFY_SYNC_LOG_TARGET, "🥩 Running BeefyJustifsRequestHandler"); while let Ok(request) = self.request_receiver.recv(|| vec![]).await { let peer = request.peer; match self.handle_request(request) { Ok(()) => { debug!( - target: "beefy::sync", + target: BEEFY_SYNC_LOG_TARGET, "🥩 Handled BEEFY justification request from {:?}.", peer ) }, Err(e) => { // TODO (issue #12293): apply reputation changes here based on error type. debug!( - target: "beefy::sync", + target: BEEFY_SYNC_LOG_TARGET, "🥩 Failed to handle BEEFY justification request from {:?}: {}", peer, e, ) }, diff --git a/client/beefy/src/communication/request_response/mod.rs b/client/beefy/src/communication/request_response/mod.rs index c83bb9d57e..22a20c2470 100644 --- a/client/beefy/src/communication/request_response/mod.rs +++ b/client/beefy/src/communication/request_response/mod.rs @@ -40,6 +40,8 @@ const JUSTIF_CHANNEL_SIZE: usize = 10; const MAX_RESPONSE_SIZE: u64 = 1024 * 1024; const JUSTIF_REQUEST_TIMEOUT: Duration = Duration::from_secs(3); +const BEEFY_SYNC_LOG_TARGET: &str = "beefy::sync"; + /// Get the configuration for the BEEFY justifications Request/response protocol. /// /// Returns a receiver for messages received on this protocol and the requested diff --git a/client/beefy/src/communication/request_response/outgoing_requests_engine.rs b/client/beefy/src/communication/request_response/outgoing_requests_engine.rs index 00ee7610dd..c7dc269b49 100644 --- a/client/beefy/src/communication/request_response/outgoing_requests_engine.rs +++ b/client/beefy/src/communication/request_response/outgoing_requests_engine.rs @@ -32,7 +32,7 @@ use sp_runtime::traits::{Block, NumberFor}; use std::{collections::VecDeque, result::Result, sync::Arc}; use crate::{ - communication::request_response::{Error, JustificationRequest}, + communication::request_response::{Error, JustificationRequest, BEEFY_SYNC_LOG_TARGET}, justification::{decode_and_verify_finality_proof, BeefyVersionedFinalityProof}, KnownPeers, }; @@ -96,10 +96,8 @@ impl OnDemandJustificationsEngine { fn request_from_peer(&mut self, peer: PeerId, req_info: RequestInfo) { debug!( - target: "beefy::sync", - "🥩 requesting justif #{:?} from peer {:?}", - req_info.block, - peer, + target: BEEFY_SYNC_LOG_TARGET, + "🥩 requesting justif #{:?} from peer {:?}", req_info.block, peer, ); let payload = JustificationRequest:: { begin: req_info.block }.encode(); @@ -132,7 +130,10 @@ impl OnDemandJustificationsEngine { if let Some(peer) = self.try_next_peer() { self.request_from_peer(peer, RequestInfo { block, active_set }); } else { - debug!(target: "beefy::sync", "🥩 no good peers to request justif #{:?} from", block); + debug!( + target: BEEFY_SYNC_LOG_TARGET, + "🥩 no good peers to request justif #{:?} from", block + ); } } @@ -141,8 +142,8 @@ impl OnDemandJustificationsEngine { match &self.state { State::AwaitingResponse(_, req_info, _) if req_info.block <= block => { debug!( - target: "beefy::sync", "🥩 cancel pending request for justification #{:?}", - req_info.block + target: BEEFY_SYNC_LOG_TARGET, + "🥩 cancel pending request for justification #{:?}", req_info.block ); self.state = State::Idle; }, @@ -159,17 +160,21 @@ impl OnDemandJustificationsEngine { response .map_err(|e| { debug!( - target: "beefy::sync", + target: BEEFY_SYNC_LOG_TARGET, "🥩 for on demand justification #{:?}, peer {:?} hung up: {:?}", - req_info.block, peer, e + req_info.block, + peer, + e ); Error::InvalidResponse })? .map_err(|e| { debug!( - target: "beefy::sync", + target: BEEFY_SYNC_LOG_TARGET, "🥩 for on demand justification #{:?}, peer {:?} error: {:?}", - req_info.block, peer, e + req_info.block, + peer, + e ); Error::InvalidResponse }) @@ -181,7 +186,7 @@ impl OnDemandJustificationsEngine { ) .map_err(|e| { debug!( - target: "beefy::sync", + target: BEEFY_SYNC_LOG_TARGET, "🥩 for on demand justification #{:?}, peer {:?} responded with invalid proof: {:?}", req_info.block, peer, e ); @@ -213,14 +218,16 @@ impl OnDemandJustificationsEngine { if let Some(peer) = self.try_next_peer() { self.request_from_peer(peer, req_info); } else { - warn!(target: "beefy::sync", "🥩 ran out of peers to request justif #{:?} from", block); + warn!( + target: BEEFY_SYNC_LOG_TARGET, + "🥩 ran out of peers to request justif #{:?} from", block + ); } }) .map(|proof| { debug!( - target: "beefy::sync", - "🥩 received valid on-demand justif #{:?} from {:?}", - block, peer + target: BEEFY_SYNC_LOG_TARGET, + "🥩 received valid on-demand justif #{:?} from {:?}", block, peer ); proof }) diff --git a/client/beefy/src/import.rs b/client/beefy/src/import.rs index 0ed50d0ec8..f0fe3bfa02 100644 --- a/client/beefy/src/import.rs +++ b/client/beefy/src/import.rs @@ -35,6 +35,7 @@ use sc_consensus::{BlockCheckParams, BlockImport, BlockImportParams, ImportResul use crate::{ communication::notification::BeefyVersionedFinalityProofSender, justification::{decode_and_verify_finality_proof, BeefyVersionedFinalityProof}, + LOG_TARGET, }; /// A block-import handler for BEEFY. @@ -138,16 +139,20 @@ where (Some(encoded), ImportResult::Imported(_)) => { if let Ok(proof) = self.decode_and_verify(&encoded, number, hash) { // The proof is valid and the block is imported and final, we can import. - debug!(target: "beefy", "🥩 import justif {:?} for block number {:?}.", proof, number); + debug!( + target: LOG_TARGET, + "🥩 import justif {:?} for block number {:?}.", proof, number + ); // Send the justification to the BEEFY voter for processing. self.justification_sender .notify(|| Ok::<_, ()>(proof)) .expect("forwards closure result; the closure always returns Ok; qed."); } else { debug!( - target: "beefy", + target: LOG_TARGET, "🥩 error decoding justification: {:?} for imported block {:?}", - encoded, number, + encoded, + number, ); } }, diff --git a/client/beefy/src/keystore.rs b/client/beefy/src/keystore.rs index 8d77410746..d1f5615a93 100644 --- a/client/beefy/src/keystore.rs +++ b/client/beefy/src/keystore.rs @@ -28,7 +28,7 @@ use beefy_primitives::{ BeefyAuthorityId, KEY_TYPE, }; -use crate::error; +use crate::{error, LOG_TARGET}; /// A BEEFY specific keystore implemented as a `Newtype`. This is basically a /// wrapper around [`sp_keystore::SyncCryptoStore`] and allows to customize @@ -53,7 +53,12 @@ impl BeefyKeystore { .collect(); if public.len() > 1 { - warn!(target: "beefy", "🥩 Multiple private keys found for: {:?} ({})", public, public.len()); + warn!( + target: LOG_TARGET, + "🥩 Multiple private keys found for: {:?} ({})", + public, + public.len() + ); } public.get(0).cloned() diff --git a/client/beefy/src/lib.rs b/client/beefy/src/lib.rs index 5b6531822a..185f3b1ad5 100644 --- a/client/beefy/src/lib.rs +++ b/client/beefy/src/lib.rs @@ -75,6 +75,8 @@ pub use communication::beefy_protocol_name::{ #[cfg(test)] mod tests; +const LOG_TARGET: &str = "beefy"; + /// A convenience BEEFY client trait that defines all the type bounds a BEEFY client /// has to satisfy. Ideally that should actually be a trait alias. Unfortunately as /// of today, Rust does not allow a type alias to be used as a trait bound. Tracking @@ -252,11 +254,11 @@ where prometheus_registry.as_ref().map(metrics::Metrics::register).and_then( |result| match result { Ok(metrics) => { - debug!(target: "beefy", "🥩 Registered metrics"); + debug!(target: LOG_TARGET, "🥩 Registered metrics"); Some(metrics) }, Err(err) => { - debug!(target: "beefy", "🥩 Failed to register metrics: {:?}", err); + debug!(target: LOG_TARGET, "🥩 Failed to register metrics: {:?}", err); None }, }, @@ -276,7 +278,7 @@ where }) { Ok(state) => state, Err(e) => { - error!(target: "beefy", "Error: {:?}. Terminating.", e); + error!(target: LOG_TARGET, "Error: {:?}. Terminating.", e); return }, }; @@ -321,7 +323,7 @@ where state.set_best_grandpa(best_grandpa); // Overwrite persisted data with newly provided `min_block_delta`. state.set_min_block_delta(min_block_delta); - info!(target: "beefy", "🥩 Loading BEEFY voter state from db: {:?}.", state); + info!(target: LOG_TARGET, "🥩 Loading BEEFY voter state from db: {:?}.", state); Ok(state) } else { initialize_voter_state(backend, runtime, best_grandpa, min_block_delta) @@ -357,7 +359,7 @@ where .map(|justifs| justifs.get(BEEFY_ENGINE_ID).is_some()) { info!( - target: "beefy", + target: LOG_TARGET, "🥩 Initialize BEEFY voter at last BEEFY finalized block: {:?}.", *header.number() ); @@ -382,10 +384,11 @@ where let genesis_set = expect_validator_set(runtime, BlockId::hash(header.hash())) .and_then(genesis_set_sanity_check)?; info!( - target: "beefy", + target: LOG_TARGET, "🥩 Loading BEEFY voter state from genesis on what appears to be first startup. \ Starting voting rounds at block {:?}, genesis validator set {:?}.", - genesis_num, genesis_set, + genesis_num, + genesis_set, ); sessions.push_front(Rounds::new(genesis_num, genesis_set)); @@ -394,7 +397,11 @@ where } if let Some(active) = worker::find_authorities_change::(&header) { - info!(target: "beefy", "🥩 Marking block {:?} as BEEFY Mandatory.", *header.number()); + info!( + target: LOG_TARGET, + "🥩 Marking block {:?} as BEEFY Mandatory.", + *header.number() + ); sessions.push_front(Rounds::new(*header.number(), active)); } @@ -407,7 +414,7 @@ where .flatten() .ok_or_else(|| { let msg = format!("{}. Could not initialize BEEFY voter.", parent_hash); - error!(target: "beefy", "🥩 {}", msg); + error!(target: LOG_TARGET, "🥩 {}", msg); ClientError::Consensus(sp_consensus::Error::StateUnavailable(msg)) })?; @@ -432,7 +439,7 @@ where R: ProvideRuntimeApi, R::Api: BeefyApi, { - info!(target: "beefy", "🥩 BEEFY gadget waiting for BEEFY pallet to become available..."); + info!(target: LOG_TARGET, "🥩 BEEFY gadget waiting for BEEFY pallet to become available..."); loop { futures::select! { notif = finality.next() => { @@ -444,7 +451,7 @@ where if let Some(active) = runtime.runtime_api().validator_set(&at).ok().flatten() { // Beefy pallet available, return best grandpa at the time. info!( - target: "beefy", "🥩 BEEFY pallet available: block {:?} validator set {:?}", + target: LOG_TARGET, "🥩 BEEFY pallet available: block {:?} validator set {:?}", notif.header.number(), active ); return Ok(notif.header) @@ -456,7 +463,7 @@ where } } let err_msg = "🥩 Gossip engine has unexpectedly terminated.".into(); - error!(target: "beefy", "{}", err_msg); + error!(target: LOG_TARGET, "{}", err_msg); Err(ClientError::Backend(err_msg)) } @@ -466,7 +473,7 @@ fn genesis_set_sanity_check( if active.id() == GENESIS_AUTHORITY_SET_ID { Ok(active) } else { - error!(target: "beefy", "🥩 Unexpected ID for genesis validator set {:?}.", active); + error!(target: LOG_TARGET, "🥩 Unexpected ID for genesis validator set {:?}.", active); Err(ClientError::Backend("BEEFY Genesis sanity check failed.".into())) } } diff --git a/client/beefy/src/round.rs b/client/beefy/src/round.rs index 48d3d08729..647d42110e 100644 --- a/client/beefy/src/round.rs +++ b/client/beefy/src/round.rs @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use crate::LOG_TARGET; + use beefy_primitives::{ crypto::{Public, Signature}, ValidatorSet, ValidatorSetId, @@ -122,11 +124,11 @@ where ) -> bool { let num = round.1; if num < self.session_start || Some(num) <= self.best_done { - debug!(target: "beefy", "🥩 received vote for old stale round {:?}, ignoring", num); + debug!(target: LOG_TARGET, "🥩 received vote for old stale round {:?}, ignoring", num); false } else if !self.validators().iter().any(|id| vote.0 == *id) { debug!( - target: "beefy", + target: LOG_TARGET, "🥩 received vote {:?} from validator that is not in the validator set, ignoring", vote ); @@ -145,7 +147,7 @@ where .get(round) .map(|tracker| tracker.is_done(threshold(self.validator_set.len()))) .unwrap_or(false); - trace!(target: "beefy", "🥩 Round #{} done: {}", round.1, done); + trace!(target: LOG_TARGET, "🥩 Round #{} done: {}", round.1, done); if done { let signatures = self.rounds.remove(round)?.votes; @@ -165,7 +167,7 @@ where self.rounds.retain(|&(_, number), _| number > round_num); self.mandatory_done = self.mandatory_done || round_num == self.session_start; self.best_done = self.best_done.max(Some(round_num)); - debug!(target: "beefy", "🥩 Concluded round #{}", round_num); + debug!(target: LOG_TARGET, "🥩 Concluded round #{}", round_num); } } diff --git a/client/beefy/src/worker.rs b/client/beefy/src/worker.rs index 8ec1403bb3..19ab52f520 100644 --- a/client/beefy/src/worker.rs +++ b/client/beefy/src/worker.rs @@ -27,7 +27,7 @@ use crate::{ metric_inc, metric_set, metrics::Metrics, round::Rounds, - BeefyVoterLinks, + BeefyVoterLinks, LOG_TARGET, }; use beefy_primitives::{ crypto::{AuthorityId, Signature}, @@ -129,7 +129,7 @@ impl VoterOracle { min_block_delta: min_block_delta.max(1), }) } else { - error!(target: "beefy", "🥩 Invalid sessions queue: {:?}.", sessions); + error!(target: LOG_TARGET, "🥩 Invalid sessions queue: {:?}.", sessions); None } } @@ -227,7 +227,7 @@ impl VoterOracle { let rounds = if let Some(r) = self.sessions.front() { r } else { - debug!(target: "beefy", "🥩 No voting round started"); + debug!(target: LOG_TARGET, "🥩 No voting round started"); return None }; @@ -235,7 +235,7 @@ impl VoterOracle { let target = vote_target(best_grandpa, best_beefy, rounds.session_start(), self.min_block_delta); trace!( - target: "beefy", + target: LOG_TARGET, "🥩 best beefy: #{:?}, best finalized: #{:?}, current_vote_target: {:?}", best_beefy, best_grandpa, @@ -405,7 +405,7 @@ where if store.intersection(&active).count() == 0 { let msg = "no authority public key found in store".to_string(); - debug!(target: "beefy", "🥩 for block {:?} {}", block, msg); + debug!(target: LOG_TARGET, "🥩 for block {:?} {}", block, msg); Err(Error::Keystore(msg)) } else { Ok(()) @@ -418,13 +418,14 @@ where validator_set: ValidatorSet, new_session_start: NumberFor, ) { - debug!(target: "beefy", "🥩 New active validator set: {:?}", validator_set); + debug!(target: LOG_TARGET, "🥩 New active validator set: {:?}", validator_set); // BEEFY should finalize a mandatory block during each session. if let Some(active_session) = self.active_rounds() { if !active_session.mandatory_done() { debug!( - target: "beefy", "🥩 New session {} while active session {} is still lagging.", + target: LOG_TARGET, + "🥩 New session {} while active session {} is still lagging.", validator_set.id(), active_session.validator_set_id(), ); @@ -432,7 +433,7 @@ where } } - if log_enabled!(target: "beefy", log::Level::Debug) { + if log_enabled!(target: LOG_TARGET, log::Level::Debug) { // verify the new validator set - only do it if we're also logging the warning let _ = self.verify_validator_set(&new_session_start, &validator_set); } @@ -443,14 +444,15 @@ where .add_session(Rounds::new(new_session_start, validator_set)); metric_set!(self, beefy_validator_set_id, id); info!( - target: "beefy", + target: LOG_TARGET, "🥩 New Rounds for validator set id: {:?} with session_start {:?}", - id, new_session_start + id, + new_session_start ); } fn handle_finality_notification(&mut self, notification: &FinalityNotification) { - debug!(target: "beefy", "🥩 Finality notification: {:?}", notification); + debug!(target: LOG_TARGET, "🥩 Finality notification: {:?}", notification); let header = ¬ification.header; if *header.number() > self.best_grandpa_block() { @@ -491,14 +493,17 @@ where false, )?, RoundAction::Enqueue => { - debug!(target: "beefy", "🥩 Buffer vote for round: {:?}.", block_num); + debug!(target: LOG_TARGET, "🥩 Buffer vote for round: {:?}.", block_num); if self.pending_votes.len() < MAX_BUFFERED_VOTE_ROUNDS { let votes_vec = self.pending_votes.entry(block_num).or_default(); if votes_vec.try_push(vote).is_err() { - warn!(target: "beefy", "🥩 Buffer vote dropped for round: {:?}", block_num) + warn!( + target: LOG_TARGET, + "🥩 Buffer vote dropped for round: {:?}", block_num + ) } } else { - warn!(target: "beefy", "🥩 Buffer vote dropped for round: {:?}.", block_num); + warn!(target: LOG_TARGET, "🥩 Buffer vote dropped for round: {:?}.", block_num); } }, RoundAction::Drop => (), @@ -520,15 +525,18 @@ where let best_grandpa = self.best_grandpa_block(); match self.voting_oracle().triage_round(block_num, best_grandpa)? { RoundAction::Process => { - debug!(target: "beefy", "🥩 Process justification for round: {:?}.", block_num); + debug!(target: LOG_TARGET, "🥩 Process justification for round: {:?}.", block_num); self.finalize(justification)? }, RoundAction::Enqueue => { - debug!(target: "beefy", "🥩 Buffer justification for round: {:?}.", block_num); + debug!(target: LOG_TARGET, "🥩 Buffer justification for round: {:?}.", block_num); if self.pending_justifications.len() < MAX_BUFFERED_JUSTIFICATIONS { self.pending_justifications.entry(block_num).or_insert(justification); } else { - warn!(target: "beefy", "🥩 Buffer justification dropped for round: {:?}.", block_num); + warn!( + target: LOG_TARGET, + "🥩 Buffer justification dropped for round: {:?}.", block_num + ); } }, RoundAction::Drop => (), @@ -566,7 +574,10 @@ where metric_set!(self, beefy_round_concluded, block_num); - info!(target: "beefy", "🥩 Round #{} concluded, finality_proof: {:?}.", round.1, finality_proof); + info!( + target: LOG_TARGET, + "🥩 Round #{} concluded, finality_proof: {:?}.", round.1, finality_proof + ); // We created the `finality_proof` and know to be valid. // New state is persisted after finalization. @@ -627,7 +638,10 @@ where self.backend .append_justification(hash, (BEEFY_ENGINE_ID, finality_proof.encode())) }) { - error!(target: "beefy", "🥩 Error {:?} on appending justification: {:?}", e, finality_proof); + error!( + target: LOG_TARGET, + "🥩 Error {:?} on appending justification: {:?}", e, finality_proof + ); } self.links @@ -635,7 +649,7 @@ where .notify(|| Ok::<_, ()>(finality_proof)) .expect("forwards closure result; the closure always returns Ok; qed."); } else { - debug!(target: "beefy", "🥩 Can't set best beefy to older: {}", block_num); + debug!(target: LOG_TARGET, "🥩 Can't set best beefy to older: {}", block_num); } Ok(()) } @@ -666,9 +680,9 @@ where if !self.pending_justifications.is_empty() { let justifs_to_handle = to_process_for(&mut self.pending_justifications, interval, _ph); for (num, justification) in justifs_to_handle.into_iter() { - debug!(target: "beefy", "🥩 Handle buffered justification for: {:?}.", num); + debug!(target: LOG_TARGET, "🥩 Handle buffered justification for: {:?}.", num); if let Err(err) = self.finalize(justification) { - error!(target: "beefy", "🥩 Error finalizing block: {}", err); + error!(target: LOG_TARGET, "🥩 Error finalizing block: {}", err); } } // Possibly new interval after processing justifications. @@ -679,14 +693,14 @@ where if !self.pending_votes.is_empty() { let votes_to_handle = to_process_for(&mut self.pending_votes, interval, _ph); for (num, votes) in votes_to_handle.into_iter() { - debug!(target: "beefy", "🥩 Handle buffered votes for: {:?}.", num); + debug!(target: LOG_TARGET, "🥩 Handle buffered votes for: {:?}.", num); for v in votes.into_iter() { if let Err(err) = self.handle_vote( (v.commitment.payload, v.commitment.block_number), (v.id, v.signature), false, ) { - error!(target: "beefy", "🥩 Error handling buffered vote: {}", err); + error!(target: LOG_TARGET, "🥩 Error handling buffered vote: {}", err); }; } } @@ -711,7 +725,7 @@ where /// /// Also handle this self vote by calling `self.handle_vote()` for it. fn do_vote(&mut self, target_number: NumberFor) -> Result<(), Error> { - debug!(target: "beefy", "🥩 Try voting on {}", target_number); + debug!(target: LOG_TARGET, "🥩 Try voting on {}", target_number); // Most of the time we get here, `target` is actually `best_grandpa`, // avoid getting header from backend in that case. @@ -743,7 +757,7 @@ where let payload = if let Some(hash) = self.payload_provider.payload(&target_header) { hash } else { - warn!(target: "beefy", "🥩 No MMR root digest found for: {:?}", target_hash); + warn!(target: LOG_TARGET, "🥩 No MMR root digest found for: {:?}", target_hash); return Ok(()) }; @@ -753,16 +767,22 @@ where .active_rounds_mut() .ok_or(Error::UninitSession)?; if !rounds.should_self_vote(&(payload.clone(), target_number)) { - debug!(target: "beefy", "🥩 Don't double vote for block number: {:?}", target_number); + debug!( + target: LOG_TARGET, + "🥩 Don't double vote for block number: {:?}", target_number + ); return Ok(()) } let (validators, validator_set_id) = (rounds.validators(), rounds.validator_set_id()); let authority_id = if let Some(id) = self.key_store.authority_id(validators) { - debug!(target: "beefy", "🥩 Local authority id: {:?}", id); + debug!(target: LOG_TARGET, "🥩 Local authority id: {:?}", id); id } else { - debug!(target: "beefy", "🥩 Missing validator id - can't vote for: {:?}", target_hash); + debug!( + target: LOG_TARGET, + "🥩 Missing validator id - can't vote for: {:?}", target_hash + ); return Ok(()) }; @@ -772,13 +792,13 @@ where let signature = match self.key_store.sign(&authority_id, &encoded_commitment) { Ok(sig) => sig, Err(err) => { - warn!(target: "beefy", "🥩 Error signing commitment: {:?}", err); + warn!(target: LOG_TARGET, "🥩 Error signing commitment: {:?}", err); return Ok(()) }, }; trace!( - target: "beefy", + target: LOG_TARGET, "🥩 Produced signature using {:?}, is_valid: {:?}", authority_id, BeefyKeystore::verify(&authority_id, &signature, &encoded_commitment) @@ -790,14 +810,14 @@ where metric_inc!(self, beefy_votes_sent); - debug!(target: "beefy", "🥩 Sent vote message: {:?}", message); + debug!(target: LOG_TARGET, "🥩 Sent vote message: {:?}", message); if let Err(err) = self.handle_vote( (message.commitment.payload, message.commitment.block_number), (message.id, message.signature), true, ) { - error!(target: "beefy", "🥩 Error handling self vote: {}", err); + error!(target: LOG_TARGET, "🥩 Error handling self vote: {}", err); } self.gossip_engine.gossip_message(topic::(), encoded_message, false); @@ -808,14 +828,14 @@ where fn process_new_state(&mut self) { // Handle pending justifications and/or votes for now GRANDPA finalized blocks. if let Err(err) = self.try_pending_justif_and_votes() { - debug!(target: "beefy", "🥩 {}", err); + debug!(target: LOG_TARGET, "🥩 {}", err); } // Don't bother voting or requesting justifications during major sync. if !self.network.is_major_syncing() { // There were external events, 'state' is changed, author a vote if needed/possible. if let Err(err) = self.try_to_vote() { - debug!(target: "beefy", "🥩 {}", err); + debug!(target: LOG_TARGET, "🥩 {}", err); } // If the current target is a mandatory block, // make sure there's also an on-demand justification request out for it. @@ -835,13 +855,17 @@ where mut block_import_justif: Fuse>>, mut finality_notifications: Fuse>, ) { - info!(target: "beefy", "🥩 run BEEFY worker, best grandpa: #{:?}.", self.best_grandpa_block()); + info!( + target: LOG_TARGET, + "🥩 run BEEFY worker, best grandpa: #{:?}.", + self.best_grandpa_block() + ); let mut votes = Box::pin( self.gossip_engine .messages_for(topic::()) .filter_map(|notification| async move { - trace!(target: "beefy", "🥩 Got vote message: {:?}", notification); + trace!(target: LOG_TARGET, "🥩 Got vote message: {:?}", notification); VoteMessage::, AuthorityId, Signature>::decode( &mut ¬ification.message[..], @@ -863,7 +887,7 @@ where // Use `select_biased!` to prioritize order below. // Make sure to pump gossip engine. _ = gossip_engine => { - error!(target: "beefy", "🥩 Gossip engine has terminated, closing worker."); + error!(target: LOG_TARGET, "🥩 Gossip engine has terminated, closing worker."); return; }, // Process finality notifications first since these drive the voter. @@ -871,7 +895,7 @@ where if let Some(notification) = notification { self.handle_finality_notification(¬ification); } else { - error!(target: "beefy", "🥩 Finality stream terminated, closing worker."); + error!(target: LOG_TARGET, "🥩 Finality stream terminated, closing worker."); return; } }, @@ -879,7 +903,7 @@ where justif = self.on_demand_justifications.next().fuse() => { if let Some(justif) = justif { if let Err(err) = self.triage_incoming_justif(justif) { - debug!(target: "beefy", "🥩 {}", err); + debug!(target: LOG_TARGET, "🥩 {}", err); } } }, @@ -888,10 +912,10 @@ where // Block import justifications have already been verified to be valid // by `BeefyBlockImport`. if let Err(err) = self.triage_incoming_justif(justif) { - debug!(target: "beefy", "🥩 {}", err); + debug!(target: LOG_TARGET, "🥩 {}", err); } } else { - error!(target: "beefy", "🥩 Block import stream terminated, closing worker."); + error!(target: LOG_TARGET, "🥩 Block import stream terminated, closing worker."); return; } }, @@ -900,10 +924,10 @@ where if let Some(vote) = vote { // Votes have already been verified to be valid by the gossip validator. if let Err(err) = self.triage_incoming_vote(vote) { - debug!(target: "beefy", "🥩 {}", err); + debug!(target: LOG_TARGET, "🥩 {}", err); } } else { - error!(target: "beefy", "🥩 Votes gossiping stream terminated, closing worker."); + error!(target: LOG_TARGET, "🥩 Votes gossiping stream terminated, closing worker."); return; } }, @@ -937,18 +961,14 @@ where // if the mandatory block (session_start) does not have a beefy justification yet, // we vote on it let target = if best_beefy < session_start { - debug!( - target: "beefy", - "🥩 vote target - mandatory block: #{:?}", - session_start, - ); + debug!(target: LOG_TARGET, "🥩 vote target - mandatory block: #{:?}", session_start,); session_start } else { let diff = best_grandpa.saturating_sub(best_beefy) + 1u32.into(); let diff = diff.saturated_into::() / 2; let target = best_beefy + min_delta.max(diff.next_power_of_two()).into(); trace!( - target: "beefy", + target: LOG_TARGET, "🥩 vote target - diff: {:?}, next_power_of_two: {:?}, target block: #{:?}", diff, diff.next_power_of_two(), From 09de7b41599add51cf27eca8f1bc4c50ed8e9453 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 24 Jan 2023 12:21:52 -0600 Subject: [PATCH 46/80] Upgrade wasm-opt to 0.111.0 (#13038) --- Cargo.lock | 12 ++++++------ utils/wasm-builder/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 214c4f72c7..5d34dd81e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11804,9 +11804,9 @@ dependencies = [ [[package]] name = "wasm-opt" -version = "0.110.2" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68e8037b4daf711393f4be2056246d12d975651b14d581520ad5d1f19219cec" +checksum = "84a303793cbc01fb96551badfc7367db6007396bba6bac97936b3c8b6f7fdb41" dependencies = [ "anyhow", "libc", @@ -11820,9 +11820,9 @@ dependencies = [ [[package]] name = "wasm-opt-cxx-sys" -version = "0.110.2" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91adbad477e97bba3fbd21dd7bfb594e7ad5ceb9169ab1c93ab9cb0ada636b6f" +checksum = "d9c9deb56f8a9f2ec177b3bd642a8205621835944ed5da55f2388ef216aca5a4" dependencies = [ "anyhow", "cxx", @@ -11832,9 +11832,9 @@ dependencies = [ [[package]] name = "wasm-opt-sys" -version = "0.110.2" +version = "0.111.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec4fa5a322a4e6ac22fd141f498d56afbdbf9df5debeac32380d2dcaa3e06941" +checksum = "4432e28b542738a9776cedf92e8a99d8991c7b4667ee2c7ccddfb479dd2856a7" dependencies = [ "anyhow", "cc", diff --git a/utils/wasm-builder/Cargo.toml b/utils/wasm-builder/Cargo.toml index 46c5929969..84693f5eec 100644 --- a/utils/wasm-builder/Cargo.toml +++ b/utils/wasm-builder/Cargo.toml @@ -22,4 +22,4 @@ toml = "0.5.4" walkdir = "2.3.2" sp-maybe-compressed-blob = { version = "4.1.0-dev", path = "../../primitives/maybe-compressed-blob" } filetime = "0.2.16" -wasm-opt = "0.110" \ No newline at end of file +wasm-opt = "0.111" \ No newline at end of file From 5749760b7d95bd82599be2b1a23e129dcfa5be28 Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:22:47 +0100 Subject: [PATCH 47/80] storage-monitor: statvfs arithmetic bug fixed (#13234) --- client/storage-monitor/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/storage-monitor/src/lib.rs b/client/storage-monitor/src/lib.rs index 39bd15675b..162fcfe34a 100644 --- a/client/storage-monitor/src/lib.rs +++ b/client/storage-monitor/src/lib.rs @@ -118,7 +118,10 @@ impl StorageMonitorService { /// Returns free space in MB, or error if statvfs failed. fn free_space(path: &Path) -> Result { statvfs(path) - .map(|stats| stats.blocks_available() * stats.block_size() / 1_000_000) + .map(|stats| { + u64::from(stats.blocks_available()).saturating_mul(u64::from(stats.block_size())) / + 1_000_000 + }) .map_err(Error::from) } From d2afb5d97bc0ddad72b02b1e2e6ea8c56835bb6a Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 24 Jan 2023 23:10:21 +0100 Subject: [PATCH 48/80] Bump parity-db (#13226) --- Cargo.lock | 4 ++-- bin/node/bench/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d34dd81e1..53e5d4882b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6689,9 +6689,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a7511a0bec4a336b5929999d02b560d2439c993cccf98c26481484e811adc43" +checksum = "dd684a725651d9588ef21f140a328b6b4f64e646b2e931f3e6f14f75eedf9980" dependencies = [ "blake2", "crc32fast", diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index 9732faf6e1..0097b51ab0 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -38,7 +38,7 @@ tempfile = "3.1.0" fs_extra = "1" rand = { version = "0.8.5", features = ["small_rng"] } lazy_static = "1.4.0" -parity-db = "0.4.2" +parity-db = "0.4.3" sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" } sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" } futures = { version = "0.3.21", features = ["thread-pool"] } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 028af5d6e4..a9f5e28c73 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -22,7 +22,7 @@ kvdb-memorydb = "0.13.0" kvdb-rocksdb = { version = "0.17.0", optional = true } linked-hash-map = "0.5.4" log = "0.4.17" -parity-db = "0.4.2" +parity-db = "0.4.3" parking_lot = "0.12.1" sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-state-db = { version = "0.10.0-dev", path = "../state-db" } From 1314eeca18c2b1a3094a6d8fca378da1b0c386a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 25 Jan 2023 12:57:01 +0100 Subject: [PATCH 49/80] pallet-assets: Rename `total_supply` to `amount` (#13229) * pallet-assets: Rename `total_supply` to `amount` We are actually passing the `amount` on assets being minted and not the total supply. Closes: https://github.com/paritytech/substrate/issues/13210 * ".git/.scripts/commands/fmt/fmt.sh" * Fix compilation * FMT Co-authored-by: command-bot <> --- frame/assets/src/benchmarking.rs | 2 +- frame/assets/src/functions.rs | 15 ++++++--------- frame/assets/src/lib.rs | 8 +++----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index ede5b4e77f..235d1d9374 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -220,7 +220,7 @@ benchmarks_instance_pallet! { let amount = T::Balance::from(100u32); }: _(SystemOrigin::Signed(caller.clone()), asset_id, caller_lookup, amount) verify { - assert_last_event::(Event::Issued { asset_id: asset_id.into(), owner: caller, total_supply: amount }.into()); + assert_last_event::(Event::Issued { asset_id: asset_id.into(), owner: caller, amount }.into()); } burn { diff --git a/frame/assets/src/functions.rs b/frame/assets/src/functions.rs index 2cdf2d7c4c..b540f02b87 100644 --- a/frame/assets/src/functions.rs +++ b/frame/assets/src/functions.rs @@ -354,18 +354,15 @@ impl, I: 'static> Pallet { if let Some(check_issuer) = maybe_check_issuer { ensure!(check_issuer == details.issuer, Error::::NoPermission); } - debug_assert!( - T::Balance::max_value() - details.supply >= amount, - "checked in prep; qed" - ); + debug_assert!(details.supply.checked_add(&amount).is_some(), "checked in prep; qed"); + details.supply = details.supply.saturating_add(amount); + Ok(()) })?; - Self::deposit_event(Event::Issued { - asset_id: id, - owner: beneficiary.clone(), - total_supply: amount, - }); + + Self::deposit_event(Event::Issued { asset_id: id, owner: beneficiary.clone(), amount }); + Ok(()) } diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 93e416c3be..c2480a2063 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -151,9 +151,7 @@ pub use types::*; use scale_info::TypeInfo; use sp_runtime::{ - traits::{ - AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero, - }, + traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero}, ArithmeticError, TokenError, }; use sp_std::{borrow::Borrow, prelude::*}; @@ -427,7 +425,7 @@ pub mod pallet { *amount, |details| -> DispatchResult { debug_assert!( - T::Balance::max_value() - details.supply >= *amount, + details.supply.checked_add(&amount).is_some(), "checked in prep; qed" ); details.supply = details.supply.saturating_add(*amount); @@ -445,7 +443,7 @@ pub mod pallet { /// Some asset class was created. Created { asset_id: T::AssetId, creator: T::AccountId, owner: T::AccountId }, /// Some assets were issued. - Issued { asset_id: T::AssetId, owner: T::AccountId, total_supply: T::Balance }, + Issued { asset_id: T::AssetId, owner: T::AccountId, amount: T::Balance }, /// Some assets were transferred. Transferred { asset_id: T::AssetId, From e3938747cdc201a6c3fbf920d0e983e2b7be01c7 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Wed, 25 Jan 2023 12:57:59 +0100 Subject: [PATCH 50/80] Babe: bad epoch index with skipped epochs and warp sync (#13135) * Detect and correct epoch-index for skipped epochs * Code refactory * Epoch index should be also be fixed for secondary claims with VRF * Fix typo * Make clippy happy * Fix typo * Trigger pipeline --- client/consensus/babe/src/authorship.rs | 21 +++- client/consensus/babe/src/lib.rs | 75 +++++++----- client/consensus/babe/src/tests.rs | 141 +++++++++++++++++----- client/consensus/babe/src/verification.rs | 17 ++- 4 files changed, 187 insertions(+), 67 deletions(-) diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs index b39153faa6..3a92aa5c6b 100644 --- a/client/consensus/babe/src/authorship.rs +++ b/client/consensus/babe/src/authorship.rs @@ -20,6 +20,7 @@ use super::Epoch; use codec::Encode; +use sc_consensus_epochs::Epoch as EpochT; use schnorrkel::{keys::PublicKey, vrf::VRFInOut}; use sp_application_crypto::AppKey; use sp_consensus_babe::{ @@ -135,18 +136,23 @@ fn claim_secondary_slot( keystore: &SyncCryptoStorePtr, author_secondary_vrf: bool, ) -> Option<(PreDigest, AuthorityId)> { - let Epoch { authorities, randomness, epoch_index, .. } = epoch; + let Epoch { authorities, randomness, mut epoch_index, .. } = epoch; if authorities.is_empty() { return None } + if epoch.end_slot() <= slot { + // Slot doesn't strictly belong to the epoch, create a clone with fixed values. + epoch_index = epoch.clone_for_slot(slot).epoch_index; + } + let expected_author = secondary_slot_author(slot, authorities, *randomness)?; for (authority_id, authority_index) in keys { if authority_id == expected_author { let pre_digest = if author_secondary_vrf { - let transcript_data = make_transcript_data(randomness, slot, *epoch_index); + let transcript_data = make_transcript_data(randomness, slot, epoch_index); let result = SyncCryptoStore::sr25519_vrf_sign( &**keystore, AuthorityId::ID, @@ -238,11 +244,16 @@ fn claim_primary_slot( keystore: &SyncCryptoStorePtr, keys: &[(AuthorityId, usize)], ) -> Option<(PreDigest, AuthorityId)> { - let Epoch { authorities, randomness, epoch_index, .. } = epoch; + let Epoch { authorities, randomness, mut epoch_index, .. } = epoch; + + if epoch.end_slot() <= slot { + // Slot doesn't strictly belong to the epoch, create a clone with fixed values. + epoch_index = epoch.clone_for_slot(slot).epoch_index; + } for (authority_id, authority_index) in keys { - let transcript = make_transcript(randomness, slot, *epoch_index); - let transcript_data = make_transcript_data(randomness, slot, *epoch_index); + let transcript = make_transcript(randomness, slot, epoch_index); + let transcript_data = make_transcript_data(randomness, slot, epoch_index); let result = SyncCryptoStore::sr25519_vrf_sign( &**keystore, AuthorityId::ID, diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index c9e171dbed..5ba523665b 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -209,8 +209,9 @@ impl From for Epoch { } impl Epoch { - /// Create the genesis epoch (epoch #0). This is defined to start at the slot of - /// the first block, so that has to be provided. + /// Create the genesis epoch (epoch #0). + /// + /// This is defined to start at the slot of the first block, so that has to be provided. pub fn genesis(genesis_config: &BabeConfiguration, slot: Slot) -> Epoch { Epoch { epoch_index: 0, @@ -224,6 +225,38 @@ impl Epoch { }, } } + + /// Clone and tweak epoch information to refer to the specified slot. + /// + /// All the information which depends on the slot value is recomputed and assigned + /// to the returned epoch instance. + /// + /// The `slot` must be greater than or equal the original epoch start slot, + /// if is less this operation is equivalent to a simple clone. + pub fn clone_for_slot(&self, slot: Slot) -> Epoch { + let mut epoch = self.clone(); + + let skipped_epochs = *slot.saturating_sub(self.start_slot) / self.duration; + + let epoch_index = epoch.epoch_index.checked_add(skipped_epochs).expect( + "epoch number is u64; it should be strictly smaller than number of slots; \ + slots relate in some way to wall clock time; \ + if u64 is not enough we should crash for safety; qed.", + ); + + let start_slot = skipped_epochs + .checked_mul(epoch.duration) + .and_then(|skipped_slots| epoch.start_slot.checked_add(skipped_slots)) + .expect( + "slot number is u64; it should relate in some way to wall clock time; \ + if u64 is not enough we should crash for safety; qed.", + ); + + epoch.epoch_index = epoch_index; + epoch.start_slot = Slot::from(start_slot); + + epoch + } } /// Errors encountered by the babe authorship task. @@ -1540,45 +1573,27 @@ where }; if viable_epoch.as_ref().end_slot() <= slot { - // some epochs must have been skipped as our current slot - // fits outside the current epoch. we will figure out - // which epoch it belongs to and we will re-use the same - // data for that epoch - let mut epoch_data = viable_epoch.as_mut(); - let skipped_epochs = - *slot.saturating_sub(epoch_data.start_slot) / epoch_data.duration; - - // NOTE: notice that we are only updating a local copy of the `Epoch`, this + // Some epochs must have been skipped as our current slot fits outside the + // current epoch. We will figure out which epoch it belongs to and we will + // re-use the same data for that epoch. + // Notice that we are only updating a local copy of the `Epoch`, this // makes it so that when we insert the next epoch into `EpochChanges` below // (after incrementing it), it will use the correct epoch index and start slot. - // we do not update the original epoch that will be re-used because there might + // We do not update the original epoch that will be re-used because there might // be other forks (that we haven't imported) where the epoch isn't skipped, and - // to import those forks we want to keep the original epoch data. not updating + // to import those forks we want to keep the original epoch data. Not updating // the original epoch works because when we search the tree for which epoch to // use for a given slot, we will search in-depth with the predicate // `epoch.start_slot <= slot` which will still match correctly without updating // `start_slot` to the correct value as below. - let epoch_index = epoch_data.epoch_index.checked_add(skipped_epochs).expect( - "epoch number is u64; it should be strictly smaller than number of slots; \ - slots relate in some way to wall clock time; \ - if u64 is not enough we should crash for safety; qed.", - ); - - let start_slot = skipped_epochs - .checked_mul(epoch_data.duration) - .and_then(|skipped_slots| epoch_data.start_slot.checked_add(skipped_slots)) - .expect( - "slot number is u64; it should relate in some way to wall clock time; \ - if u64 is not enough we should crash for safety; qed.", - ); + let epoch = viable_epoch.as_mut(); + let prev_index = epoch.epoch_index; + *epoch = epoch.clone_for_slot(slot); warn!( target: LOG_TARGET, - "👶 Epoch(s) skipped: from {} to {}", epoch_data.epoch_index, epoch_index, + "👶 Epoch(s) skipped: from {} to {}", prev_index, epoch.epoch_index, ); - - epoch_data.epoch_index = epoch_index; - epoch_data.start_slot = Slot::from(start_slot); } log!( diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 304bc9fc22..0dd0b59dd6 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -20,7 +20,6 @@ use super::*; use authorship::claim_slot; -use log::debug; use rand_chacha::{ rand_core::{RngCore, SeedableRng}, ChaChaRng, @@ -35,9 +34,10 @@ use sp_application_crypto::key_types::BABE; use sp_consensus::{DisableProofRecording, NoNetwork as DummyOracle, Proposal}; use sp_consensus_babe::{ inherents::InherentDataProvider, make_transcript, make_transcript_data, AllowedSlots, - AuthorityPair, Slot, + AuthorityId, AuthorityPair, Slot, }; use sp_consensus_slots::SlotDuration; +use sp_consensus_vrf::schnorrkel::VRFOutput; use sp_core::crypto::Pair; use sp_keyring::Sr25519Keyring; use sp_keystore::{ @@ -553,52 +553,133 @@ fn sig_is_not_pre_digest() { } #[test] -fn can_author_block() { - sp_tracing::try_init_simple(); +fn claim_epoch_slots() { + // We don't require the full claim information, thus as a shorter alias we're + // going to use a simple integer value. Generally not verbose enough, but good enough + // to be used within the narrow scope of a single test. + // 0 -> None (i.e. unable to claim the slot), + // 1 -> Primary + // 2 -> Secondary + // 3 -> Secondary with VRF + const EPOCH_DURATION: u64 = 10; let authority = Sr25519Keyring::Alice; let keystore = create_keystore(authority); - let mut i = 0; - let epoch = Epoch { + let mut epoch = Epoch { start_slot: 0.into(), authorities: vec![(authority.public().into(), 1)], randomness: [0; 32], epoch_index: 1, - duration: 100, + duration: EPOCH_DURATION, config: BabeEpochConfiguration { c: (3, 10), allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots, }, }; - let mut config = crate::BabeConfiguration { - slot_duration: 1000, - epoch_length: 100, - c: (3, 10), - authorities: Vec::new(), + let claim_slot_wrap = |s, e| match claim_slot(Slot::from(s as u64), &e, &keystore) { + None => 0, + Some((PreDigest::Primary(_), _)) => 1, + Some((PreDigest::SecondaryPlain(_), _)) => 2, + Some((PreDigest::SecondaryVRF(_), _)) => 3, + }; + + // With secondary mechanism we should be able to claim all slots. + let claims: Vec<_> = (0..EPOCH_DURATION) + .into_iter() + .map(|slot| claim_slot_wrap(slot, epoch.clone())) + .collect(); + assert_eq!(claims, [1, 2, 2, 1, 2, 2, 2, 2, 2, 1]); + + // With secondary with VRF mechanism we should be able to claim all the slots. + epoch.config.allowed_slots = AllowedSlots::PrimaryAndSecondaryVRFSlots; + let claims: Vec<_> = (0..EPOCH_DURATION) + .into_iter() + .map(|slot| claim_slot_wrap(slot, epoch.clone())) + .collect(); + assert_eq!(claims, [1, 3, 3, 1, 3, 3, 3, 3, 3, 1]); + + // Otherwise with only vrf-based primary slots we are able to claim a subset of the slots. + epoch.config.allowed_slots = AllowedSlots::PrimarySlots; + let claims: Vec<_> = (0..EPOCH_DURATION) + .into_iter() + .map(|slot| claim_slot_wrap(slot, epoch.clone())) + .collect(); + assert_eq!(claims, [1, 0, 0, 1, 0, 0, 0, 0, 0, 1]); +} + +#[test] +fn claim_vrf_check() { + let authority = Sr25519Keyring::Alice; + let keystore = create_keystore(authority); + + let public = authority.public(); + + let epoch = Epoch { + start_slot: 0.into(), + authorities: vec![(public.into(), 1)], randomness: [0; 32], - allowed_slots: AllowedSlots::PrimaryAndSecondaryPlainSlots, + epoch_index: 1, + duration: 10, + config: BabeEpochConfiguration { + c: (3, 10), + allowed_slots: AllowedSlots::PrimaryAndSecondaryVRFSlots, + }, }; - // with secondary slots enabled it should never be empty - match claim_slot(i.into(), &epoch, &keystore) { - None => i += 1, - Some(s) => debug!(target: LOG_TARGET, "Authored block {:?}", s.0), - } + // We leverage the predictability of claim types given a constant randomness. - // otherwise with only vrf-based primary slots we might need to try a couple - // of times. - config.allowed_slots = AllowedSlots::PrimarySlots; - loop { - match claim_slot(i.into(), &epoch, &keystore) { - None => i += 1, - Some(s) => { - debug!(target: LOG_TARGET, "Authored block {:?}", s.0); - break - }, - } - } + // We expect a Primary claim for slot 0 + + let pre_digest = match claim_slot(0.into(), &epoch, &keystore).unwrap().0 { + PreDigest::Primary(d) => d, + v => panic!("Unexpected pre-digest variant {:?}", v), + }; + let transcript = make_transcript_data(&epoch.randomness.clone(), 0.into(), epoch.epoch_index); + let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + .unwrap() + .unwrap(); + assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); + + // We expect a SecondaryVRF claim for slot 1 + let pre_digest = match claim_slot(1.into(), &epoch, &keystore).unwrap().0 { + PreDigest::SecondaryVRF(d) => d, + v => panic!("Unexpected pre-digest variant {:?}", v), + }; + let transcript = make_transcript_data(&epoch.randomness.clone(), 1.into(), epoch.epoch_index); + let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + .unwrap() + .unwrap(); + assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); + + // Check that correct epoch index has been used if epochs are skipped (primary VRF) + let slot = Slot::from(103); + let claim = match claim_slot(slot, &epoch, &keystore).unwrap().0 { + PreDigest::Primary(d) => d, + v => panic!("Unexpected claim variant {:?}", v), + }; + let fixed_epoch = epoch.clone_for_slot(slot); + let transcript = make_transcript_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); + let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + .unwrap() + .unwrap(); + assert_eq!(fixed_epoch.epoch_index, 11); + assert_eq!(claim.vrf_output, VRFOutput(sign.output)); + + // Check that correct epoch index has been used if epochs are skipped (secondary VRF) + let slot = Slot::from(100); + let pre_digest = match claim_slot(slot, &epoch, &keystore).unwrap().0 { + PreDigest::SecondaryVRF(d) => d, + v => panic!("Unexpected claim variant {:?}", v), + }; + let fixed_epoch = epoch.clone_for_slot(slot); + let transcript = make_transcript_data(&epoch.randomness.clone(), slot, fixed_epoch.epoch_index); + let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) + .unwrap() + .unwrap(); + assert_eq!(fixed_epoch.epoch_index, 11); + assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); } // Propose and import a new BABE block on top of the given parent. diff --git a/client/consensus/babe/src/verification.rs b/client/consensus/babe/src/verification.rs index e77a70c8e4..8e8f5d998f 100644 --- a/client/consensus/babe/src/verification.rs +++ b/client/consensus/babe/src/verification.rs @@ -22,6 +22,7 @@ use crate::{ babe_err, find_pre_digest, BlockT, Epoch, Error, LOG_TARGET, }; use log::{debug, trace}; +use sc_consensus_epochs::Epoch as EpochT; use sc_consensus_slots::CheckedHeader; use sp_consensus_babe::{ digests::{ @@ -155,10 +156,16 @@ fn check_primary_header( c: (u64, u64), ) -> Result<(), Error> { let author = &epoch.authorities[pre_digest.authority_index as usize].0; + let mut epoch_index = epoch.epoch_index; + + if epoch.end_slot() <= pre_digest.slot { + // Slot doesn't strictly belong to this epoch, create a clone with fixed values. + epoch_index = epoch.clone_for_slot(pre_digest.slot).epoch_index; + } if AuthorityPair::verify(&signature, pre_hash, author) { let (inout, _) = { - let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch.epoch_index); + let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch_index); schnorrkel::PublicKey::from_bytes(author.as_slice()) .and_then(|p| { @@ -228,8 +235,14 @@ fn check_secondary_vrf_header( return Err(Error::InvalidAuthor(expected_author.clone(), author.clone())) } + let mut epoch_index = epoch.epoch_index; + if epoch.end_slot() <= pre_digest.slot { + // Slot doesn't strictly belong to this epoch, create a clone with fixed values. + epoch_index = epoch.clone_for_slot(pre_digest.slot).epoch_index; + } + if AuthorityPair::verify(&signature, pre_hash.as_ref(), author) { - let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch.epoch_index); + let transcript = make_transcript(&epoch.randomness, pre_digest.slot, epoch_index); schnorrkel::PublicKey::from_bytes(author.as_slice()) .and_then(|p| p.vrf_verify(transcript, &pre_digest.vrf_output, &pre_digest.vrf_proof)) From 1a1600b827020cae62c9b856cb9ba4b823ab080a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Thei=C3=9Fen?= Date: Wed, 25 Jan 2023 10:48:40 -0300 Subject: [PATCH 51/80] contracts: Deprecate random interface (#13204) * Deprecate random interface * Revert change to runtime file * Fix docs * Fix tests * Rename to not_deprecated * Apply suggestions from code review Co-authored-by: Sasha Gryaznov * Deprecate `set_rent_allowance` Co-authored-by: Sasha Gryaznov --- frame/contracts/proc-macro/src/lib.rs | 55 ++++- frame/contracts/src/benchmarking/sandbox.rs | 13 +- frame/contracts/src/exec.rs | 31 +++ frame/contracts/src/lib.rs | 9 +- frame/contracts/src/wasm/mod.rs | 217 +++++++++++++++++--- frame/contracts/src/wasm/prepare.rs | 72 +++++-- frame/contracts/src/wasm/runtime.rs | 132 ++++++------ 7 files changed, 416 insertions(+), 113 deletions(-) diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index d0247d720a..eaf437c150 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -162,6 +162,8 @@ struct HostFn { returns: HostFnReturn, is_stable: bool, alias_to: Option, + /// Formulating the predicate inverted makes the expression using it simpler. + not_deprecated: bool, } enum HostFnReturn { @@ -199,13 +201,14 @@ impl HostFn { // process attributes let msg = - "only #[version()], #[unstable] and #[prefixed_alias] attributes are allowed."; + "only #[version()], #[unstable], #[prefixed_alias] and #[deprecated] attributes are allowed."; let span = item.span(); let mut attrs = item.attrs.clone(); attrs.retain(|a| !a.path.is_ident("doc")); let mut maybe_module = None; let mut is_stable = true; let mut alias_to = None; + let mut not_deprecated = true; while let Some(attr) = attrs.pop() { let ident = attr.path.get_ident().ok_or(err(span, msg))?.to_string(); match ident.as_str() { @@ -230,12 +233,22 @@ impl HostFn { item.sig.ident.span(), ); }, + "deprecated" => { + if !not_deprecated { + return Err(err(span, "#[deprecated] can only be specified once")) + } + not_deprecated = false; + }, _ => return Err(err(span, msg)), } } let name = item.sig.ident.to_string(); - // process arguments: The first and second arg are treated differently (ctx, memory) + if !(is_stable || not_deprecated) { + return Err(err(span, "#[deprecated] is mutually exclusive with #[unstable]")) + } + + // process arguments: The first and second args are treated differently (ctx, memory) // they must exist and be `ctx: _` and `memory: _`. let msg = "Every function must start with two inferred parameters: ctx: _ and memory: _"; let special_args = item @@ -330,6 +343,7 @@ impl HostFn { returns, is_stable, alias_to, + not_deprecated, }) }, _ => Err(err(span, &msg)), @@ -510,7 +524,12 @@ fn expand_impls(def: &mut EnvDef) -> TokenStream2 { quote! { impl<'a, E: Ext> crate::wasm::Environment> for Env { - fn define(store: &mut ::wasmi::Store>, linker: &mut ::wasmi::Linker>, allow_unstable: bool) -> Result<(), ::wasmi::errors::LinkerError> { + fn define( + store: &mut ::wasmi::Store>, + linker: &mut ::wasmi::Linker>, + allow_unstable: AllowUnstableInterface, + allow_deprecated: AllowDeprecatedInterface, + ) -> Result<(),::wasmi::errors::LinkerError> { #impls Ok(()) } @@ -518,7 +537,12 @@ fn expand_impls(def: &mut EnvDef) -> TokenStream2 { impl crate::wasm::Environment<()> for Env { - fn define(store: &mut ::wasmi::Store<()>, linker: &mut ::wasmi::Linker<()>, allow_unstable: bool) -> Result<(), ::wasmi::errors::LinkerError> { + fn define( + store: &mut ::wasmi::Store<()>, + linker: &mut ::wasmi::Linker<()>, + allow_unstable: AllowUnstableInterface, + allow_deprecated: AllowDeprecatedInterface, + ) -> Result<(), ::wasmi::errors::LinkerError> { #dummy_impls Ok(()) } @@ -542,6 +566,7 @@ fn expand_functions( &f.item.sig.output ); let is_stable = f.is_stable; + let not_deprecated = f.not_deprecated; // If we don't expand blocks (implementing for `()`) we change a few things: // - We replace any code by unreachable! @@ -582,9 +607,13 @@ fn expand_functions( }; quote! { - // We need to allow unstable functions when runtime benchmarks are performed because - // we generate the weights even when those interfaces are not enabled. - if ::core::cfg!(feature = "runtime-benchmarks") || #is_stable || allow_unstable { + // We need to allow all interfaces when runtime benchmarks are performed because + // we generate the weights even when those interfaces are not enabled. This + // is necessary as the decision whether we allow unstable or deprecated functions + // is a decision made at runtime. Generation of the weights happens statically. + if ::core::cfg!(feature = "runtime-benchmarks") || + ((#is_stable || __allow_unstable__) && (#not_deprecated || __allow_deprecated__)) + { #allow_unused linker.define(#module, #name, ::wasmi::Func::wrap(&mut*store, |mut __caller__: ::wasmi::Caller<#host_state>, #( #params, )*| -> #wasm_output { let mut func = #inner; @@ -596,6 +625,8 @@ fn expand_functions( } }); quote! { + let __allow_unstable__ = matches!(allow_unstable, AllowUnstableInterface::Yes); + let __allow_deprecated__ = matches!(allow_deprecated, AllowDeprecatedInterface::Yes); #( #impls )* } } @@ -691,6 +722,16 @@ fn expand_functions( /// `...` modules each having its `Api` trait containing functions holding documentation for every /// host function defined by the macro. /// +/// # Deprecated Interfaces +/// +/// An interface can be annotated with `#[deprecated]`. It is mutually exclusive with `#[unstable]`. +/// Deprecated interfaces have the following properties: +/// - New contract codes utilizing those interfaces cannot be uploaded. +/// - New contracts from existing codes utilizing those interfaces cannot be instantiated. +/// - Existing contracts containing those interfaces still work. +/// +/// Those interfaces will eventually be removed. +/// /// To build up these docs, run: /// /// ```nocompile diff --git a/frame/contracts/src/benchmarking/sandbox.rs b/frame/contracts/src/benchmarking/sandbox.rs index 5d080bad92..a6a97d11ac 100644 --- a/frame/contracts/src/benchmarking/sandbox.rs +++ b/frame/contracts/src/benchmarking/sandbox.rs @@ -19,7 +19,9 @@ /// ! sandbox to execute the wasm code. This is because we do not need the full /// ! environment that provides the seal interface as imported functions. use super::{code::WasmModule, Config}; -use crate::wasm::{Environment, PrefabWasmModule}; +use crate::wasm::{ + AllowDeprecatedInterface, AllowUnstableInterface, Environment, PrefabWasmModule, +}; use wasmi::{errors::LinkerError, Func, Linker, StackLimits, Store}; /// Minimal execution environment without any imported functions. @@ -49,6 +51,8 @@ impl From<&WasmModule> for Sandbox { (), memory, StackLimits::default(), + // We are testing with an empty environment anyways + AllowDeprecatedInterface::No, ) .expect("Failed to create benchmarking Sandbox instance"); let entry_point = instance.get_export(&store, "call").unwrap().into_func().unwrap(); @@ -59,7 +63,12 @@ impl From<&WasmModule> for Sandbox { struct EmptyEnv; impl Environment<()> for EmptyEnv { - fn define(_: &mut Store<()>, _: &mut Linker<()>, _: bool) -> Result<(), LinkerError> { + fn define( + _: &mut Store<()>, + _: &mut Linker<()>, + _: AllowUnstableInterface, + _: AllowDeprecatedInterface, + ) -> Result<(), LinkerError> { Ok(()) } } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index b5b6306536..7a07b01d27 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -3440,4 +3440,35 @@ mod tests { )); }); } + + /// This works even though random interface is deprecated, as the check to ban deprecated + /// functions happens in the wasm stack which is mocked for exec tests. + #[test] + fn randomness_works() { + let subject = b"nice subject".as_ref(); + let code_hash = MockLoader::insert(Call, move |ctx, _| { + let rand = ::Randomness::random(subject); + assert_eq!(rand, ctx.ext.random(subject)); + exec_success() + }); + + ExtBuilder::default().build().execute_with(|| { + let schedule = ::Schedule::get(); + place_contract(&BOB, code_hash); + + let mut storage_meter = storage::meter::Meter::new(&ALICE, Some(0), 0).unwrap(); + let result = MockStack::run_call( + ALICE, + BOB, + &mut GasMeter::::new(GAS_LIMIT), + &mut storage_meter, + &schedule, + 0, + vec![], + None, + Determinism::Deterministic, + ); + assert_matches!(result, Ok(_)); + }); + } } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 672c4517d0..84a72b7016 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -216,7 +216,14 @@ pub mod pallet { /// The time implementation used to supply timestamps to contracts through `seal_now`. type Time: Time; - /// The generator used to supply randomness to contracts through `seal_random` + /// The generator used to supply randomness to contracts through `seal_random`. + /// + /// # Deprecated + /// + /// Codes using the randomness functionality cannot be uploaded. Neither can contracts + /// be instantiated from existing codes that use this deprecated functionality. It will + /// be removed eventually. Hence for new `pallet-contracts` deployments it is okay + /// to supply a dummy implementation for this type (because it is never used). type Randomness: Randomness; /// The currency in which fees are paid and contract balances are held. diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index c2b0611769..6b9cefcdd2 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -24,14 +24,16 @@ mod runtime; #[cfg(feature = "runtime-benchmarks")] pub use crate::wasm::code_cache::reinstrument; +#[cfg(doc)] +pub use crate::wasm::runtime::api_doc; pub use crate::wasm::{ prepare::TryInstantiate, - runtime::{CallFlags, Environment, ReturnCode, Runtime, RuntimeCosts}, + runtime::{ + AllowDeprecatedInterface, AllowUnstableInterface, CallFlags, Environment, ReturnCode, + Runtime, RuntimeCosts, + }, }; -#[cfg(doc)] -pub use crate::wasm::runtime::api_doc; - use crate::{ exec::{ExecResult, Executable, ExportedFunction, Ext}, gas::GasMeter, @@ -205,6 +207,7 @@ impl PrefabWasmModule { host_state: H, memory: (u32, u32), stack_limits: StackLimits, + allow_deprecated: AllowDeprecatedInterface, ) -> Result<(Store, Memory, Instance), wasmi::Error> where E: Environment, @@ -220,7 +223,16 @@ impl PrefabWasmModule { let module = Module::new(&engine, code)?; let mut store = Store::new(&engine, host_state); let mut linker = Linker::new(); - E::define(&mut store, &mut linker, T::UnsafeUnstableInterface::get())?; + E::define( + &mut store, + &mut linker, + if T::UnsafeUnstableInterface::get() { + AllowUnstableInterface::Yes + } else { + AllowUnstableInterface::No + }, + allow_deprecated, + )?; let memory = Memory::new(&mut store, MemoryType::new(memory.0, Some(memory.1))?).expect( "The limits defined in our `Schedule` limit the amount of memory well below u32::MAX; qed", ); @@ -233,20 +245,14 @@ impl PrefabWasmModule { Ok((store, memory, instance)) } - /// Create and store the module without checking nor instrumenting the passed code. - /// - /// # Note - /// - /// This is useful for benchmarking where we don't want instrumentation to skew - /// our results. This also does not collect any deposit from the `owner`. + /// See [`Self::from_code_unchecked`]. #[cfg(feature = "runtime-benchmarks")] pub fn store_code_unchecked( original_code: Vec, schedule: &Schedule, owner: T::AccountId, ) -> DispatchResult { - let executable = prepare::benchmarking::prepare(original_code, schedule, owner) - .map_err::(Into::into)?; + let executable = Self::from_code_unchecked(original_code, schedule, owner)?; code_cache::store(executable, false) } @@ -255,6 +261,23 @@ impl PrefabWasmModule { pub fn decrement_version(&mut self) { self.instruction_weights_version = self.instruction_weights_version.checked_sub(1).unwrap(); } + + /// Create the module without checking nor instrumenting the passed code. + /// + /// # Note + /// + /// This is useful for benchmarking where we don't want instrumentation to skew + /// our results. This also does not collect any deposit from the `owner`. Also useful + /// during testing when we want to deploy codes that do not pass the instantiation checks. + #[cfg(any(test, feature = "runtime-benchmarks"))] + fn from_code_unchecked( + original_code: Vec, + schedule: &Schedule, + owner: T::AccountId, + ) -> Result { + prepare::benchmarking::prepare(original_code, schedule, owner) + .map_err::(Into::into) + } } impl OwnerInfo { @@ -294,6 +317,10 @@ impl Executable for PrefabWasmModule { runtime, (self.initial, self.maximum), StackLimits::default(), + match function { + ExportedFunction::Constructor => AllowDeprecatedInterface::No, + ExportedFunction::Call => AllowDeprecatedInterface::Yes, + }, ) .map_err(|msg| { log::debug!(target: "runtime::contracts", "failed to instantiate code: {}", msg); @@ -629,38 +656,77 @@ mod tests { } } + /// Execute the supplied code. + /// + /// Not used directly but through the wrapper functions defined below. fn execute_internal>( wat: &str, input_data: Vec, mut ext: E, + entry_point: &ExportedFunction, unstable_interface: bool, + skip_checks: bool, ) -> ExecResult { type RuntimeConfig = ::T; RuntimeConfig::set_unstable_interface(unstable_interface); let wasm = wat::parse_str(wat).unwrap(); let schedule = crate::Schedule::default(); - let executable = PrefabWasmModule::::from_code( - wasm, - &schedule, - ALICE, - Determinism::Deterministic, - TryInstantiate::Skip, - ) - .map_err(|err| err.0)?; - executable.execute(ext.borrow_mut(), &ExportedFunction::Call, input_data) + let executable = if skip_checks { + PrefabWasmModule::::from_code_unchecked(wasm, &schedule, ALICE)? + } else { + PrefabWasmModule::::from_code( + wasm, + &schedule, + ALICE, + Determinism::Deterministic, + TryInstantiate::Instantiate, + ) + .map_err(|err| err.0)? + }; + executable.execute(ext.borrow_mut(), entry_point, input_data) } + /// Execute the suppplied code. fn execute>(wat: &str, input_data: Vec, ext: E) -> ExecResult { - execute_internal(wat, input_data, ext, true) + execute_internal(wat, input_data, ext, &ExportedFunction::Call, true, false) } + /// Execute the supplied code with disabled unstable functions. + /// + /// In our test config unstable functions are disabled so that we can test them. + /// In order to test that code using them is properly rejected we temporarily disable + /// them when this test is run. #[cfg(not(feature = "runtime-benchmarks"))] fn execute_no_unstable>( wat: &str, input_data: Vec, ext: E, ) -> ExecResult { - execute_internal(wat, input_data, ext, false) + execute_internal(wat, input_data, ext, &ExportedFunction::Call, false, false) + } + + /// Execute code without validating it first. + /// + /// This is mainly useful in order to test code which uses deprecated functions. Those + /// would fail when validating the code. + fn execute_unvalidated>( + wat: &str, + input_data: Vec, + ext: E, + ) -> ExecResult { + execute_internal(wat, input_data, ext, &ExportedFunction::Call, false, true) + } + + /// Execute instantiation entry point of code without validating it first. + /// + /// Same as `execute_unvalidated` except that the `deploy` entry point is ran. + #[cfg(not(feature = "runtime-benchmarks"))] + fn execute_instantiate_unvalidated>( + wat: &str, + input_data: Vec, + ext: E, + ) -> ExecResult { + execute_internal(wat, input_data, ext, &ExportedFunction::Constructor, false, true) } const CODE_TRANSFER: &str = r#" @@ -1861,7 +1927,7 @@ mod tests { #[test] fn random() { - let output = execute(CODE_RANDOM, vec![], MockExt::default()).unwrap(); + let output = execute_unvalidated(CODE_RANDOM, vec![], MockExt::default()).unwrap(); // The mock ext just returns the same data that was passed as the subject. assert_eq!( @@ -1931,7 +1997,7 @@ mod tests { #[test] fn random_v1() { - let output = execute(CODE_RANDOM_V1, vec![], MockExt::default()).unwrap(); + let output = execute_unvalidated(CODE_RANDOM_V1, vec![], MockExt::default()).unwrap(); // The mock ext just returns the same data that was passed as the subject. assert_eq!( @@ -3007,6 +3073,29 @@ mod tests { execute(CODE, vec![], &mut mock_ext).unwrap(); } + /// Code with deprecated functions cannot be uploaded or instantiated. However, we + /// need to make sure that it still can be re-instrumented. + #[test] + fn can_reinstrument_deprecated() { + const CODE_RANDOM: &str = r#" +(module + (import "seal0" "random" (func $seal_random (param i32 i32 i32 i32))) + (func (export "call")) + (func (export "deploy")) +) + "#; + let wasm = wat::parse_str(CODE_RANDOM).unwrap(); + let schedule = crate::Schedule::::default(); + #[cfg(not(feature = "runtime-benchmarks"))] + assert_err!(execute(CODE_RANDOM, vec![], MockExt::default()), >::CodeRejected); + self::prepare::reinstrument::( + &wasm, + &schedule, + Determinism::Deterministic, + ) + .unwrap(); + } + /// This test check that an unstable interface cannot be deployed. In case of runtime /// benchmarks we always allow unstable interfaces. This is why this test does not /// work when this feature is enabled. @@ -3026,4 +3115,80 @@ mod tests { ); assert_ok!(execute(CANNOT_DEPLOY_UNSTABLE, vec![], MockExt::default())); } + + /// The random interface is deprecated and hence new contracts using it should not be deployed. + /// In case of runtime benchmarks we always allow deprecated interfaces. This is why this + /// test doesn't work if this feature is enabled. + #[cfg(not(feature = "runtime-benchmarks"))] + #[test] + fn cannot_deploy_deprecated() { + const CODE_RANDOM_0: &str = r#" +(module + (import "seal0" "seal_random" (func $seal_random (param i32 i32 i32 i32))) + (func (export "call")) + (func (export "deploy")) +) + "#; + const CODE_RANDOM_1: &str = r#" +(module + (import "seal1" "seal_random" (func $seal_random (param i32 i32 i32 i32))) + (func (export "call")) + (func (export "deploy")) +) + "#; + const CODE_RANDOM_2: &str = r#" +(module + (import "seal0" "random" (func $seal_random (param i32 i32 i32 i32))) + (func (export "call")) + (func (export "deploy")) +) + "#; + const CODE_RANDOM_3: &str = r#" +(module + (import "seal1" "random" (func $seal_random (param i32 i32 i32 i32))) + (func (export "call")) + (func (export "deploy")) +) + "#; + + assert_ok!(execute_unvalidated(CODE_RANDOM_0, vec![], MockExt::default())); + assert_err!( + execute_instantiate_unvalidated(CODE_RANDOM_0, vec![], MockExt::default()), + >::CodeRejected, + ); + assert_err!( + execute(CODE_RANDOM_0, vec![], MockExt::default()), + >::CodeRejected, + ); + + assert_ok!(execute_unvalidated(CODE_RANDOM_1, vec![], MockExt::default())); + assert_err!( + execute_instantiate_unvalidated(CODE_RANDOM_1, vec![], MockExt::default()), + >::CodeRejected, + ); + assert_err!( + execute(CODE_RANDOM_1, vec![], MockExt::default()), + >::CodeRejected, + ); + + assert_ok!(execute_unvalidated(CODE_RANDOM_2, vec![], MockExt::default())); + assert_err!( + execute_instantiate_unvalidated(CODE_RANDOM_2, vec![], MockExt::default()), + >::CodeRejected, + ); + assert_err!( + execute(CODE_RANDOM_2, vec![], MockExt::default()), + >::CodeRejected, + ); + + assert_ok!(execute_unvalidated(CODE_RANDOM_3, vec![], MockExt::default())); + assert_err!( + execute_instantiate_unvalidated(CODE_RANDOM_3, vec![], MockExt::default()), + >::CodeRejected, + ); + assert_err!( + execute(CODE_RANDOM_3, vec![], MockExt::default()), + >::CodeRejected, + ); + } } diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index dfe25bc3af..787b97d31a 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -22,7 +22,9 @@ use crate::{ chain_extension::ChainExtension, storage::meter::Diff, - wasm::{Determinism, Environment, OwnerInfo, PrefabWasmModule}, + wasm::{ + runtime::AllowDeprecatedInterface, Determinism, Environment, OwnerInfo, PrefabWasmModule, + }, AccountIdOf, CodeVec, Config, Error, Schedule, }; use codec::{Encode, MaxEncodedLen}; @@ -54,6 +56,14 @@ pub enum TryInstantiate { Skip, } +/// The reason why a contract is instrumented. +enum InstrumentReason { + /// A new code is uploaded. + New, + /// Existing code is re-instrumented. + Reinstrument, +} + struct ContractModule<'a, T: Config> { /// A deserialized module. The module is valid (this is Guaranteed by `new` method). module: elements::Module, @@ -381,6 +391,7 @@ fn instrument( schedule: &Schedule, determinism: Determinism, try_instantiate: TryInstantiate, + reason: InstrumentReason, ) -> Result<(Vec, (u32, u32)), (DispatchError, &'static str)> where E: Environment<()>, @@ -454,11 +465,20 @@ where // We don't actually ever run any code so we can get away with a minimal stack which // reduces the amount of memory that needs to be zeroed. let stack_limits = StackLimits::new(1, 1, 0).expect("initial <= max; qed"); - PrefabWasmModule::::instantiate::(&code, (), (initial, maximum), stack_limits) - .map_err(|err| { - log::debug!(target: "runtime::contracts", "{}", err); - (Error::::CodeRejected.into(), "new code rejected after instrumentation") - })?; + PrefabWasmModule::::instantiate::( + &code, + (), + (initial, maximum), + stack_limits, + match reason { + InstrumentReason::New => AllowDeprecatedInterface::No, + InstrumentReason::Reinstrument => AllowDeprecatedInterface::Yes, + }, + ) + .map_err(|err| { + log::debug!(target: "runtime::contracts", "{}", err); + (Error::::CodeRejected.into(), "new code rejected after instrumentation") + })?; } Ok((code, (initial, maximum))) @@ -486,8 +506,13 @@ where E: Environment<()>, T: Config, { - let (code, (initial, maximum)) = - instrument::(original_code.as_ref(), schedule, determinism, try_instantiate)?; + let (code, (initial, maximum)) = instrument::( + original_code.as_ref(), + schedule, + determinism, + try_instantiate, + InstrumentReason::New, + )?; let original_code_len = original_code.len(); @@ -532,21 +557,30 @@ where E: Environment<()>, T: Config, { - instrument::(original_code, schedule, determinism, TryInstantiate::Skip) - .map_err(|(err, msg)| { - log::error!(target: "runtime::contracts", "CodeRejected during reinstrument: {}", msg); - err - }) - .map(|(code, _)| code) + instrument::( + original_code, + schedule, + determinism, + // This function was triggered by an interaction with an existing contract code + // that will try to instantiate anyways. Failing here would not help + // as the contract is already on chain. + TryInstantiate::Skip, + InstrumentReason::Reinstrument, + ) + .map_err(|(err, msg)| { + log::error!(target: "runtime::contracts", "CodeRejected during reinstrument: {}", msg); + err + }) + .map(|(code, _)| code) } -/// Alternate (possibly unsafe) preparation functions used only for benchmarking. +/// Alternate (possibly unsafe) preparation functions used only for benchmarking and testing. /// /// For benchmarking we need to construct special contracts that might not pass our /// sanity checks or need to skip instrumentation for correct results. We hide functions -/// allowing this behind a feature that is only set during benchmarking to prevent usage -/// in production code. -#[cfg(feature = "runtime-benchmarks")] +/// allowing this behind a feature that is only set during benchmarking or testing to +/// prevent usage in production code. +#[cfg(any(test, feature = "runtime-benchmarks"))] pub mod benchmarking { use super::*; @@ -600,7 +634,7 @@ mod tests { #[allow(unreachable_code)] mod env { use super::*; - use crate::wasm::runtime::TrapReason; + use crate::wasm::runtime::{AllowDeprecatedInterface, AllowUnstableInterface, TrapReason}; // Define test environment for tests. We need ImportSatisfyCheck // implementation from it. So actual implementations doesn't matter. diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 745583b337..9cdf0bf092 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -37,6 +37,22 @@ use wasmi::{core::HostError, errors::LinkerError, Linker, Memory, Store}; /// The maximum nesting depth a contract can use when encoding types. const MAX_DECODE_NESTING: u32 = 256; +/// Passed to [`Environment`] to determine whether it should expose deprecated interfaces. +pub enum AllowDeprecatedInterface { + /// No deprecated interfaces are exposed. + No, + /// Deprecated interfaces are exposed. + Yes, +} + +/// Passed to [`Environment`] to determine whether it should expose unstable interfaces. +pub enum AllowUnstableInterface { + /// No unstable interfaces are exposed. + No, + /// Unstable interfaces are exposed. + Yes, +} + /// Trait implemented by the [`define_env`](pallet_contracts_proc_macro::define_env) macro for the /// emitted `Env` struct. pub trait Environment { @@ -45,14 +61,15 @@ pub trait Environment { fn define( store: &mut Store, linker: &mut Linker, - allow_unstable: bool, + allow_unstable: AllowUnstableInterface, + allow_deprecated: AllowDeprecatedInterface, ) -> Result<(), LinkerError>; } /// Type of a storage key. #[allow(dead_code)] enum KeyType { - /// Deprecated fix sized key `[u8;32]`. + /// Legacy fix sized key `[u8;32]`. Fix, /// Variable sized key used in transparent hashing, /// cannot be larger than MaxStorageKeyLen. @@ -91,12 +108,8 @@ pub enum ReturnCode { CalleeReverted = 2, /// The passed key does not exist in storage. KeyNotFound = 3, - /// Deprecated and no longer returned: There is only the minimum balance. - _BelowSubsistenceThreshold = 4, /// See [`Error::TransferFailed`]. TransferFailed = 5, - /// Deprecated and no longer returned: Endowment is no longer required. - _EndowmentTooLow = 6, /// No code could be found at the supplied code hash. CodeNotFound = 7, /// The contract that was called is no contract (a plain account). @@ -1280,7 +1293,7 @@ pub mod env { /// Make a call to another contract. /// - /// # Deprecation + /// # New version available /// /// This is equivalent to calling the newer version of this function with /// `flags` set to `ALLOW_REENTRY`. See the newer version for documentation. @@ -1418,7 +1431,7 @@ pub mod env { /// Instantiate a contract with the specified code hash. /// - /// # Deprecation + /// # New version available /// /// This is equivalent to calling the newer version of this function. The newer version /// drops the now unnecessary length fields. @@ -1538,7 +1551,7 @@ pub mod env { /// Remove the calling account and transfer remaining balance. /// - /// # Deprecation + /// # New version available /// /// This is equivalent to calling the newer version of this function. The newer version /// drops the now unnecessary length fields. @@ -1879,12 +1892,8 @@ pub mod env { /// space at `out_ptr` is less than the size of the value a trap is triggered. /// /// The data is encoded as `T::Hash`. - /// - /// # Deprecation - /// - /// This function is deprecated. Users should migrate to the [`super::seal1::Api::random()`] - /// version. #[prefixed_alias] + #[deprecated] fn random( ctx: _, memory: _, @@ -1931,6 +1940,7 @@ pub mod env { /// commitment. #[version(1)] #[prefixed_alias] + #[deprecated] fn random( ctx: _, memory: _, @@ -2001,10 +2011,11 @@ pub mod env { /// `out_ptr`. This call overwrites it with the size of the value. If the available /// space at `out_ptr` is less than the size of the value a trap is triggered. /// - /// # Deprecation + /// # Note /// /// There is no longer a tombstone deposit. This function always returns `0`. #[prefixed_alias] + #[deprecated] fn tombstone_deposit( ctx: _, memory: _, @@ -2030,6 +2041,7 @@ pub mod env { /// The state rent functionality was removed. This is stub only exists for /// backwards compatiblity #[prefixed_alias] + #[deprecated] fn restore_to( ctx: _, memory: _, @@ -2054,6 +2066,7 @@ pub mod env { /// backwards compatiblity #[version(1)] #[prefixed_alias] + #[deprecated] fn restore_to( ctx: _, memory: _, @@ -2067,49 +2080,6 @@ pub mod env { Ok(()) } - /// Deposit a contract event with the data buffer and optional list of topics. There is a limit - /// on the maximum number of topics specified by `event_topics`. - /// - /// - `topics_ptr`: a pointer to the buffer of topics encoded as `Vec`. The value of - /// this is ignored if `topics_len` is set to `0`. The topics list can't contain duplicates. - /// - `topics_len`: the length of the topics buffer. Pass 0 if you want to pass an empty - /// vector. - /// - `data_ptr`: a pointer to a raw data buffer which will saved along the event. - /// - `data_len`: the length of the data buffer. - #[prefixed_alias] - fn deposit_event( - ctx: _, - memory: _, - topics_ptr: u32, - topics_len: u32, - data_ptr: u32, - data_len: u32, - ) -> Result<(), TrapReason> { - let num_topic = topics_len - .checked_div(sp_std::mem::size_of::>() as u32) - .ok_or("Zero sized topics are not allowed")?; - ctx.charge_gas(RuntimeCosts::DepositEvent { num_topic, len: data_len })?; - if data_len > ctx.ext.max_value_size() { - return Err(Error::::ValueTooLarge.into()) - } - - let topics: Vec::T>> = match topics_len { - 0 => Vec::new(), - _ => ctx.read_sandbox_memory_as_unbounded(memory, topics_ptr, topics_len)?, - }; - - // If there are more than `event_topics`, then trap. - if topics.len() > ctx.ext.schedule().limits.event_topics as usize { - return Err(Error::::TooManyTopics.into()) - } - - let event_data = ctx.read_sandbox_memory(memory, data_ptr, data_len)?; - - ctx.ext.deposit_event(topics, event_data); - - Ok(()) - } - /// Was used to set rent allowance of the contract. /// /// # Note @@ -2117,6 +2087,7 @@ pub mod env { /// The state rent functionality was removed. This is stub only exists for /// backwards compatiblity. #[prefixed_alias] + #[deprecated] fn set_rent_allowance( ctx: _, memory: _, @@ -2135,6 +2106,7 @@ pub mod env { /// backwards compatiblity. #[version(1)] #[prefixed_alias] + #[deprecated] fn set_rent_allowance(ctx: _, _memory: _, _value_ptr: u32) -> Result<(), TrapReason> { ctx.charge_gas(RuntimeCosts::DebugMessage)?; Ok(()) @@ -2147,6 +2119,7 @@ pub mod env { /// The state rent functionality was removed. This is stub only exists for /// backwards compatiblity. #[prefixed_alias] + #[deprecated] fn rent_allowance(ctx: _, memory: _, out_ptr: u32, out_len_ptr: u32) -> Result<(), TrapReason> { ctx.charge_gas(RuntimeCosts::Balance)?; let rent_allowance = >::max_value().encode(); @@ -2160,6 +2133,49 @@ pub mod env { )?) } + /// Deposit a contract event with the data buffer and optional list of topics. There is a limit + /// on the maximum number of topics specified by `event_topics`. + /// + /// - `topics_ptr`: a pointer to the buffer of topics encoded as `Vec`. The value of + /// this is ignored if `topics_len` is set to `0`. The topics list can't contain duplicates. + /// - `topics_len`: the length of the topics buffer. Pass 0 if you want to pass an empty + /// vector. + /// - `data_ptr`: a pointer to a raw data buffer which will saved along the event. + /// - `data_len`: the length of the data buffer. + #[prefixed_alias] + fn deposit_event( + ctx: _, + memory: _, + topics_ptr: u32, + topics_len: u32, + data_ptr: u32, + data_len: u32, + ) -> Result<(), TrapReason> { + let num_topic = topics_len + .checked_div(sp_std::mem::size_of::>() as u32) + .ok_or("Zero sized topics are not allowed")?; + ctx.charge_gas(RuntimeCosts::DepositEvent { num_topic, len: data_len })?; + if data_len > ctx.ext.max_value_size() { + return Err(Error::::ValueTooLarge.into()) + } + + let topics: Vec::T>> = match topics_len { + 0 => Vec::new(), + _ => ctx.read_sandbox_memory_as_unbounded(memory, topics_ptr, topics_len)?, + }; + + // If there are more than `event_topics`, then trap. + if topics.len() > ctx.ext.schedule().limits.event_topics as usize { + return Err(Error::::TooManyTopics.into()) + } + + let event_data = ctx.read_sandbox_memory(memory, data_ptr, data_len)?; + + ctx.ext.deposit_event(topics, event_data); + + Ok(()) + } + /// Stores the current block number of the current contract into the supplied buffer. /// /// The value is stored to linear memory at the address pointed to by `out_ptr`. From d74eab8801538ac1218d89833f572697c3fae77b Mon Sep 17 00:00:00 2001 From: Sasha Gryaznov Date: Wed, 25 Jan 2023 20:12:29 +0200 Subject: [PATCH 52/80] [contracts] Add upfront weight of merkle trie proofs for storage reading functions (#13236) * Add upfront weight of merkle trie proofs for storage reading functions * drive-by fixes --- frame/contracts/proc-macro/src/lib.rs | 17 ++++++++++------- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/schedule.rs | 10 +++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/frame/contracts/proc-macro/src/lib.rs b/frame/contracts/proc-macro/src/lib.rs index eaf437c150..de7b9b881d 100644 --- a/frame/contracts/proc-macro/src/lib.rs +++ b/frame/contracts/proc-macro/src/lib.rs @@ -124,21 +124,24 @@ fn format_weight(field: &Ident) -> TokenStream2 { quote_spanned! { field.span() => &if self.#field.ref_time() > 1_000_000_000 { format!( - "{:.1?} ms", - Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000_000).to_float() + "{:.1?} ms, {} bytes", + Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000_000).to_float(), + self.#field.proof_size() ) } else if self.#field.ref_time() > 1_000_000 { format!( - "{:.1?} µs", - Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000).to_float() + "{:.1?} µs, {} bytes", + Fixed::saturating_from_rational(self.#field.ref_time(), 1_000_000).to_float(), + self.#field.proof_size() ) } else if self.#field.ref_time() > 1_000 { format!( - "{:.1?} ns", - Fixed::saturating_from_rational(self.#field.ref_time(), 1_000).to_float() + "{:.1?} ns, {} bytes", + Fixed::saturating_from_rational(self.#field.ref_time(), 1_000).to_float(), + self.#field.proof_size() ) } else { - format!("{} ps", self.#field.ref_time()) + format!("{} ps, {} bytes", self.#field.ref_time(), self.#field.proof_size()) } } } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 84a72b7016..f97b4b790c 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -78,7 +78,7 @@ //! //! * [`ink`](https://github.com/paritytech/ink) is //! an [`eDSL`](https://wiki.haskell.org/Embedded_domain_specific_language) that enables writing -//! WebAssembly based smart contracts in the Rust programming language. This is a work in progress. +//! WebAssembly based smart contracts in the Rust programming language. #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] diff --git a/frame/contracts/src/schedule.rs b/frame/contracts/src/schedule.rs index eabd18c818..7e09d55b44 100644 --- a/frame/contracts/src/schedule.rs +++ b/frame/contracts/src/schedule.rs @@ -644,23 +644,23 @@ impl Default for HostFnWeights { 1 )), debug_message: to_weight!(cost_batched!(seal_debug_message)), - set_storage: to_weight!(cost_batched!(seal_set_storage)), + set_storage: to_weight!(cost_batched!(seal_set_storage), 1024u64), set_code_hash: to_weight!(cost_batched!(seal_set_code_hash)), set_storage_per_new_byte: to_weight!(cost_byte_batched!(seal_set_storage_per_new_kb)), set_storage_per_old_byte: to_weight!( cost_byte_batched!(seal_set_storage_per_old_kb), 1u64 ), - clear_storage: to_weight!(cost_batched!(seal_clear_storage)), + clear_storage: to_weight!(cost_batched!(seal_clear_storage), 1024u64), clear_storage_per_byte: to_weight!(cost_byte_batched!(seal_clear_storage_per_kb), 1u64), - contains_storage: to_weight!(cost_batched!(seal_contains_storage)), + contains_storage: to_weight!(cost_batched!(seal_contains_storage), 1024u64), contains_storage_per_byte: to_weight!( cost_byte_batched!(seal_contains_storage_per_kb), 1u64 ), - get_storage: to_weight!(cost_batched!(seal_get_storage)), + get_storage: to_weight!(cost_batched!(seal_get_storage), 1024u64), get_storage_per_byte: to_weight!(cost_byte_batched!(seal_get_storage_per_kb), 1u64), - take_storage: to_weight!(cost_batched!(seal_take_storage)), + take_storage: to_weight!(cost_batched!(seal_take_storage), 1024u64), take_storage_per_byte: to_weight!(cost_byte_batched!(seal_take_storage_per_kb), 1u64), transfer: to_weight!(cost_batched!(seal_transfer)), call: to_weight!(cost_batched!(seal_call)), From d22e68ccb67788a1f1ad5a044568abd3e0a2c904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 25 Jan 2023 23:49:03 +0100 Subject: [PATCH 53/80] CI: Rewrite `check-each-crate` in python (#13238) * CI: Rewrite `check-each-crate` in python This is a much better readable version of the script and it should also work on Macos and not siltently fail ;) * Fix dumb bugs and print everything to stderr * Don't buffer Python output * :facepalm: * :facepalm: :facepalm: * Use check all until we have more macos runners * Update scripts/ci/gitlab/check-each-crate.py Co-authored-by: Oliver Tale-Yazdi * Update scripts/ci/gitlab/pipeline/test.yml Co-authored-by: Vladimir Istyufeev Co-authored-by: Oliver Tale-Yazdi --- scripts/ci/gitlab/check-each-crate.py | 57 +++++++++++++++++++++++++++ scripts/ci/gitlab/check-each-crate.sh | 54 ------------------------- scripts/ci/gitlab/pipeline/test.yml | 5 ++- 3 files changed, 60 insertions(+), 56 deletions(-) create mode 100755 scripts/ci/gitlab/check-each-crate.py delete mode 100755 scripts/ci/gitlab/check-each-crate.sh diff --git a/scripts/ci/gitlab/check-each-crate.py b/scripts/ci/gitlab/check-each-crate.py new file mode 100755 index 0000000000..adad4f5bd5 --- /dev/null +++ b/scripts/ci/gitlab/check-each-crate.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 + +# A script that checks each workspace crate individually. +# It's relevant to check workspace crates individually because otherwise their compilation problems +# due to feature misconfigurations won't be caught, as exemplified by +# https://github.com/paritytech/substrate/issues/12705 +# +# `check-each-crate.py target_group groups_total` +# +# - `target_group`: Integer starting from 1, the group this script should execute. +# - `groups_total`: Integer starting from 1, total number of groups. + +import subprocess, sys + +# Get all crates +output = subprocess.check_output(["cargo", "tree", "--locked", "--workspace", "--depth", "0", "--prefix", "none"]) + +# Convert the output into a proper list +crates = [] +for line in output.splitlines(): + if line != b"": + crates.append(line.decode('utf8').split(" ")[0]) + +# Make the list unique and sorted +crates = list(set(crates)) +crates.sort() + +target_group = int(sys.argv[1]) - 1 +groups_total = int(sys.argv[2]) + +if len(crates) == 0: + print("No crates detected!", file=sys.stderr) + sys.exit(1) + +print(f"Total crates: {len(crates)}", file=sys.stderr) + +crates_per_group = len(crates) // groups_total + +# If this is the last runner, we need to take care of crates +# after the group that we lost because of the integer division. +if target_group + 1 == groups_total: + overflow_crates = len(crates) % groups_total +else: + overflow_crates = 0 + +print(f"Crates per group: {crates_per_group}", file=sys.stderr) + +# Check each crate +for i in range(0, crates_per_group + overflow_crates): + crate = crates_per_group * target_group + i + + print(f"Checking {crates[crate]}", file=sys.stderr) + + res = subprocess.run(["cargo", "check", "--locked", "-p", crates[crate]]) + + if res.returncode != 0: + sys.exit(1) diff --git a/scripts/ci/gitlab/check-each-crate.sh b/scripts/ci/gitlab/check-each-crate.sh deleted file mode 100755 index 24cad67007..0000000000 --- a/scripts/ci/gitlab/check-each-crate.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -## A script that checks each workspace crate individually. -## It's relevant to check workspace crates individually because otherwise their compilation problems -## due to feature misconfigurations won't be caught, as exemplified by -## https://github.com/paritytech/substrate/issues/12705 - -set -Eeu -o pipefail -shopt -s inherit_errexit - -set -vx - -target_group="$1" -groups_total="$2" - -readarray -t workspace_crates < <(\ - cargo tree --workspace --depth 0 --prefix none | - awk '{ if (length($1) == 0 || substr($1, 1, 1) == "[") { skip } else { print $1 } }' | - sort | - uniq -) - -crates_total=${#workspace_crates[*]} -if [ "$crates_total" -lt 1 ]; then - >&2 echo "No crates detected for $PWD" - exit 1 -fi - -if [ "$crates_total" -lt "$groups_total" ]; then - # `crates_total / groups_total` would result in 0, so round it up to 1 - crates_per_group=1 -else - # We add `crates_total % groups_total > 0` (which evaluates to 1 in case there's a remainder for - # `crates_total % groups_total`) to round UP `crates_total / groups_total` 's - # potentially-fractional result to the nearest integer. Doing that ensures that we'll not miss any - # crate in case `crates_total / groups_total` would normally result in a fractional number, since - # in those cases Bash would round DOWN the result to the nearest integer. For example, if - # `crates_total = 5` and `groups_total = 2`, then `crates_total / groups_total` would round down - # to 2; since the loop below would then step by 2, we'd miss the 5th crate. - crates_per_group=$(( (crates_total / groups_total) + (crates_total % groups_total > 0) )) -fi - -group=1 -for ((i=0; i < crates_total; i += crates_per_group)); do - if [ $group -eq "$target_group" ]; then - crates_in_group=("${workspace_crates[@]:$i:$crates_per_group}") - echo "crates in the group: ${crates_in_group[*]}" >/dev/null # >/dev/null due to "set -x" - for crate in "${crates_in_group[@]}"; do - cargo check --locked --release -p "$crate" - done - break - fi - group=$(( group + 1 )) -done diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index f00857ffa9..02e05752fd 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -411,7 +411,7 @@ cargo-check-each-crate: CI_JOB_NAME: cargo-check-each-crate script: - rusty-cachier snapshot create - - time ./scripts/ci/gitlab/check-each-crate.sh "$CI_NODE_INDEX" "$CI_NODE_TOTAL" + - PYTHONUNBUFFERED=x time ./scripts/ci/gitlab/check-each-crate.py "$CI_NODE_INDEX" "$CI_NODE_TOTAL" # need to update cache only from one job - if [ "$CI_NODE_INDEX" == 1 ]; then rusty-cachier cache upload; fi parallel: 2 @@ -449,6 +449,7 @@ cargo-check-each-crate-macos: script: # TODO: enable rusty-cachier once it supports Mac # TODO: use parallel jobs, as per cargo-check-each-crate, once more Mac runners are available - - time ./scripts/ci/gitlab/check-each-crate.sh 1 1 + # - time ./scripts/ci/gitlab/check-each-crate.py 1 1 + - time cargo check --workspace --locked tags: - osx From d02922585673cb626df11a39927502d2ba040ff9 Mon Sep 17 00:00:00 2001 From: zjb0807 Date: Thu, 26 Jan 2023 12:12:19 +1300 Subject: [PATCH 54/80] Fix try-runtime with create-snapshot (#13223) * Fix try-runtime with create-snapshot * Apply review suggestions --- .../frame/try-runtime/cli/src/commands/create_snapshot.rs | 2 +- utils/frame/try-runtime/cli/src/commands/execute_block.rs | 2 +- utils/frame/try-runtime/cli/src/commands/follow_chain.rs | 2 +- .../frame/try-runtime/cli/src/commands/offchain_worker.rs | 2 +- .../try-runtime/cli/src/commands/on_runtime_upgrade.rs | 2 +- utils/frame/try-runtime/cli/src/lib.rs | 7 +++++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/utils/frame/try-runtime/cli/src/commands/create_snapshot.rs b/utils/frame/try-runtime/cli/src/commands/create_snapshot.rs index ef39c3d984..8d6144f84c 100644 --- a/utils/frame/try-runtime/cli/src/commands/create_snapshot.rs +++ b/utils/frame/try-runtime/cli/src/commands/create_snapshot.rs @@ -71,7 +71,7 @@ where let executor = build_executor::(&shared); let _ = State::Live(command.from) - .into_ext::(&shared, &executor, Some(path.into())) + .into_ext::(&shared, &executor, Some(path.into()), false) .await?; Ok(()) diff --git a/utils/frame/try-runtime/cli/src/commands/execute_block.rs b/utils/frame/try-runtime/cli/src/commands/execute_block.rs index ee5e21af5d..e054c8ab87 100644 --- a/utils/frame/try-runtime/cli/src/commands/execute_block.rs +++ b/utils/frame/try-runtime/cli/src/commands/execute_block.rs @@ -99,7 +99,7 @@ where HostFns: HostFunctions, { let executor = build_executor::(&shared); - let ext = command.state.into_ext::(&shared, &executor, None).await?; + let ext = command.state.into_ext::(&shared, &executor, None, true).await?; // get the block number associated with this block. let block_ws_uri = command.block_ws_uri::(); diff --git a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs index e4f166fe7a..d887757b16 100644 --- a/utils/frame/try-runtime/cli/src/commands/follow_chain.rs +++ b/utils/frame/try-runtime/cli/src/commands/follow_chain.rs @@ -137,7 +137,7 @@ where pallet: vec![], child_tree: true, }); - let ext = state.into_ext::(&shared, &executor, None).await?; + let ext = state.into_ext::(&shared, &executor, None, true).await?; maybe_state_ext = Some(ext); } diff --git a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs index c55de7da64..985b04bfb1 100644 --- a/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs +++ b/utils/frame/try-runtime/cli/src/commands/offchain_worker.rs @@ -78,7 +78,7 @@ where { let executor = build_executor(&shared); // we first build the externalities with the remote code. - let ext = command.state.into_ext::(&shared, &executor, None).await?; + let ext = command.state.into_ext::(&shared, &executor, None, true).await?; let header_ws_uri = command.header_ws_uri::(); diff --git a/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs b/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs index 81f81d6a55..61b5847ed8 100644 --- a/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs +++ b/utils/frame/try-runtime/cli/src/commands/on_runtime_upgrade.rs @@ -62,7 +62,7 @@ where HostFns: HostFunctions, { let executor = build_executor(&shared); - let ext = command.state.into_ext::(&shared, &executor, None).await?; + let ext = command.state.into_ext::(&shared, &executor, None, true).await?; let (_, encoded_result) = state_machine_call_with_proof::( &ext, diff --git a/utils/frame/try-runtime/cli/src/lib.rs b/utils/frame/try-runtime/cli/src/lib.rs index aac2ad4238..dea20febb9 100644 --- a/utils/frame/try-runtime/cli/src/lib.rs +++ b/utils/frame/try-runtime/cli/src/lib.rs @@ -609,6 +609,7 @@ impl State { shared: &SharedParams, executor: &WasmExecutor, state_snapshot: Option, + try_runtime_check: bool, ) -> sc_cli::Result> where Block::Hash: FromStr, @@ -707,8 +708,10 @@ impl State { } // whatever runtime we have in store now must have been compiled with try-runtime feature. - if !ensure_try_runtime::(&executor, &mut ext) { - return Err("given runtime is NOT compiled with try-runtime feature!".into()) + if try_runtime_check { + if !ensure_try_runtime::(&executor, &mut ext) { + return Err("given runtime is NOT compiled with try-runtime feature!".into()) + } } Ok(ext) From 8b4331c27bba6d9f178b8be093e39153350b9be8 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Wed, 25 Jan 2023 20:59:19 -0300 Subject: [PATCH 55/80] reduce exec time of fast-unstake benchmarks (#13120) * reduce exec time of fast-unstake benchmarks * fix test * fmt * fix patch the tests * fix patch the tests * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * add batch size as well * update some benches to be better * fix one last test * fix * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * reduce time even more * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * fix tests * nit * remove * improve the weight calc further * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * fix benchmarks * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * update * fix * fix * fmt * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * lots of changes again... * smaller input * update * fmt * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * cleanup * small simplification * fmt * reduce exec time a bit * fix * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * test * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * increase again * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake * review comments * fmt * fix * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake Co-authored-by: command-bot <> --- bin/node/runtime/src/lib.rs | 5 +- frame/fast-unstake/src/benchmarking.rs | 38 +++--- frame/fast-unstake/src/lib.rs | 126 ++++++++++++------ frame/fast-unstake/src/mock.rs | 3 + frame/fast-unstake/src/tests.rs | 173 ++++++------------------- frame/fast-unstake/src/weights.rs | 155 ++++++++++++---------- 6 files changed, 237 insertions(+), 263 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 0ac6ade912..1f85d118ea 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -591,10 +591,13 @@ impl pallet_staking::Config for Runtime { impl pallet_fast_unstake::Config for Runtime { type RuntimeEvent = RuntimeEvent; type ControlOrigin = frame_system::EnsureRoot; - type BatchSize = ConstU32<128>; + type BatchSize = ConstU32<64>; type Deposit = ConstU128<{ DOLLARS }>; type Currency = Balances; type Staking = Staking; + type MaxErasToCheckPerBlock = ConstU32<1>; + #[cfg(feature = "runtime-benchmarks")] + type MaxBackersPerValidator = MaxNominatorRewardedPerValidator; type WeightInfo = (); } diff --git a/frame/fast-unstake/src/benchmarking.rs b/frame/fast-unstake/src/benchmarking.rs index b4a5e21dcf..de85502f7b 100644 --- a/frame/fast-unstake/src/benchmarking.rs +++ b/frame/fast-unstake/src/benchmarking.rs @@ -31,13 +31,11 @@ use sp_staking::{EraIndex, StakingInterface}; use sp_std::prelude::*; const USER_SEED: u32 = 0; -const DEFAULT_BACKER_PER_VALIDATOR: u32 = 128; -const MAX_VALIDATORS: u32 = 128; type CurrencyOf = ::Currency; -fn create_unexposed_nominators() -> Vec { - (0..T::BatchSize::get()) +fn create_unexposed_batch(batch_size: u32) -> Vec { + (0..batch_size) .map(|i| { let account = frame_benchmarking::account::("unexposed_nominator", i, USER_SEED); @@ -76,7 +74,7 @@ fn setup_staking(v: u32, until: EraIndex) { .collect::>(); for era in 0..=until { - let others = (0..DEFAULT_BACKER_PER_VALIDATOR) + let others = (0..T::MaxBackersPerValidator::get()) .map(|s| { let who = frame_benchmarking::account::("nominator", era, s); let value = ed; @@ -97,8 +95,10 @@ fn on_idle_full_block() { benchmarks! { // on_idle, we don't check anyone, but fully unbond them. on_idle_unstake { + let b in 1 .. T::BatchSize::get(); + ErasToCheckPerBlock::::put(1); - for who in create_unexposed_nominators::() { + for who in create_unexposed_batch::(b).into_iter() { assert_ok!(FastUnstake::::register_fast_unstake( RawOrigin::Signed(who.clone()).into(), )); @@ -114,7 +114,7 @@ benchmarks! { checked, stashes, .. - }) if checked.len() == 1 && stashes.len() as u32 == T::BatchSize::get() + }) if checked.len() == 1 && stashes.len() as u32 == b )); } : { @@ -123,25 +123,23 @@ benchmarks! { verify { assert!(matches!( fast_unstake_events::().last(), - Some(Event::BatchFinished) + Some(Event::BatchFinished { size: b }) )); } - // on_idle, when we check some number of eras, + // on_idle, when we check some number of eras and the queue is already set. on_idle_check { - // number of eras multiplied by validators in that era. - let x in (T::Staking::bonding_duration() * 1) .. (T::Staking::bonding_duration() * MAX_VALIDATORS); - - let u = T::Staking::bonding_duration(); - let v = x / u; + let v in 1 .. 256; + let b in 1 .. T::BatchSize::get(); + let u = T::MaxErasToCheckPerBlock::get().min(T::Staking::bonding_duration()); ErasToCheckPerBlock::::put(u); T::Staking::set_current_era(u); - // setup staking with v validators and u eras of data (0..=u) + // setup staking with v validators and u eras of data (0..=u+1) setup_staking::(v, u); - let stashes = create_unexposed_nominators::().into_iter().map(|s| { + let stashes = create_unexposed_batch::(b).into_iter().map(|s| { assert_ok!(FastUnstake::::register_fast_unstake( RawOrigin::Signed(s.clone()).into(), )); @@ -150,6 +148,8 @@ benchmarks! { // no one is queued thus far. assert_eq!(Head::::get(), None); + + Head::::put(UnstakeRequest { stashes: stashes.clone().try_into().unwrap(), checked: Default::default() }); } : { on_idle_full_block::(); @@ -167,7 +167,7 @@ benchmarks! { register_fast_unstake { ErasToCheckPerBlock::::put(1); - let who = create_unexposed_nominators::().get(0).cloned().unwrap(); + let who = create_unexposed_batch::(1).get(0).cloned().unwrap(); whitelist_account!(who); assert_eq!(Queue::::count(), 0); @@ -179,7 +179,7 @@ benchmarks! { deregister { ErasToCheckPerBlock::::put(1); - let who = create_unexposed_nominators::().get(0).cloned().unwrap(); + let who = create_unexposed_batch::(1).get(0).cloned().unwrap(); assert_ok!(FastUnstake::::register_fast_unstake( RawOrigin::Signed(who.clone()).into(), )); @@ -194,7 +194,7 @@ benchmarks! { control { let origin = ::ControlOrigin::successful_origin(); } - : _(origin, 128) + : _(origin, T::MaxErasToCheckPerBlock::get()) verify {} impl_benchmark_test_suite!(Pallet, crate::mock::ExtBuilder::default().build(), crate::mock::Runtime) diff --git a/frame/fast-unstake/src/lib.rs b/frame/fast-unstake/src/lib.rs index c0bffc4427..82454a4b8a 100644 --- a/frame/fast-unstake/src/lib.rs +++ b/frame/fast-unstake/src/lib.rs @@ -86,12 +86,9 @@ pub mod pallet { traits::{Defensive, ReservableCurrency, StorageVersion}, }; use frame_system::pallet_prelude::*; - use sp_runtime::{ - traits::{Saturating, Zero}, - DispatchResult, - }; + use sp_runtime::{traits::Zero, DispatchResult}; use sp_staking::{EraIndex, StakingInterface}; - use sp_std::{collections::btree_set::BTreeSet, prelude::*, vec::Vec}; + use sp_std::{prelude::*, vec::Vec}; pub use weights::WeightInfo; #[derive(scale_info::TypeInfo, codec::Encode, codec::Decode, codec::MaxEncodedLen)] @@ -138,6 +135,14 @@ pub mod pallet { /// The weight information of this pallet. type WeightInfo: WeightInfo; + + /// Maximum value for `ErasToCheckPerBlock`. This should be as close as possible, but more + /// than the actual value, in order to have accurate benchmarks. + type MaxErasToCheckPerBlock: Get; + + /// Use only for benchmarking. + #[cfg(feature = "runtime-benchmarks")] + type MaxBackersPerValidator: Get; } /// The current "head of the queue" being unstaked. @@ -173,11 +178,11 @@ pub mod pallet { InternalError, /// A batch was partially checked for the given eras, but the process did not finish. BatchChecked { eras: Vec }, - /// A batch was terminated. + /// A batch of a given size was terminated. /// /// This is always follows by a number of `Unstaked` or `Slashed` events, marking the end /// of the batch. A new batch will be created upon next block. - BatchFinished, + BatchFinished { size: u32 }, } #[pallet::error] @@ -208,6 +213,31 @@ pub mod pallet { Self::do_on_idle(remaining_weight) } + + fn integrity_test() { + sp_std::if_std! { + sp_io::TestExternalities::new_empty().execute_with(|| { + // ensure that the value of `ErasToCheckPerBlock` is less than + // `T::MaxErasToCheckPerBlock`. + assert!( + ErasToCheckPerBlock::::get() <= T::MaxErasToCheckPerBlock::get(), + "the value of `ErasToCheckPerBlock` is greater than `T::MaxErasToCheckPerBlock`", + ); + }); + } + } + + #[cfg(feature = "try-runtime")] + fn try_state(_n: T::BlockNumber) -> Result<(), &'static str> { + // ensure that the value of `ErasToCheckPerBlock` is less than + // `T::MaxErasToCheckPerBlock`. + assert!( + ErasToCheckPerBlock::::get() <= T::MaxErasToCheckPerBlock::get(), + "the value of `ErasToCheckPerBlock` is greater than `T::MaxErasToCheckPerBlock`", + ); + + Ok(()) + } } #[pallet::call] @@ -288,9 +318,10 @@ pub mod pallet { /// Dispatch origin must be signed by the [`Config::ControlOrigin`]. #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::control())] - pub fn control(origin: OriginFor, unchecked_eras_to_check: EraIndex) -> DispatchResult { + pub fn control(origin: OriginFor, eras_to_check: EraIndex) -> DispatchResult { let _ = T::ControlOrigin::ensure_origin(origin)?; - ErasToCheckPerBlock::::put(unchecked_eras_to_check); + ensure!(eras_to_check <= T::MaxErasToCheckPerBlock::get(), Error::::CallNotAllowed); + ErasToCheckPerBlock::::put(eras_to_check); Ok(()) } } @@ -324,27 +355,38 @@ pub mod pallet { /// found out to have no eras to check. At the end of a check cycle, even if they are fully /// checked, we don't finish the process. pub(crate) fn do_on_idle(remaining_weight: Weight) -> Weight { - let mut eras_to_check_per_block = ErasToCheckPerBlock::::get(); + // any weight that is unaccounted for + let mut unaccounted_weight = Weight::from_ref_time(0); + + let eras_to_check_per_block = ErasToCheckPerBlock::::get(); if eras_to_check_per_block.is_zero() { - return T::DbWeight::get().reads(1) + return T::DbWeight::get().reads(1).saturating_add(unaccounted_weight) } // NOTE: here we're assuming that the number of validators has only ever increased, // meaning that the number of exposures to check is either this per era, or less. let validator_count = T::Staking::desired_validator_count(); + let (next_batch_size, reads_from_queue) = Head::::get() + .map_or((Queue::::count().min(T::BatchSize::get()), true), |head| { + (head.stashes.len() as u32, false) + }); // determine the number of eras to check. This is based on both `ErasToCheckPerBlock` // and `remaining_weight` passed on to us from the runtime executive. - let max_weight = |v, u| { - ::WeightInfo::on_idle_check(v * u) - .max(::WeightInfo::on_idle_unstake()) + let max_weight = |v, b| { + // NOTE: this potentially under-counts by up to `BatchSize` reads from the queue. + ::WeightInfo::on_idle_check(v, b) + .max(::WeightInfo::on_idle_unstake(b)) + .saturating_add(if reads_from_queue { + T::DbWeight::get().reads(next_batch_size.into()) + } else { + Zero::zero() + }) }; - while max_weight(validator_count, eras_to_check_per_block).any_gt(remaining_weight) { - eras_to_check_per_block.saturating_dec(); - if eras_to_check_per_block.is_zero() { - log!(debug, "early existing because eras_to_check_per_block is zero"); - return T::DbWeight::get().reads(2) - } + + if max_weight(validator_count, next_batch_size).any_gt(remaining_weight) { + log!(debug, "early exit because eras_to_check_per_block is zero"); + return T::DbWeight::get().reads(3).saturating_add(unaccounted_weight) } if T::Staking::election_ongoing() { @@ -352,7 +394,7 @@ pub mod pallet { // there is an ongoing election -- we better not do anything. Imagine someone is not // exposed anywhere in the last era, and the snapshot for the election is already // taken. In this time period, we don't want to accidentally unstake them. - return T::DbWeight::get().reads(2) + return T::DbWeight::get().reads(4).saturating_add(unaccounted_weight) } let UnstakeRequest { stashes, mut checked } = match Head::::take().or_else(|| { @@ -362,6 +404,9 @@ pub mod pallet { .collect::>() .try_into() .expect("take ensures bound is met; qed"); + unaccounted_weight.saturating_accrue( + T::DbWeight::get().reads_writes(stashes.len() as u64, stashes.len() as u64), + ); if stashes.is_empty() { None } else { @@ -377,10 +422,11 @@ pub mod pallet { log!( debug, - "checking {:?} stashes, eras_to_check_per_block = {:?}, remaining_weight = {:?}", + "checking {:?} stashes, eras_to_check_per_block = {:?}, checked {:?}, remaining_weight = {:?}", stashes.len(), eras_to_check_per_block, - remaining_weight + checked, + remaining_weight, ); // the range that we're allowed to check in this round. @@ -431,11 +477,10 @@ pub mod pallet { } }; - let check_stash = |stash, deposit, eras_checked: &mut BTreeSet| { - let is_exposed = unchecked_eras_to_check.iter().any(|e| { - eras_checked.insert(*e); - T::Staking::is_exposed_in_era(&stash, e) - }); + let check_stash = |stash, deposit| { + let is_exposed = unchecked_eras_to_check + .iter() + .any(|e| T::Staking::is_exposed_in_era(&stash, e)); if is_exposed { T::Currency::slash_reserved(&stash, deposit); @@ -448,20 +493,16 @@ pub mod pallet { }; if unchecked_eras_to_check.is_empty() { - // `stash` is not exposed in any era now -- we can let go of them now. + // `stashes` are not exposed in any era now -- we can let go of them now. + let size = stashes.len() as u32; stashes.into_iter().for_each(|(stash, deposit)| unstake_stash(stash, deposit)); - Self::deposit_event(Event::::BatchFinished); - ::WeightInfo::on_idle_unstake() + Self::deposit_event(Event::::BatchFinished { size }); + ::WeightInfo::on_idle_unstake(size).saturating_add(unaccounted_weight) } else { - // eras checked so far. - let mut eras_checked = BTreeSet::::new(); - let pre_length = stashes.len(); let stashes: BoundedVec<(T::AccountId, BalanceOf), T::BatchSize> = stashes .into_iter() - .filter(|(stash, deposit)| { - check_stash(stash.clone(), *deposit, &mut eras_checked) - }) + .filter(|(stash, deposit)| check_stash(stash.clone(), *deposit)) .collect::>() .try_into() .expect("filter can only lessen the length; still in bound; qed"); @@ -469,8 +510,8 @@ pub mod pallet { log!( debug, - "checked {:?} eras, pre stashes: {:?}, post: {:?}", - eras_checked.len(), + "checked {:?}, pre stashes: {:?}, post: {:?}", + unchecked_eras_to_check, pre_length, post_length, ); @@ -478,7 +519,7 @@ pub mod pallet { match checked.try_extend(unchecked_eras_to_check.clone().into_iter()) { Ok(_) => if stashes.is_empty() { - Self::deposit_event(Event::::BatchFinished); + Self::deposit_event(Event::::BatchFinished { size: 0 }); } else { Head::::put(UnstakeRequest { stashes, checked }); Self::deposit_event(Event::::BatchChecked { @@ -491,9 +532,8 @@ pub mod pallet { }, } - ::WeightInfo::on_idle_check( - validator_count * eras_checked.len() as u32, - ) + ::WeightInfo::on_idle_check(validator_count, pre_length as u32) + .saturating_add(unaccounted_weight) } } } diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index 3f974e5e1a..38cf41fdeb 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -185,6 +185,9 @@ impl fast_unstake::Config for Runtime { type ControlOrigin = frame_system::EnsureRoot; type BatchSize = BatchSize; type WeightInfo = (); + type MaxErasToCheckPerBlock = ConstU32<16>; + #[cfg(feature = "runtime-benchmarks")] + type MaxBackersPerValidator = ConstU32<128>; } type Block = frame_system::mocking::MockBlock; diff --git a/frame/fast-unstake/src/tests.rs b/frame/fast-unstake/src/tests.rs index 522aa1d0fa..3e62146ae2 100644 --- a/frame/fast-unstake/src/tests.rs +++ b/frame/fast-unstake/src/tests.rs @@ -18,7 +18,7 @@ //! Tests for pallet-fast-unstake. use super::*; -use crate::{mock::*, types::*, weights::WeightInfo, Event}; +use crate::{mock::*, types::*, Event}; use frame_support::{assert_noop, assert_ok, bounded_vec, pallet_prelude::*, traits::Currency}; use pallet_staking::{CurrentEra, RewardDestination}; @@ -236,120 +236,6 @@ mod on_idle { }); } - #[test] - fn respects_weight() { - ExtBuilder::default().build_and_execute(|| { - // we want to check all eras in one block... - ErasToCheckPerBlock::::put(BondingDuration::get() + 1); - CurrentEra::::put(BondingDuration::get()); - - // given - assert_ok!(FastUnstake::register_fast_unstake(RuntimeOrigin::signed(2))); - assert_eq!(Queue::::get(1), Some(Deposit::get())); - - assert_eq!(Queue::::count(), 1); - assert_eq!(Head::::get(), None); - - // when: call fast unstake with not enough weight to process the whole thing, just one - // era. - let remaining_weight = ::WeightInfo::on_idle_check( - pallet_staking::ValidatorCount::::get() * 1, - ); - assert_eq!(FastUnstake::on_idle(0, remaining_weight), remaining_weight); - - // then - assert_eq!( - fast_unstake_events_since_last_call(), - vec![Event::BatchChecked { eras: vec![3] }] - ); - assert_eq!( - Head::::get(), - Some(UnstakeRequest { - stashes: bounded_vec![(1, Deposit::get())], - checked: bounded_vec![3] - }) - ); - - // when: another 1 era. - let remaining_weight = ::WeightInfo::on_idle_check( - pallet_staking::ValidatorCount::::get() * 1, - ); - assert_eq!(FastUnstake::on_idle(0, remaining_weight), remaining_weight); - - // then: - assert_eq!( - fast_unstake_events_since_last_call(), - vec![Event::BatchChecked { eras: bounded_vec![2] }] - ); - assert_eq!( - Head::::get(), - Some(UnstakeRequest { - stashes: bounded_vec![(1, Deposit::get())], - checked: bounded_vec![3, 2] - }) - ); - - // when: then 5 eras, we only need 2 more. - let remaining_weight = ::WeightInfo::on_idle_check( - pallet_staking::ValidatorCount::::get() * 5, - ); - assert_eq!( - FastUnstake::on_idle(0, remaining_weight), - // note the amount of weight consumed: 2 eras worth of weight. - ::WeightInfo::on_idle_check( - pallet_staking::ValidatorCount::::get() * 2, - ) - ); - - // then: - assert_eq!( - fast_unstake_events_since_last_call(), - vec![Event::BatchChecked { eras: vec![1, 0] }] - ); - assert_eq!( - Head::::get(), - Some(UnstakeRequest { - stashes: bounded_vec![(1, Deposit::get())], - checked: bounded_vec![3, 2, 1, 0] - }) - ); - - // when: not enough weight to unstake: - let remaining_weight = - ::WeightInfo::on_idle_unstake() - Weight::from_ref_time(1); - assert_eq!(FastUnstake::on_idle(0, remaining_weight), Weight::from_ref_time(0)); - - // then nothing happens: - assert_eq!(fast_unstake_events_since_last_call(), vec![]); - assert_eq!( - Head::::get(), - Some(UnstakeRequest { - stashes: bounded_vec![(1, Deposit::get())], - checked: bounded_vec![3, 2, 1, 0] - }) - ); - - // when: enough weight to get over at least one iteration: then we are unblocked and can - // unstake. - let remaining_weight = ::WeightInfo::on_idle_check( - pallet_staking::ValidatorCount::::get() * 1, - ); - assert_eq!( - FastUnstake::on_idle(0, remaining_weight), - ::WeightInfo::on_idle_unstake() - ); - - // then we finish the unbonding: - assert_eq!( - fast_unstake_events_since_last_call(), - vec![Event::Unstaked { stash: 1, result: Ok(()) }, Event::BatchFinished], - ); - assert_eq!(Head::::get(), None,); - - assert_unstaked(&1); - }); - } - #[test] fn if_head_not_set_one_random_fetched_from_queue() { ExtBuilder::default().build_and_execute(|| { @@ -410,7 +296,7 @@ mod on_idle { vec![ Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished, + Event::BatchFinished { size: 1 }, Event::BatchChecked { eras: vec![3, 2, 1, 0] } ] ); @@ -458,10 +344,10 @@ mod on_idle { vec![ Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished, + Event::BatchFinished { size: 1 }, Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::Unstaked { stash: 3, result: Ok(()) }, - Event::BatchFinished, + Event::BatchFinished { size: 1 }, ] ); @@ -503,7 +389,7 @@ mod on_idle { vec![ Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 1 } ] ); assert_unstaked(&1); @@ -545,7 +431,7 @@ mod on_idle { vec![ Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 1 } ] ); assert_unstaked(&1); @@ -620,7 +506,7 @@ mod on_idle { Event::BatchChecked { eras: vec![1] }, Event::BatchChecked { eras: vec![0] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 1 } ] ); assert_unstaked(&1); @@ -704,7 +590,7 @@ mod on_idle { Event::BatchChecked { eras: vec![0] }, Event::BatchChecked { eras: vec![4] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 1 } ] ); assert_unstaked(&1); @@ -799,7 +685,7 @@ mod on_idle { Event::BatchChecked { eras: vec![4] }, Event::BatchChecked { eras: vec![1] }, Event::Unstaked { stash: 1, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 1 } ] ); @@ -843,7 +729,7 @@ mod on_idle { Event::BatchChecked { eras: vec![3] }, Event::BatchChecked { eras: vec![2] }, Event::Slashed { stash: exposed, amount: Deposit::get() }, - Event::BatchFinished + Event::BatchFinished { size: 0 } ] ); }); @@ -879,7 +765,7 @@ mod on_idle { vec![ Event::BatchChecked { eras: vec![3, 2] }, Event::Slashed { stash: exposed, amount: Deposit::get() }, - Event::BatchFinished + Event::BatchFinished { size: 0 } ] ); }); @@ -910,7 +796,10 @@ mod on_idle { assert_eq!( fast_unstake_events_since_last_call(), - vec![Event::Slashed { stash: 100, amount: Deposit::get() }, Event::BatchFinished] + vec![ + Event::Slashed { stash: 100, amount: Deposit::get() }, + Event::BatchFinished { size: 0 } + ] ); }); } @@ -946,7 +835,7 @@ mod on_idle { vec![ Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::Unstaked { stash: 42, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 1 } ] ); }); @@ -1001,7 +890,7 @@ mod batched { Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 5, result: Ok(()) }, Event::Unstaked { stash: 7, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 3 } ] ); }); @@ -1067,7 +956,7 @@ mod batched { Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 5, result: Ok(()) }, Event::Unstaked { stash: 7, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 3 } ] ); }); @@ -1132,7 +1021,7 @@ mod batched { Event::BatchChecked { eras: vec![1, 0] }, Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 3, result: Ok(()) }, - Event::BatchFinished + Event::BatchFinished { size: 2 } ] ); }); @@ -1191,10 +1080,32 @@ mod batched { Event::Slashed { stash: 666, amount: Deposit::get() }, Event::BatchChecked { eras: vec![3] }, Event::Slashed { stash: 667, amount: Deposit::get() }, - Event::BatchFinished, + Event::BatchFinished { size: 0 }, Event::BatchChecked { eras: vec![3] } ] ); }); } } + +#[test] +fn kusama_estimate() { + use crate::WeightInfo; + let block_time = frame_support::weights::Weight::from_ref_time( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2, + ) + .ref_time() as f32; + let on_idle = crate::weights::SubstrateWeight::::on_idle_check(1000, 64).ref_time() as f32; + dbg!(block_time, on_idle, on_idle / block_time); +} + +#[test] +fn polkadot_estimate() { + use crate::WeightInfo; + let block_time = frame_support::weights::Weight::from_ref_time( + frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2, + ) + .ref_time() as f32; + let on_idle = crate::weights::SubstrateWeight::::on_idle_check(300, 64).ref_time() as f32; + dbg!(block_time, on_idle, on_idle / block_time); +} diff --git a/frame/fast-unstake/src/weights.rs b/frame/fast-unstake/src/weights.rs index 6001250e8c..f7d0cacba0 100644 --- a/frame/fast-unstake/src/weights.rs +++ b/frame/fast-unstake/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,24 +18,25 @@ //! Autogenerated weights for pallet_fast_unstake //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/production/substrate // benchmark // pallet -// --chain=dev // --steps=50 // --repeat=20 -// --pallet=pallet_fast_unstake // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/fast-unstake/src/weights.rs +// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json +// --pallet=pallet_fast_unstake +// --chain=dev // --header=./HEADER-APACHE2 +// --output=./frame/fast-unstake/src/weights.rs // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -47,8 +48,8 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_fast_unstake. pub trait WeightInfo { - fn on_idle_unstake() -> Weight; - fn on_idle_check(x: u32, ) -> Weight; + fn on_idle_unstake(b: u32, ) -> Weight; + fn on_idle_check(v: u32, b: u32, ) -> Weight; fn register_fast_unstake() -> Weight; fn deregister() -> Weight; fn control() -> Weight; @@ -59,8 +60,9 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: FastUnstake Head (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) // Storage: Staking Bonded (r:1 w:1) @@ -70,29 +72,36 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Ledger (r:0 w:1) // Storage: Staking Payee (r:0 w:1) - fn on_idle_unstake() -> Weight { - // Minimum execution time: 82_426 nanoseconds. - Weight::from_ref_time(83_422_000 as u64) - .saturating_add(T::DbWeight::get().reads(11 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + /// The range of component `b` is `[1, 64]`. + fn on_idle_unstake(b: u32, ) -> Weight { + // Minimum execution time: 92_833 nanoseconds. + Weight::from_ref_time(62_136_346) + // Standard Error: 25_541 + .saturating_add(Weight::from_ref_time(42_904_859).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(b.into()))) + .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(b.into()))) } // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: FastUnstake Head (r:1 w:1) - // Storage: FastUnstake Queue (r:2 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasStakers (r:1344 w:0) - /// The range of component `x` is `[672, 86016]`. - fn on_idle_check(x: u32, ) -> Weight { - // Minimum execution time: 13_932_777 nanoseconds. - Weight::from_ref_time(13_996_029_000 as u64) - // Standard Error: 16_878 - .saturating_add(Weight::from_ref_time(18_113_540 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(345 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Storage: Staking ErasStakers (r:2 w:0) + /// The range of component `v` is `[1, 256]`. + /// The range of component `b` is `[1, 64]`. + fn on_idle_check(v: u32, b: u32, ) -> Weight { + // Minimum execution time: 1_775_293 nanoseconds. + Weight::from_ref_time(1_787_133_000) + // Standard Error: 17_109_142 + .saturating_add(Weight::from_ref_time(546_766_552).saturating_mul(v.into())) + // Standard Error: 68_455_625 + .saturating_add(Weight::from_ref_time(2_135_980_830).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -109,10 +118,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:1) fn register_fast_unstake() -> Weight { - // Minimum execution time: 120_190 nanoseconds. - Weight::from_ref_time(121_337_000 as u64) - .saturating_add(T::DbWeight::get().reads(14 as u64)) - .saturating_add(T::DbWeight::get().writes(9 as u64)) + // Minimum execution time: 124_849 nanoseconds. + Weight::from_ref_time(128_176_000) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(9)) } // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -120,16 +129,16 @@ impl WeightInfo for SubstrateWeight { // Storage: FastUnstake Head (r:1 w:0) // Storage: FastUnstake CounterForQueue (r:1 w:1) fn deregister() -> Weight { - // Minimum execution time: 49_897 nanoseconds. - Weight::from_ref_time(50_080_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 48_246 nanoseconds. + Weight::from_ref_time(49_720_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) fn control() -> Weight { - // Minimum execution time: 4_814 nanoseconds. - Weight::from_ref_time(4_997_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 4_611 nanoseconds. + Weight::from_ref_time(4_844_000) + .saturating_add(T::DbWeight::get().writes(1)) } } @@ -137,8 +146,9 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: FastUnstake Head (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0) // Storage: Staking Bonded (r:1 w:1) @@ -148,29 +158,36 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Ledger (r:0 w:1) // Storage: Staking Payee (r:0 w:1) - fn on_idle_unstake() -> Weight { - // Minimum execution time: 82_426 nanoseconds. - Weight::from_ref_time(83_422_000 as u64) - .saturating_add(RocksDbWeight::get().reads(11 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) + /// The range of component `b` is `[1, 64]`. + fn on_idle_unstake(b: u32, ) -> Weight { + // Minimum execution time: 92_833 nanoseconds. + Weight::from_ref_time(62_136_346) + // Standard Error: 25_541 + .saturating_add(Weight::from_ref_time(42_904_859).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(b.into()))) + .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(b.into()))) } // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: FastUnstake Head (r:1 w:1) - // Storage: FastUnstake Queue (r:2 w:1) - // Storage: FastUnstake CounterForQueue (r:1 w:1) + // Storage: FastUnstake CounterForQueue (r:1 w:0) + // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasStakers (r:1344 w:0) - /// The range of component `x` is `[672, 86016]`. - fn on_idle_check(x: u32, ) -> Weight { - // Minimum execution time: 13_932_777 nanoseconds. - Weight::from_ref_time(13_996_029_000 as u64) - // Standard Error: 16_878 - .saturating_add(Weight::from_ref_time(18_113_540 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(345 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64))) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Storage: Staking ErasStakers (r:2 w:0) + /// The range of component `v` is `[1, 256]`. + /// The range of component `b` is `[1, 64]`. + fn on_idle_check(v: u32, b: u32, ) -> Weight { + // Minimum execution time: 1_775_293 nanoseconds. + Weight::from_ref_time(1_787_133_000) + // Standard Error: 17_109_142 + .saturating_add(Weight::from_ref_time(546_766_552).saturating_mul(v.into())) + // Standard Error: 68_455_625 + .saturating_add(Weight::from_ref_time(2_135_980_830).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking Ledger (r:1 w:1) @@ -187,10 +204,10 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:1) fn register_fast_unstake() -> Weight { - // Minimum execution time: 120_190 nanoseconds. - Weight::from_ref_time(121_337_000 as u64) - .saturating_add(RocksDbWeight::get().reads(14 as u64)) - .saturating_add(RocksDbWeight::get().writes(9 as u64)) + // Minimum execution time: 124_849 nanoseconds. + Weight::from_ref_time(128_176_000) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(9)) } // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: Staking Ledger (r:1 w:0) @@ -198,15 +215,15 @@ impl WeightInfo for () { // Storage: FastUnstake Head (r:1 w:0) // Storage: FastUnstake CounterForQueue (r:1 w:1) fn deregister() -> Weight { - // Minimum execution time: 49_897 nanoseconds. - Weight::from_ref_time(50_080_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 48_246 nanoseconds. + Weight::from_ref_time(49_720_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) fn control() -> Weight { - // Minimum execution time: 4_814 nanoseconds. - Weight::from_ref_time(4_997_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Minimum execution time: 4_611 nanoseconds. + Weight::from_ref_time(4_844_000) + .saturating_add(RocksDbWeight::get().writes(1)) } } From 9db957cea255802d50231347ebef393d0707b909 Mon Sep 17 00:00:00 2001 From: Koute Date: Thu, 26 Jan 2023 14:38:00 +0900 Subject: [PATCH 56/80] Rework the trie cache (#12982) * Rework the trie cache * Align `state-machine` tests * Bump `schnellru` to 0.1.1 * Fix off-by-one * Align to review comments * Bump `ahash` to 0.8.2 * Bump `schnellru` to 0.2.0 * Bump `schnellru` to 0.2.1 * Remove unnecessary bound * Remove unnecessary loop when calculating maximum memory usage * Remove unnecessary `mut`s --- Cargo.lock | 8 +- client/db/src/bench.rs | 2 +- client/db/src/lib.rs | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/network-gossip/Cargo.toml | 2 +- primitives/state-machine/src/trie_backend.rs | 20 +- primitives/trie/Cargo.toml | 6 +- primitives/trie/src/cache/mod.rs | 576 ++++++++--- primitives/trie/src/cache/shared_cache.rs | 948 +++++++++++-------- 9 files changed, 1016 insertions(+), 550 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 53e5d4882b..7c412030d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8383,7 +8383,7 @@ dependencies = [ name = "sc-finality-grandpa" version = "0.10.0-dev" dependencies = [ - "ahash 0.7.6", + "ahash 0.8.2", "array-bytes", "assert_matches", "async-trait", @@ -8583,7 +8583,7 @@ dependencies = [ name = "sc-network-gossip" version = "0.10.0-dev" dependencies = [ - "ahash 0.7.6", + "ahash 0.8.2", "futures", "futures-timer", "libp2p", @@ -10352,18 +10352,18 @@ dependencies = [ name = "sp-trie" version = "7.0.0" dependencies = [ - "ahash 0.7.6", + "ahash 0.8.2", "array-bytes", "criterion", "hash-db", "hashbrown 0.12.3", "lazy_static", - "lru", "memory-db", "nohash-hasher", "parity-scale-codec", "parking_lot 0.12.1", "scale-info", + "schnellru", "sp-core", "sp-runtime", "sp-std", diff --git a/client/db/src/bench.rs b/client/db/src/bench.rs index 13d91fff0b..e53209f277 100644 --- a/client/db/src/bench.rs +++ b/client/db/src/bench.rs @@ -110,7 +110,7 @@ impl BenchmarkingState { proof_recorder_root: Cell::new(root), enable_tracking, // Enable the cache, but do not sync anything to the shared state. - shared_trie_cache: SharedTrieCache::new(CacheSize::Maximum(0)), + shared_trie_cache: SharedTrieCache::new(CacheSize::new(0)), }; state.add_whitelist_to_tracker(); diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 09ccfef1cc..f217eb6480 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -1243,7 +1243,7 @@ impl Backend { blocks_pruning: config.blocks_pruning, genesis_state: RwLock::new(None), shared_trie_cache: config.trie_cache_maximum_size.map(|maximum_size| { - SharedTrieCache::new(sp_trie::cache::CacheSize::Maximum(maximum_size)) + SharedTrieCache::new(sp_trie::cache::CacheSize::new(maximum_size)) }), }; diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 9a31a1d4bf..8a4e0449f2 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -ahash = "0.7.6" +ahash = "0.8.2" array-bytes = "4.1" async-trait = "0.1.57" dyn-clone = "1.0" diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index ef23062768..7811e86c09 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -14,7 +14,7 @@ readme = "README.md" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -ahash = "0.7.6" +ahash = "0.8.2" futures = "0.3.21" futures-timer = "3.0.1" libp2p = "0.50.0" diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index da4250b6ba..ff5cce24c5 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -412,19 +412,19 @@ pub mod tests { fn $name() { let parameters = vec![ (StateVersion::V0, None, None), - (StateVersion::V0, Some(SharedCache::new(CacheSize::Unlimited)), None), + (StateVersion::V0, Some(SharedCache::new(CacheSize::unlimited())), None), (StateVersion::V0, None, Some(Recorder::default())), ( StateVersion::V0, - Some(SharedCache::new(CacheSize::Unlimited)), + Some(SharedCache::new(CacheSize::unlimited())), Some(Recorder::default()), ), (StateVersion::V1, None, None), - (StateVersion::V1, Some(SharedCache::new(CacheSize::Unlimited)), None), + (StateVersion::V1, Some(SharedCache::new(CacheSize::unlimited())), None), (StateVersion::V1, None, Some(Recorder::default())), ( StateVersion::V1, - Some(SharedCache::new(CacheSize::Unlimited)), + Some(SharedCache::new(CacheSize::unlimited())), Some(Recorder::default()), ), ]; @@ -760,7 +760,7 @@ pub mod tests { .clone() .for_each(|i| assert_eq!(trie.storage(&[i]).unwrap().unwrap(), vec![i; size_content])); - for cache in [Some(SharedTrieCache::new(CacheSize::Unlimited)), None] { + for cache in [Some(SharedTrieCache::new(CacheSize::unlimited())), None] { // Run multiple times to have a different cache conditions. for i in 0..5 { if let Some(cache) = &cache { @@ -793,7 +793,7 @@ pub mod tests { proof_record_works_with_iter_inner(StateVersion::V1); } fn proof_record_works_with_iter_inner(state_version: StateVersion) { - for cache in [Some(SharedTrieCache::new(CacheSize::Unlimited)), None] { + for cache in [Some(SharedTrieCache::new(CacheSize::unlimited())), None] { // Run multiple times to have a different cache conditions. for i in 0..5 { if let Some(cache) = &cache { @@ -870,7 +870,7 @@ pub mod tests { assert_eq!(in_memory.child_storage(child_info_2, &[i]).unwrap().unwrap(), vec![i]) }); - for cache in [Some(SharedTrieCache::new(CacheSize::Unlimited)), None] { + for cache in [Some(SharedTrieCache::new(CacheSize::unlimited())), None] { // Run multiple times to have a different cache conditions. for i in 0..5 { eprintln!("Running with cache {}, iteration {}", cache.is_some(), i); @@ -1002,7 +1002,7 @@ pub mod tests { nodes }; - let cache = SharedTrieCache::::new(CacheSize::Unlimited); + let cache = SharedTrieCache::::new(CacheSize::unlimited()); { let local_cache = cache.local_cache(); let mut trie_cache = local_cache.as_trie_db_cache(child_1_root); @@ -1093,7 +1093,7 @@ pub mod tests { #[test] fn new_data_is_added_to_the_cache() { - let shared_cache = SharedTrieCache::new(CacheSize::Unlimited); + let shared_cache = SharedTrieCache::new(CacheSize::unlimited()); let new_data = vec![ (&b"new_data0"[..], Some(&b"0"[..])), (&b"new_data1"[..], Some(&b"1"[..])), @@ -1159,7 +1159,7 @@ pub mod tests { assert_eq!(in_memory.child_storage(child_info_1, &key).unwrap().unwrap(), child_trie_1_val); assert_eq!(in_memory.child_storage(child_info_2, &key).unwrap().unwrap(), child_trie_2_val); - for cache in [Some(SharedTrieCache::new(CacheSize::Unlimited)), None] { + for cache in [Some(SharedTrieCache::new(CacheSize::unlimited())), None] { // Run multiple times to have a different cache conditions. for i in 0..5 { eprintln!("Running with cache {}, iteration {}", cache.is_some(), i); diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 3f045a1cb2..78b0b5d1bb 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -18,12 +18,11 @@ name = "bench" harness = false [dependencies] -ahash = { version = "0.7.6", optional = true } +ahash = { version = "0.8.2", optional = true } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } hashbrown = { version = "0.12.3", optional = true } hash-db = { version = "0.15.2", default-features = false } lazy_static = { version = "1.4.0", optional = true } -lru = { version = "0.8.1", optional = true } memory-db = { version = "0.31.0", default-features = false } nohash-hasher = { version = "0.2.0", optional = true } parking_lot = { version = "0.12.1", optional = true } @@ -34,6 +33,7 @@ trie-db = { version = "0.24.0", default-features = false } trie-root = { version = "0.17.0", default-features = false } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-std = { version = "5.0.0", default-features = false, path = "../std" } +schnellru = { version = "0.2.1", optional = true } [dev-dependencies] array-bytes = "4.1" @@ -50,7 +50,7 @@ std = [ "hashbrown", "hash-db/std", "lazy_static", - "lru", + "schnellru", "memory-db/std", "nohash-hasher", "parking_lot", diff --git a/primitives/trie/src/cache/mod.rs b/primitives/trie/src/cache/mod.rs index 85539cf626..3c1e5b8d0f 100644 --- a/primitives/trie/src/cache/mod.rs +++ b/primitives/trie/src/cache/mod.rs @@ -36,13 +36,17 @@ use crate::{Error, NodeCodec}; use hash_db::Hasher; -use hashbrown::HashSet; use nohash_hasher::BuildNoHashHasher; -use parking_lot::{Mutex, MutexGuard, RwLockReadGuard}; -use shared_cache::{SharedValueCache, ValueCacheKey}; +use parking_lot::{Mutex, MutexGuard}; +use schnellru::LruMap; +use shared_cache::{ValueCacheKey, ValueCacheRef}; use std::{ - collections::{hash_map::Entry as MapEntry, HashMap}, - sync::Arc, + collections::HashMap, + sync::{ + atomic::{AtomicU64, Ordering}, + Arc, + }, + time::Duration, }; use trie_db::{node::NodeOwned, CachedValue}; @@ -50,29 +54,267 @@ mod shared_cache; pub use shared_cache::SharedTrieCache; -use self::shared_cache::{SharedTrieCacheInner, ValueCacheKeyHash}; +use self::shared_cache::ValueCacheKeyHash; const LOG_TARGET: &str = "trie-cache"; -/// The size of the cache. +/// The maximum amount of time we'll wait trying to acquire the shared cache lock +/// when the local cache is dropped and synchronized with the share cache. +/// +/// This is just a failsafe; normally this should never trigger. +const SHARED_CACHE_WRITE_LOCK_TIMEOUT: Duration = Duration::from_millis(100); + +/// The maximum number of existing keys in the shared cache that a single local cache +/// can promote to the front of the LRU cache in one go. +/// +/// If we have a big shared cache and the local cache hits all of those keys we don't +/// want to spend forever bumping all of them. +const SHARED_NODE_CACHE_MAX_PROMOTED_KEYS: u32 = 1792; +/// Same as [`SHARED_NODE_CACHE_MAX_PROMOTED_KEYS`]. +const SHARED_VALUE_CACHE_MAX_PROMOTED_KEYS: u32 = 1792; + +/// The maximum portion of the shared cache (in percent) that a single local +/// cache can replace in one go. +/// +/// We don't want a single local cache instance to have the ability to replace +/// everything in the shared cache. +const SHARED_NODE_CACHE_MAX_REPLACE_PERCENT: usize = 33; +/// Same as [`SHARED_NODE_CACHE_MAX_REPLACE_PERCENT`]. +const SHARED_VALUE_CACHE_MAX_REPLACE_PERCENT: usize = 33; + +/// The maximum inline capacity of the local cache, in bytes. +/// +/// This is just an upper limit; since the maps are resized in powers of two +/// their actual size will most likely not exactly match this. +const LOCAL_NODE_CACHE_MAX_INLINE_SIZE: usize = 512 * 1024; +/// Same as [`LOCAL_NODE_CACHE_MAX_INLINE_SIZE`]. +const LOCAL_VALUE_CACHE_MAX_INLINE_SIZE: usize = 512 * 1024; + +/// The maximum size of the memory allocated on the heap by the local cache, in bytes. +const LOCAL_NODE_CACHE_MAX_HEAP_SIZE: usize = 2 * 1024 * 1024; +/// Same as [`LOCAL_NODE_CACHE_MAX_HEAP_SIZE`]. +const LOCAL_VALUE_CACHE_MAX_HEAP_SIZE: usize = 4 * 1024 * 1024; + +/// The size of the shared cache. #[derive(Debug, Clone, Copy)] -pub enum CacheSize { - /// Do not limit the cache size. - Unlimited, - /// Let the cache in maximum use the given amount of bytes. - Maximum(usize), -} +pub struct CacheSize(usize); impl CacheSize { - /// Returns `true` if the `current_size` exceeds the allowed size. - fn exceeds(&self, current_size: usize) -> bool { - match self { - Self::Unlimited => false, - Self::Maximum(max) => *max < current_size, + /// An unlimited cache size. + pub const fn unlimited() -> Self { + CacheSize(usize::MAX) + } + + /// A cache size `bytes` big. + pub const fn new(bytes: usize) -> Self { + CacheSize(bytes) + } +} + +/// A limiter for the local node cache. This makes sure the local cache doesn't grow too big. +#[derive(Default)] +pub struct LocalNodeCacheLimiter { + /// The current size (in bytes) of data allocated by this cache on the heap. + /// + /// This doesn't include the size of the map itself. + current_heap_size: usize, +} + +impl schnellru::Limiter> for LocalNodeCacheLimiter +where + H: AsRef<[u8]> + std::fmt::Debug, +{ + type KeyToInsert<'a> = H; + type LinkType = u32; + + #[inline] + fn is_over_the_limit(&self, length: usize) -> bool { + // Only enforce the limit if there's more than one element to make sure + // we can always add a new element to the cache. + if length <= 1 { + return false } + + self.current_heap_size > LOCAL_NODE_CACHE_MAX_HEAP_SIZE + } + + #[inline] + fn on_insert<'a>( + &mut self, + _length: usize, + key: H, + cached_node: NodeCached, + ) -> Option<(H, NodeCached)> { + self.current_heap_size += cached_node.heap_size(); + Some((key, cached_node)) + } + + #[inline] + fn on_replace( + &mut self, + _length: usize, + _old_key: &mut H, + _new_key: H, + old_node: &mut NodeCached, + new_node: &mut NodeCached, + ) -> bool { + debug_assert_eq!(_old_key.as_ref().len(), _new_key.as_ref().len()); + self.current_heap_size = + self.current_heap_size + new_node.heap_size() - old_node.heap_size(); + true + } + + #[inline] + fn on_removed(&mut self, _key: &mut H, cached_node: &mut NodeCached) { + self.current_heap_size -= cached_node.heap_size(); + } + + #[inline] + fn on_cleared(&mut self) { + self.current_heap_size = 0; + } + + #[inline] + fn on_grow(&mut self, new_memory_usage: usize) -> bool { + new_memory_usage <= LOCAL_NODE_CACHE_MAX_INLINE_SIZE + } +} + +/// A limiter for the local value cache. This makes sure the local cache doesn't grow too big. +#[derive(Default)] +pub struct LocalValueCacheLimiter { + /// The current size (in bytes) of data allocated by this cache on the heap. + /// + /// This doesn't include the size of the map itself. + current_heap_size: usize, +} + +impl schnellru::Limiter, CachedValue> for LocalValueCacheLimiter +where + H: AsRef<[u8]>, +{ + type KeyToInsert<'a> = ValueCacheRef<'a, H>; + type LinkType = u32; + + #[inline] + fn is_over_the_limit(&self, length: usize) -> bool { + // Only enforce the limit if there's more than one element to make sure + // we can always add a new element to the cache. + if length <= 1 { + return false + } + + self.current_heap_size > LOCAL_VALUE_CACHE_MAX_HEAP_SIZE + } + + #[inline] + fn on_insert( + &mut self, + _length: usize, + key: Self::KeyToInsert<'_>, + value: CachedValue, + ) -> Option<(ValueCacheKey, CachedValue)> { + self.current_heap_size += key.storage_key.len(); + Some((key.into(), value)) + } + + #[inline] + fn on_replace( + &mut self, + _length: usize, + _old_key: &mut ValueCacheKey, + _new_key: ValueCacheRef, + _old_value: &mut CachedValue, + _new_value: &mut CachedValue, + ) -> bool { + debug_assert_eq!(_old_key.storage_key.len(), _new_key.storage_key.len()); + true + } + + #[inline] + fn on_removed(&mut self, key: &mut ValueCacheKey, _: &mut CachedValue) { + self.current_heap_size -= key.storage_key.len(); + } + + #[inline] + fn on_cleared(&mut self) { + self.current_heap_size = 0; + } + + #[inline] + fn on_grow(&mut self, new_memory_usage: usize) -> bool { + new_memory_usage <= LOCAL_VALUE_CACHE_MAX_INLINE_SIZE + } +} + +/// A struct to gather hit/miss stats to aid in debugging the performance of the cache. +#[derive(Default)] +struct HitStats { + shared_hits: AtomicU64, + shared_fetch_attempts: AtomicU64, + local_hits: AtomicU64, + local_fetch_attempts: AtomicU64, +} + +impl std::fmt::Display for HitStats { + fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { + let shared_hits = self.shared_hits.load(Ordering::Relaxed); + let shared_fetch_attempts = self.shared_fetch_attempts.load(Ordering::Relaxed); + let local_hits = self.local_hits.load(Ordering::Relaxed); + let local_fetch_attempts = self.local_fetch_attempts.load(Ordering::Relaxed); + if shared_fetch_attempts == 0 && local_hits == 0 { + write!(fmt, "empty") + } else { + let percent_local = (local_hits as f32 / local_fetch_attempts as f32) * 100.0; + let percent_shared = (shared_hits as f32 / shared_fetch_attempts as f32) * 100.0; + write!( + fmt, + "local hit rate = {}% [{}/{}], shared hit rate = {}% [{}/{}]", + percent_local as u32, + local_hits, + local_fetch_attempts, + percent_shared as u32, + shared_hits, + shared_fetch_attempts + ) + } + } +} + +/// A struct to gather hit/miss stats for the node cache and the value cache. +#[derive(Default)] +struct TrieHitStats { + node_cache: HitStats, + value_cache: HitStats, +} + +/// An internal struct to store the cached trie nodes. +pub(crate) struct NodeCached { + /// The cached node. + pub node: NodeOwned, + /// Whether this node was fetched from the shared cache or not. + pub is_from_shared_cache: bool, +} + +impl NodeCached { + /// Returns the number of bytes allocated on the heap by this node. + fn heap_size(&self) -> usize { + self.node.size_in_bytes() - std::mem::size_of::>() } } +type NodeCacheMap = LruMap, LocalNodeCacheLimiter, schnellru::RandomState>; + +type ValueCacheMap = LruMap< + ValueCacheKey, + CachedValue, + LocalValueCacheLimiter, + BuildNoHashHasher>, +>; + +type ValueAccessSet = + LruMap>; + /// The local trie cache. /// /// This cache should be used per state instance created by the backend. One state instance is @@ -86,21 +328,13 @@ impl CacheSize { pub struct LocalTrieCache { /// The shared trie cache that created this instance. shared: SharedTrieCache, + /// The local cache for the trie nodes. - node_cache: Mutex>>, - /// Keeps track of all the trie nodes accessed in the shared cache. - /// - /// This will be used to ensure that these nodes are brought to the front of the lru when this - /// local instance is merged back to the shared cache. - shared_node_cache_access: Mutex>, + node_cache: Mutex>, + /// The local cache for the values. - value_cache: Mutex< - HashMap< - ValueCacheKey<'static, H::Out>, - CachedValue, - BuildNoHashHasher>, - >, - >, + value_cache: Mutex>, + /// Keeps track of all values accessed in the shared cache. /// /// This will be used to ensure that these nodes are brought to the front of the lru when this @@ -109,8 +343,9 @@ pub struct LocalTrieCache { /// as we only use this set to update the lru position it is fine, even if we bring the wrong /// value to the top. The important part is that we always get the correct value from the value /// cache for a given key. - shared_value_cache_access: - Mutex>>, + shared_value_cache_access: Mutex, + + stats: TrieHitStats, } impl LocalTrieCache { @@ -118,19 +353,18 @@ impl LocalTrieCache { /// /// The given `storage_root` needs to be the storage root of the trie this cache is used for. pub fn as_trie_db_cache(&self, storage_root: H::Out) -> TrieCache<'_, H> { - let shared_inner = self.shared.read_lock_inner(); - let value_cache = ValueCache::ForStorageRoot { storage_root, local_value_cache: self.value_cache.lock(), shared_value_cache_access: self.shared_value_cache_access.lock(), + buffered_value: None, }; TrieCache { - shared_inner, + shared_cache: self.shared.clone(), local_cache: self.node_cache.lock(), value_cache, - shared_node_cache_access: self.shared_node_cache_access.lock(), + stats: &self.stats, } } @@ -143,63 +377,89 @@ impl LocalTrieCache { /// would break because of this. pub fn as_trie_db_mut_cache(&self) -> TrieCache<'_, H> { TrieCache { - shared_inner: self.shared.read_lock_inner(), + shared_cache: self.shared.clone(), local_cache: self.node_cache.lock(), value_cache: ValueCache::Fresh(Default::default()), - shared_node_cache_access: self.shared_node_cache_access.lock(), + stats: &self.stats, } } } impl Drop for LocalTrieCache { fn drop(&mut self) { - let mut shared_inner = self.shared.write_lock_inner(); + tracing::debug!( + target: LOG_TARGET, + "Local node trie cache dropped: {}", + self.stats.node_cache + ); + + tracing::debug!( + target: LOG_TARGET, + "Local value trie cache dropped: {}", + self.stats.value_cache + ); - shared_inner - .node_cache_mut() - .update(self.node_cache.lock().drain(), self.shared_node_cache_access.lock().drain()); + let mut shared_inner = match self.shared.write_lock_inner() { + Some(inner) => inner, + None => { + tracing::warn!( + target: LOG_TARGET, + "Timeout while trying to acquire a write lock for the shared trie cache" + ); + return + }, + }; - shared_inner - .value_cache_mut() - .update(self.value_cache.lock().drain(), self.shared_value_cache_access.lock().drain()); + shared_inner.node_cache_mut().update(self.node_cache.get_mut().drain()); + + shared_inner.value_cache_mut().update( + self.value_cache.get_mut().drain(), + self.shared_value_cache_access.get_mut().drain().map(|(key, ())| key), + ); } } /// The abstraction of the value cache for the [`TrieCache`]. -enum ValueCache<'a, H> { +enum ValueCache<'a, H: Hasher> { /// The value cache is fresh, aka not yet associated to any storage root. /// This is used for example when a new trie is being build, to cache new values. - Fresh(HashMap, CachedValue>), + Fresh(HashMap, CachedValue>), /// The value cache is already bound to a specific storage root. ForStorageRoot { - shared_value_cache_access: MutexGuard< - 'a, - HashSet>, - >, - local_value_cache: MutexGuard< - 'a, - HashMap< - ValueCacheKey<'static, H>, - CachedValue, - nohash_hasher::BuildNoHashHasher>, - >, - >, - storage_root: H, + shared_value_cache_access: MutexGuard<'a, ValueAccessSet>, + local_value_cache: MutexGuard<'a, ValueCacheMap>, + storage_root: H::Out, + // The shared value cache needs to be temporarily locked when reading from it + // so we need to clone the value that is returned, but we need to be able to + // return a reference to the value, so we just buffer it here. + buffered_value: Option>, }, } -impl + std::hash::Hash + Eq + Clone + Copy> ValueCache<'_, H> { +impl ValueCache<'_, H> { /// Get the value for the given `key`. fn get<'a>( &'a mut self, key: &[u8], - shared_value_cache: &'a SharedValueCache, - ) -> Option<&CachedValue> { - match self { - Self::Fresh(map) => map.get(key), - Self::ForStorageRoot { local_value_cache, shared_value_cache_access, storage_root } => { - let key = ValueCacheKey::new_ref(key, *storage_root); + shared_cache: &SharedTrieCache, + stats: &HitStats, + ) -> Option<&CachedValue> { + stats.local_fetch_attempts.fetch_add(1, Ordering::Relaxed); + match self { + Self::Fresh(map) => + if let Some(value) = map.get(key) { + stats.local_hits.fetch_add(1, Ordering::Relaxed); + Some(value) + } else { + None + }, + Self::ForStorageRoot { + local_value_cache, + shared_value_cache_access, + storage_root, + buffered_value, + } => { // We first need to look up in the local cache and then the shared cache. // It can happen that some value is cached in the shared cache, but the // weak reference of the data can not be upgraded anymore. This for example @@ -207,35 +467,39 @@ impl + std::hash::Hash + Eq + Clone + Copy> ValueCache<'_, H> { // // So, the logic of the trie would lookup the data and the node and store both // in our local caches. - local_value_cache - .get(unsafe { - // SAFETY - // - // We need to convert the lifetime to make the compiler happy. However, as - // we only use the `key` to looking up the value this lifetime conversion is - // safe. - std::mem::transmute::<&ValueCacheKey<'_, H>, &ValueCacheKey<'static, H>>( - &key, - ) - }) - .or_else(|| { - shared_value_cache.get(&key).map(|v| { - shared_value_cache_access.insert(key.get_hash()); - v - }) - }) + + let hash = ValueCacheKey::hash_data(key, storage_root); + + if let Some(value) = local_value_cache + .peek_by_hash(hash.raw(), |existing_key, _| { + existing_key.is_eq(storage_root, key) + }) { + stats.local_hits.fetch_add(1, Ordering::Relaxed); + + return Some(value) + } + + stats.shared_fetch_attempts.fetch_add(1, Ordering::Relaxed); + if let Some(value) = shared_cache.peek_value_by_hash(hash, storage_root, key) { + stats.shared_hits.fetch_add(1, Ordering::Relaxed); + shared_value_cache_access.insert(hash, ()); + *buffered_value = Some(value.clone()); + return buffered_value.as_ref() + } + + None }, } } /// Insert some new `value` under the given `key`. - fn insert(&mut self, key: &[u8], value: CachedValue) { + fn insert(&mut self, key: &[u8], value: CachedValue) { match self { Self::Fresh(map) => { map.insert(key.into(), value); }, Self::ForStorageRoot { local_value_cache, storage_root, .. } => { - local_value_cache.insert(ValueCacheKey::new_value(key, *storage_root), value); + local_value_cache.insert(ValueCacheRef::new(key, *storage_root), value); }, } } @@ -247,10 +511,10 @@ impl + std::hash::Hash + Eq + Clone + Copy> ValueCache<'_, H> { /// be merged back into the [`LocalTrieCache`] with [`Self::merge_into`] after all operations are /// done. pub struct TrieCache<'a, H: Hasher> { - shared_inner: RwLockReadGuard<'a, SharedTrieCacheInner>, - shared_node_cache_access: MutexGuard<'a, HashSet>, - local_cache: MutexGuard<'a, HashMap>>, - value_cache: ValueCache<'a, H::Out>, + shared_cache: SharedTrieCache, + local_cache: MutexGuard<'a, NodeCacheMap>, + value_cache: ValueCache<'a, H>, + stats: &'a TrieHitStats, } impl<'a, H: Hasher> TrieCache<'a, H> { @@ -267,16 +531,11 @@ impl<'a, H: Hasher> TrieCache<'a, H> { let mut value_cache = local.value_cache.lock(); let partial_hash = ValueCacheKey::hash_partial_data(&storage_root); - cache - .into_iter() - .map(|(k, v)| { - let hash = - ValueCacheKeyHash::from_hasher_and_storage_key(partial_hash.clone(), &k); - (ValueCacheKey::Value { storage_key: k, storage_root, hash }, v) - }) - .for_each(|(k, v)| { - value_cache.insert(k, v); - }); + cache.into_iter().for_each(|(k, v)| { + let hash = ValueCacheKeyHash::from_hasher_and_storage_key(partial_hash.clone(), &k); + let k = ValueCacheRef { storage_root, storage_key: &k, hash }; + value_cache.insert(k, v); + }); } } } @@ -287,53 +546,85 @@ impl<'a, H: Hasher> trie_db::TrieCache> for TrieCache<'a, H> { hash: H::Out, fetch_node: &mut dyn FnMut() -> trie_db::Result, H::Out, Error>, ) -> trie_db::Result<&NodeOwned, H::Out, Error> { - if let Some(res) = self.shared_inner.node_cache().get(&hash) { - tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from shared cache"); - self.shared_node_cache_access.insert(hash); - return Ok(res) - } + let mut is_local_cache_hit = true; + self.stats.node_cache.local_fetch_attempts.fetch_add(1, Ordering::Relaxed); - match self.local_cache.entry(hash) { - MapEntry::Occupied(res) => { - tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from local cache"); - Ok(res.into_mut()) - }, - MapEntry::Vacant(vacant) => { - let node = (*fetch_node)(); + // First try to grab the node from the local cache. + let node = self.local_cache.get_or_insert_fallible(hash, || { + is_local_cache_hit = false; - tracing::trace!( - target: LOG_TARGET, - ?hash, - fetch_successful = node.is_ok(), - "Node not found, needed to fetch it." - ); + // It was not in the local cache; try the shared cache. + self.stats.node_cache.shared_fetch_attempts.fetch_add(1, Ordering::Relaxed); + if let Some(node) = self.shared_cache.peek_node(&hash) { + self.stats.node_cache.shared_hits.fetch_add(1, Ordering::Relaxed); + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from shared cache"); - Ok(vacant.insert(node?)) - }, + return Ok(NodeCached:: { node: node.clone(), is_from_shared_cache: true }) + } + + // It was not in the shared cache; try fetching it from the database. + match fetch_node() { + Ok(node) => { + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from database"); + Ok(NodeCached:: { node, is_from_shared_cache: false }) + }, + Err(error) => { + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from database failed"); + Err(error) + }, + } + }); + + if is_local_cache_hit { + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from local cache"); + self.stats.node_cache.local_hits.fetch_add(1, Ordering::Relaxed); } + + Ok(&node? + .expect("you can always insert at least one element into the local cache; qed") + .node) } fn get_node(&mut self, hash: &H::Out) -> Option<&NodeOwned> { - if let Some(node) = self.shared_inner.node_cache().get(hash) { - tracing::trace!(target: LOG_TARGET, ?hash, "Getting node from shared cache"); - self.shared_node_cache_access.insert(*hash); - return Some(node) - } + let mut is_local_cache_hit = true; + self.stats.node_cache.local_fetch_attempts.fetch_add(1, Ordering::Relaxed); - let res = self.local_cache.get(hash); + // First try to grab the node from the local cache. + let cached_node = self.local_cache.get_or_insert_fallible(*hash, || { + is_local_cache_hit = false; - tracing::trace!( - target: LOG_TARGET, - ?hash, - found = res.is_some(), - "Getting node from local cache" - ); + // It was not in the local cache; try the shared cache. + self.stats.node_cache.shared_fetch_attempts.fetch_add(1, Ordering::Relaxed); + if let Some(node) = self.shared_cache.peek_node(&hash) { + self.stats.node_cache.shared_hits.fetch_add(1, Ordering::Relaxed); + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from shared cache"); - res + Ok(NodeCached:: { node: node.clone(), is_from_shared_cache: true }) + } else { + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from cache failed"); + + Err(()) + } + }); + + if is_local_cache_hit { + tracing::trace!(target: LOG_TARGET, ?hash, "Serving node from local cache"); + self.stats.node_cache.local_hits.fetch_add(1, Ordering::Relaxed); + } + + match cached_node { + Ok(Some(cached_node)) => Some(&cached_node.node), + Ok(None) => { + unreachable!( + "you can always insert at least one element into the local cache; qed" + ); + }, + Err(()) => None, + } } fn lookup_value_for_key(&mut self, key: &[u8]) -> Option<&CachedValue> { - let res = self.value_cache.get(key, self.shared_inner.value_cache()); + let res = self.value_cache.get(key, &self.shared_cache, &self.stats.value_cache); tracing::trace!( target: LOG_TARGET, @@ -352,7 +643,7 @@ impl<'a, H: Hasher> trie_db::TrieCache> for TrieCache<'a, H> { "Caching value for key", ); - self.value_cache.insert(key.into(), data); + self.value_cache.insert(key, data); } } @@ -369,7 +660,7 @@ mod tests { const TEST_DATA: &[(&[u8], &[u8])] = &[(b"key1", b"val1"), (b"key2", &[2; 64]), (b"key3", b"val3"), (b"key4", &[4; 64])]; const CACHE_SIZE_RAW: usize = 1024 * 10; - const CACHE_SIZE: CacheSize = CacheSize::Maximum(CACHE_SIZE_RAW); + const CACHE_SIZE: CacheSize = CacheSize::new(CACHE_SIZE_RAW); fn create_trie() -> (MemoryDB, TrieHash) { let mut db = MemoryDB::default(); @@ -418,7 +709,7 @@ mod tests { let fake_data = Bytes::from(&b"fake_data"[..]); let local_cache = shared_cache.local_cache(); - shared_cache.write_lock_inner().value_cache_mut().lru.put( + shared_cache.write_lock_inner().unwrap().value_cache_mut().lru.insert( ValueCacheKey::new_value(TEST_DATA[1].0, root), (fake_data.clone(), Default::default()).into(), ); @@ -591,7 +882,7 @@ mod tests { .lru .iter() .map(|d| d.0) - .all(|l| TEST_DATA.iter().any(|d| l.storage_key().unwrap() == d.0))); + .all(|l| TEST_DATA.iter().any(|d| &*l.storage_key == d.0))); // Run this in a loop. The first time we check that with the filled value cache, // the expected values are at the top of the LRU. @@ -617,7 +908,7 @@ mod tests { .iter() .take(2) .map(|d| d.0) - .all(|l| { TEST_DATA.iter().take(2).any(|d| l.storage_key().unwrap() == d.0) })); + .all(|l| { TEST_DATA.iter().take(2).any(|d| &*l.storage_key == d.0) })); // Delete the value cache, so that we access the nodes. shared_cache.reset_value_cache(); @@ -684,9 +975,6 @@ mod tests { } } - let node_cache_size = shared_cache.read_lock_inner().node_cache().size_in_bytes; - let value_cache_size = shared_cache.read_lock_inner().value_cache().size_in_bytes; - - assert!(node_cache_size + value_cache_size < CACHE_SIZE_RAW); + assert!(shared_cache.used_memory_size() < CACHE_SIZE_RAW); } } diff --git a/primitives/trie/src/cache/shared_cache.rs b/primitives/trie/src/cache/shared_cache.rs index 9d4d36b83a..8c60d5043d 100644 --- a/primitives/trie/src/cache/shared_cache.rs +++ b/primitives/trie/src/cache/shared_cache.rs @@ -17,15 +17,14 @@ ///! Provides the [`SharedNodeCache`], the [`SharedValueCache`] and the [`SharedTrieCache`] ///! that combines both caches and is exported to the outside. -use super::{CacheSize, LOG_TARGET}; +use super::{CacheSize, NodeCached}; use hash_db::Hasher; use hashbrown::{hash_set::Entry as SetEntry, HashSet}; -use lru::LruCache; use nohash_hasher::BuildNoHashHasher; -use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +use parking_lot::{Mutex, RwLock, RwLockWriteGuard}; +use schnellru::LruMap; use std::{ hash::{BuildHasher, Hasher as _}, - mem, sync::Arc, }; use trie_db::{node::NodeOwned, CachedValue}; @@ -34,94 +33,300 @@ lazy_static::lazy_static! { static ref RANDOM_STATE: ahash::RandomState = ahash::RandomState::default(); } -/// No hashing [`LruCache`]. -type NoHashingLruCache = LruCache>; +pub struct SharedNodeCacheLimiter { + /// The maximum size (in bytes) the cache can hold inline. + /// + /// This space is always consumed whether there are any items in the map or not. + max_inline_size: usize, + + /// The maximum size (in bytes) the cache can hold on the heap. + max_heap_size: usize, + + /// The current size (in bytes) of data allocated by this cache on the heap. + /// + /// This doesn't include the size of the map itself. + heap_size: usize, + + /// A counter with the number of elements that got evicted from the cache. + /// + /// Reset to zero before every update. + items_evicted: usize, + + /// The maximum number of elements that we allow to be evicted. + /// + /// Reset on every update. + max_items_evicted: usize, +} + +impl schnellru::Limiter> for SharedNodeCacheLimiter +where + H: AsRef<[u8]>, +{ + type KeyToInsert<'a> = H; + type LinkType = u32; + + #[inline] + fn is_over_the_limit(&self, _length: usize) -> bool { + // Once we hit the limit of max items evicted this will return `false` and prevent + // any further evictions, but this is fine because the outer loop which inserts + // items into this cache will just detect this and stop inserting new items. + self.items_evicted <= self.max_items_evicted && self.heap_size > self.max_heap_size + } + + #[inline] + fn on_insert( + &mut self, + _length: usize, + key: Self::KeyToInsert<'_>, + node: NodeOwned, + ) -> Option<(H, NodeOwned)> { + let new_item_heap_size = node.size_in_bytes() - std::mem::size_of::>(); + if new_item_heap_size > self.max_heap_size { + // Item's too big to add even if the cache's empty; bail. + return None + } + + self.heap_size += new_item_heap_size; + Some((key, node)) + } + + #[inline] + fn on_replace( + &mut self, + _length: usize, + _old_key: &mut H, + _new_key: H, + old_node: &mut NodeOwned, + new_node: &mut NodeOwned, + ) -> bool { + debug_assert_eq!(_old_key.as_ref(), _new_key.as_ref()); + + let new_item_heap_size = new_node.size_in_bytes() - std::mem::size_of::>(); + if new_item_heap_size > self.max_heap_size { + // Item's too big to add even if the cache's empty; bail. + return false + } + + let old_item_heap_size = old_node.size_in_bytes() - std::mem::size_of::>(); + self.heap_size = self.heap_size - old_item_heap_size + new_item_heap_size; + true + } + + #[inline] + fn on_cleared(&mut self) { + self.heap_size = 0; + } + + #[inline] + fn on_removed(&mut self, _: &mut H, node: &mut NodeOwned) { + self.heap_size -= node.size_in_bytes() - std::mem::size_of::>(); + self.items_evicted += 1; + } + + #[inline] + fn on_grow(&mut self, new_memory_usage: usize) -> bool { + new_memory_usage <= self.max_inline_size + } +} + +pub struct SharedValueCacheLimiter { + /// The maximum size (in bytes) the cache can hold inline. + /// + /// This space is always consumed whether there are any items in the map or not. + max_inline_size: usize, + + /// The maximum size (in bytes) the cache can hold on the heap. + max_heap_size: usize, + + /// The current size (in bytes) of data allocated by this cache on the heap. + /// + /// This doesn't include the size of the map itself. + heap_size: usize, + + /// A set with all of the keys deduplicated to save on memory. + known_storage_keys: HashSet>, + + /// A counter with the number of elements that got evicted from the cache. + /// + /// Reset to zero before every update. + items_evicted: usize, + + /// The maximum number of elements that we allow to be evicted. + /// + /// Reset on every update. + max_items_evicted: usize, +} + +impl schnellru::Limiter, CachedValue> for SharedValueCacheLimiter +where + H: AsRef<[u8]>, +{ + type KeyToInsert<'a> = ValueCacheKey; + type LinkType = u32; + + #[inline] + fn is_over_the_limit(&self, _length: usize) -> bool { + self.items_evicted <= self.max_items_evicted && self.heap_size > self.max_heap_size + } + + #[inline] + fn on_insert( + &mut self, + _length: usize, + mut key: Self::KeyToInsert<'_>, + value: CachedValue, + ) -> Option<(ValueCacheKey, CachedValue)> { + match self.known_storage_keys.entry(key.storage_key.clone()) { + SetEntry::Vacant(entry) => { + let new_item_heap_size = key.storage_key.len(); + if new_item_heap_size > self.max_heap_size { + // Item's too big to add even if the cache's empty; bail. + return None + } + + self.heap_size += new_item_heap_size; + entry.insert(); + }, + SetEntry::Occupied(entry) => { + key.storage_key = entry.get().clone(); + }, + } + + Some((key, value)) + } + + #[inline] + fn on_replace( + &mut self, + _length: usize, + _old_key: &mut ValueCacheKey, + _new_key: ValueCacheKey, + _old_value: &mut CachedValue, + _new_value: &mut CachedValue, + ) -> bool { + debug_assert_eq!(_new_key.storage_key, _old_key.storage_key); + true + } + + #[inline] + fn on_removed(&mut self, key: &mut ValueCacheKey, _: &mut CachedValue) { + if Arc::strong_count(&key.storage_key) == 2 { + // There are only two instances of this key: + // 1) one memoized in `known_storage_keys`, + // 2) one inside the map. + // + // This means that after this remove goes through the `Arc` will be deallocated. + self.heap_size -= key.storage_key.len(); + self.known_storage_keys.remove(&key.storage_key); + } + self.items_evicted += 1; + } + + #[inline] + fn on_cleared(&mut self) { + self.heap_size = 0; + self.known_storage_keys.clear(); + } + + #[inline] + fn on_grow(&mut self, new_memory_usage: usize) -> bool { + new_memory_usage <= self.max_inline_size + } +} + +type SharedNodeCacheMap = + LruMap, SharedNodeCacheLimiter, schnellru::RandomState>; /// The shared node cache. /// -/// Internally this stores all cached nodes in a [`LruCache`]. It ensures that when updating the +/// Internally this stores all cached nodes in a [`LruMap`]. It ensures that when updating the /// cache, that the cache stays within its allowed bounds. -pub(super) struct SharedNodeCache { +pub(super) struct SharedNodeCache +where + H: AsRef<[u8]>, +{ /// The cached nodes, ordered by least recently used. - pub(super) lru: LruCache>, - /// The size of [`Self::lru`] in bytes. - pub(super) size_in_bytes: usize, - /// The maximum cache size of [`Self::lru`]. - maximum_cache_size: CacheSize, + pub(super) lru: SharedNodeCacheMap, } impl + Eq + std::hash::Hash> SharedNodeCache { /// Create a new instance. - fn new(cache_size: CacheSize) -> Self { - Self { lru: LruCache::unbounded(), size_in_bytes: 0, maximum_cache_size: cache_size } + fn new(max_inline_size: usize, max_heap_size: usize) -> Self { + Self { + lru: LruMap::new(SharedNodeCacheLimiter { + max_inline_size, + max_heap_size, + heap_size: 0, + items_evicted: 0, + max_items_evicted: 0, // Will be set during `update`. + }), + } } - /// Get the node for `key`. - /// - /// This doesn't change the least recently order in the internal [`LruCache`]. - pub fn get(&self, key: &H) -> Option<&NodeOwned> { - self.lru.peek(key) - } + /// Update the cache with the `list` of nodes which were either newly added or accessed. + pub fn update(&mut self, list: impl IntoIterator)>) { + let mut access_count = 0; + let mut add_count = 0; - /// Update the cache with the `added` nodes and the `accessed` nodes. - /// - /// The `added` nodes are the ones that have been collected by doing operations on the trie and - /// now should be stored in the shared cache. The `accessed` nodes are only referenced by hash - /// and represent the nodes that were retrieved from this shared cache through [`Self::get`]. - /// These `accessed` nodes are being put to the front of the internal [`LruCache`] like the - /// `added` ones. - /// - /// After the internal [`LruCache`] was updated, it is ensured that the internal [`LruCache`] is - /// inside its bounds ([`Self::maximum_size_in_bytes`]). - pub fn update( - &mut self, - added: impl IntoIterator)>, - accessed: impl IntoIterator, - ) { - let update_size_in_bytes = |size_in_bytes: &mut usize, key: &H, node: &NodeOwned| { - if let Some(new_size_in_bytes) = - size_in_bytes.checked_sub(key.as_ref().len() + node.size_in_bytes()) - { - *size_in_bytes = new_size_in_bytes; - } else { - *size_in_bytes = 0; - tracing::error!(target: LOG_TARGET, "`SharedNodeCache` underflow detected!",); - } - }; + self.lru.limiter_mut().items_evicted = 0; + self.lru.limiter_mut().max_items_evicted = + self.lru.len() * 100 / super::SHARED_NODE_CACHE_MAX_REPLACE_PERCENT; - accessed.into_iter().for_each(|key| { - // Access every node in the lru to put it to the front. - self.lru.get(&key); - }); - added.into_iter().for_each(|(key, node)| { - self.size_in_bytes += key.as_ref().len() + node.size_in_bytes(); + for (key, cached_node) in list { + if cached_node.is_from_shared_cache { + if self.lru.get(&key).is_some() { + access_count += 1; - if let Some((r_key, r_node)) = self.lru.push(key, node) { - update_size_in_bytes(&mut self.size_in_bytes, &r_key, &r_node); - } + if access_count >= super::SHARED_NODE_CACHE_MAX_PROMOTED_KEYS { + // Stop when we've promoted a large enough number of items. + break + } - // Directly ensure that we respect the maximum size. By doing it directly here we ensure - // that the internal map of the [`LruCache`] doesn't grow too much. - while self.maximum_cache_size.exceeds(self.size_in_bytes) { - // This should always be `Some(_)`, otherwise something is wrong! - if let Some((key, node)) = self.lru.pop_lru() { - update_size_in_bytes(&mut self.size_in_bytes, &key, &node); + continue } } - }); + + self.lru.insert(key, cached_node.node); + add_count += 1; + + if self.lru.limiter().items_evicted > self.lru.limiter().max_items_evicted { + // Stop when we've evicted a big enough chunk of the shared cache. + break + } + } + + tracing::debug!( + target: super::LOG_TARGET, + "Updated the shared node cache: {} accesses, {} new values, {}/{} evicted (length = {}, inline size={}/{}, heap size={}/{})", + access_count, + add_count, + self.lru.limiter().items_evicted, + self.lru.limiter().max_items_evicted, + self.lru.len(), + self.lru.memory_usage(), + self.lru.limiter().max_inline_size, + self.lru.limiter().heap_size, + self.lru.limiter().max_heap_size, + ); } /// Reset the cache. fn reset(&mut self) { - self.size_in_bytes = 0; self.lru.clear(); } } /// The hash of [`ValueCacheKey`]. -#[derive(Eq, Clone, Copy)] +#[derive(PartialEq, Eq, Clone, Copy, Hash)] +#[repr(transparent)] pub struct ValueCacheKeyHash(u64); +impl ValueCacheKeyHash { + pub fn raw(self) -> u64 { + self.0 + } +} + impl ValueCacheKeyHash { pub fn from_hasher_and_storage_key( mut hasher: impl std::hash::Hasher, @@ -133,88 +338,75 @@ impl ValueCacheKeyHash { } } -impl PartialEq for ValueCacheKeyHash { - fn eq(&self, other: &Self) -> bool { - self.0 == other.0 - } +impl nohash_hasher::IsEnabled for ValueCacheKeyHash {} + +/// The key type that is being used to address a [`CachedValue`]. +#[derive(Eq)] +pub(super) struct ValueCacheKey { + /// The storage root of the trie this key belongs to. + pub storage_root: H, + /// The key to access the value in the storage. + pub storage_key: Arc<[u8]>, + /// The hash that identifies this instance of `storage_root` and `storage_key`. + pub hash: ValueCacheKeyHash, } -impl std::hash::Hash for ValueCacheKeyHash { - fn hash(&self, state: &mut Hasher) { - state.write_u64(self.0); +/// A borrowed variant of [`ValueCacheKey`]. +pub(super) struct ValueCacheRef<'a, H> { + /// The storage root of the trie this key belongs to. + pub storage_root: H, + /// The key to access the value in the storage. + pub storage_key: &'a [u8], + /// The hash that identifies this instance of `storage_root` and `storage_key`. + pub hash: ValueCacheKeyHash, +} + +impl<'a, H> ValueCacheRef<'a, H> { + pub fn new(storage_key: &'a [u8], storage_root: H) -> Self + where + H: AsRef<[u8]>, + { + let hash = ValueCacheKey::::hash_data(&storage_key, &storage_root); + Self { storage_root, storage_key, hash } } } -impl nohash_hasher::IsEnabled for ValueCacheKeyHash {} +impl<'a, H> From> for ValueCacheKey { + fn from(value: ValueCacheRef<'a, H>) -> Self { + ValueCacheKey { + storage_root: value.storage_root, + storage_key: value.storage_key.into(), + hash: value.hash, + } + } +} -/// A type that can only be constructed inside of this file. -/// -/// It "requires" that the user has read the docs to prevent fuck ups. -#[derive(Eq, PartialEq)] -pub(super) struct IReadTheDocumentation(()); +impl<'a, H: std::hash::Hash> std::hash::Hash for ValueCacheRef<'a, H> { + fn hash(&self, state: &mut Hasher) { + self.hash.hash(state) + } +} -/// The key type that is being used to address a [`CachedValue`]. -/// -/// This type is implemented as `enum` to improve the performance when accessing the value cache. -/// The problem being that we need to calculate the `hash` of [`Self`] in worst case three times -/// when trying to find a value in the value cache. First to lookup the local cache, then the shared -/// cache and if we found it in the shared cache a third time to insert it into the list of accessed -/// values. To work around each variant stores the `hash` to identify a unique combination of -/// `storage_key` and `storage_root`. However, be aware that this `hash` can lead to collisions when -/// there are two different `storage_key` and `storage_root` pairs that map to the same `hash`. This -/// type also has the `Hash` variant. This variant should only be used for the use case of updating -/// the lru for a key. Because when using only the `Hash` variant to getting a value from a hash map -/// it could happen that a wrong value is returned when there is another key in the same hash map -/// that maps to the same `hash`. The [`PartialEq`] implementation is written in a way that when one -/// of the two compared instances is the `Hash` variant, we will only compare the hashes. This -/// ensures that we can use the `Hash` variant to bring values up in the lru. -#[derive(Eq)] -pub(super) enum ValueCacheKey<'a, H> { - /// Variant that stores the `storage_key` by value. - Value { - /// The storage root of the trie this key belongs to. - storage_root: H, - /// The key to access the value in the storage. - storage_key: Arc<[u8]>, - /// The hash that identifying this instance of `storage_root` and `storage_key`. - hash: ValueCacheKeyHash, - }, - /// Variant that only references the `storage_key`. - Ref { - /// The storage root of the trie this key belongs to. - storage_root: H, - /// The key to access the value in the storage. - storage_key: &'a [u8], - /// The hash that identifying this instance of `storage_root` and `storage_key`. - hash: ValueCacheKeyHash, - }, - /// Variant that only stores the hash that represents the `storage_root` and `storage_key`. - /// - /// This should be used by caution, because it can lead to accessing the wrong value in a - /// hash map/set when there exists two different `storage_root`s and `storage_key`s that - /// map to the same `hash`. - Hash { hash: ValueCacheKeyHash, _i_read_the_documentation: IReadTheDocumentation }, +impl<'a, H> PartialEq> for ValueCacheRef<'a, H> +where + H: AsRef<[u8]>, +{ + fn eq(&self, rhs: &ValueCacheKey) -> bool { + self.storage_root.as_ref() == rhs.storage_root.as_ref() && + self.storage_key == &*rhs.storage_key + } } -impl<'a, H> ValueCacheKey<'a, H> { +impl ValueCacheKey { /// Constructs [`Self::Value`]. + #[cfg(test)] // Only used in tests. pub fn new_value(storage_key: impl Into>, storage_root: H) -> Self where H: AsRef<[u8]>, { let storage_key = storage_key.into(); let hash = Self::hash_data(&storage_key, &storage_root); - Self::Value { storage_root, storage_key, hash } - } - - /// Constructs [`Self::Ref`]. - pub fn new_ref(storage_key: &'a [u8], storage_root: H) -> Self - where - H: AsRef<[u8]>, - { - let storage_key = storage_key.into(); - let hash = Self::hash_data(storage_key, &storage_root); - Self::Ref { storage_root, storage_key, hash } + Self { storage_root, storage_key, hash } } /// Returns a hasher prepared to build the final hash to identify [`Self`]. @@ -241,231 +433,133 @@ impl<'a, H> ValueCacheKey<'a, H> { ValueCacheKeyHash::from_hasher_and_storage_key(hasher, key) } - /// Returns the `hash` that identifies the current instance. - pub fn get_hash(&self) -> ValueCacheKeyHash { - match self { - Self::Value { hash, .. } | Self::Ref { hash, .. } | Self::Hash { hash, .. } => *hash, - } - } - - /// Returns the stored storage root. - pub fn storage_root(&self) -> Option<&H> { - match self { - Self::Value { storage_root, .. } | Self::Ref { storage_root, .. } => Some(storage_root), - Self::Hash { .. } => None, - } - } - - /// Returns the stored storage key. - pub fn storage_key(&self) -> Option<&[u8]> { - match self { - Self::Ref { storage_key, .. } => Some(&storage_key), - Self::Value { storage_key, .. } => Some(storage_key), - Self::Hash { .. } => None, - } + /// Checks whether the key is equal to the given `storage_key` and `storage_root`. + #[inline] + pub fn is_eq(&self, storage_root: &H, storage_key: &[u8]) -> bool + where + H: PartialEq, + { + self.storage_root == *storage_root && *self.storage_key == *storage_key } } -// Implement manually to ensure that the `Value` and `Hash` are treated equally. -impl std::hash::Hash for ValueCacheKey<'_, H> { +// Implement manually so that only `hash` is accessed. +impl std::hash::Hash for ValueCacheKey { fn hash(&self, state: &mut Hasher) { - self.get_hash().hash(state) + self.hash.hash(state) } } -impl nohash_hasher::IsEnabled for ValueCacheKey<'_, H> {} +impl nohash_hasher::IsEnabled for ValueCacheKey {} -// Implement manually to ensure that the `Value` and `Hash` are treated equally. -impl PartialEq for ValueCacheKey<'_, H> { +// Implement manually to not have to compare `hash`. +impl PartialEq for ValueCacheKey { + #[inline] fn eq(&self, other: &Self) -> bool { - // First check if `self` or `other` is only the `Hash`. - // Then we only compare the `hash`. So, there could actually be some collision - // if two different storage roots and keys are mapping to the same key. See the - // [`ValueCacheKey`] docs for more information. - match (self, other) { - (Self::Hash { hash, .. }, Self::Hash { hash: other_hash, .. }) => hash == other_hash, - (Self::Hash { hash, .. }, _) => *hash == other.get_hash(), - (_, Self::Hash { hash: other_hash, .. }) => self.get_hash() == *other_hash, - // If both are not the `Hash` variant, we compare all the values. - _ => - self.get_hash() == other.get_hash() && - self.storage_root() == other.storage_root() && - self.storage_key() == other.storage_key(), - } + self.is_eq(&other.storage_root, &other.storage_key) } } +type SharedValueCacheMap = schnellru::LruMap< + ValueCacheKey, + CachedValue, + SharedValueCacheLimiter, + BuildNoHashHasher>, +>; + /// The shared value cache. /// /// The cache ensures that it stays in the configured size bounds. -pub(super) struct SharedValueCache { +pub(super) struct SharedValueCache +where + H: AsRef<[u8]>, +{ /// The cached nodes, ordered by least recently used. - pub(super) lru: NoHashingLruCache, CachedValue>, - /// The size of [`Self::lru`] in bytes. - pub(super) size_in_bytes: usize, - /// The maximum cache size of [`Self::lru`]. - maximum_cache_size: CacheSize, - /// All known storage keys that are stored in [`Self::lru`]. - /// - /// This is used to de-duplicate keys in memory that use the - /// same [`SharedValueCache::storage_key`], but have a different - /// [`SharedValueCache::storage_root`]. - known_storage_keys: HashSet>, + pub(super) lru: SharedValueCacheMap, } impl> SharedValueCache { /// Create a new instance. - fn new(cache_size: CacheSize) -> Self { + fn new(max_inline_size: usize, max_heap_size: usize) -> Self { Self { - lru: NoHashingLruCache::unbounded_with_hasher(Default::default()), - size_in_bytes: 0, - maximum_cache_size: cache_size, - known_storage_keys: Default::default(), + lru: schnellru::LruMap::with_hasher( + SharedValueCacheLimiter { + max_inline_size, + max_heap_size, + heap_size: 0, + known_storage_keys: Default::default(), + items_evicted: 0, + max_items_evicted: 0, // Will be set during `update`. + }, + Default::default(), + ), } } - /// Get the [`CachedValue`] for `key`. - /// - /// This doesn't change the least recently order in the internal [`LruCache`]. - pub fn get<'a>(&'a self, key: &ValueCacheKey) -> Option<&'a CachedValue> { - debug_assert!( - !matches!(key, ValueCacheKey::Hash { .. }), - "`get` can not be called with `Hash` variant as this may returns the wrong value." - ); - - self.lru.peek(unsafe { - // SAFETY - // - // We need to convert the lifetime to make the compiler happy. However, as - // we only use the `key` to looking up the value this lifetime conversion is - // safe. - mem::transmute::<&ValueCacheKey<'_, H>, &ValueCacheKey<'static, H>>(key) - }) - } - /// Update the cache with the `added` values and the `accessed` values. /// /// The `added` values are the ones that have been collected by doing operations on the trie and /// now should be stored in the shared cache. The `accessed` values are only referenced by the - /// [`ValueCacheKeyHash`] and represent the values that were retrieved from this shared cache - /// through [`Self::get`]. These `accessed` values are being put to the front of the internal - /// [`LruCache`] like the `added` ones. - /// - /// After the internal [`LruCache`] was updated, it is ensured that the internal [`LruCache`] is - /// inside its bounds ([`Self::maximum_size_in_bytes`]). + /// [`ValueCacheKeyHash`] and represent the values that were retrieved from this shared cache. + /// These `accessed` values are being put to the front of the internal [`LruMap`] like the + /// `added` ones. pub fn update( &mut self, - added: impl IntoIterator, CachedValue)>, + added: impl IntoIterator, CachedValue)>, accessed: impl IntoIterator, ) { - // The base size in memory per ([`ValueCacheKey`], [`CachedValue`]). - let base_size = mem::size_of::>() + mem::size_of::>(); - let known_keys_entry_size = mem::size_of::>(); - - let update_size_in_bytes = - |size_in_bytes: &mut usize, r_key: Arc<[u8]>, known_keys: &mut HashSet>| { - // If the `strong_count == 2`, it means this is the last instance of the key. - // One being `r_key` and the other being stored in `known_storage_keys`. - let last_instance = Arc::strong_count(&r_key) == 2; - - let key_len = if last_instance { - known_keys.remove(&r_key); - r_key.len() + known_keys_entry_size - } else { - // The key is still in `keys`, because it is still used by another - // `ValueCacheKey`. - 0 - }; - - if let Some(new_size_in_bytes) = size_in_bytes.checked_sub(key_len + base_size) { - *size_in_bytes = new_size_in_bytes; - } else { - *size_in_bytes = 0; - tracing::error!(target: LOG_TARGET, "`SharedValueCache` underflow detected!",); - } - }; - - accessed.into_iter().for_each(|key| { - // Access every node in the lru to put it to the front. - // As we are using the `Hash` variant here, it may leads to putting the wrong value to - // the top. However, the only consequence of this is that we may prune a recently used - // value to early. - self.lru.get(&ValueCacheKey::Hash { - hash: key, - _i_read_the_documentation: IReadTheDocumentation(()), - }); - }); - - added.into_iter().for_each(|(key, value)| { - let (storage_root, storage_key, key_hash) = match key { - ValueCacheKey::Hash { .. } => { - // Ignore the hash variant and try the next. - tracing::error!( - target: LOG_TARGET, - "`SharedValueCached::update` was called with a key to add \ - that uses the `Hash` variant. This would lead to potential hash collision!", - ); - return - }, - ValueCacheKey::Ref { storage_key, storage_root, hash } => - (storage_root, storage_key.into(), hash), - ValueCacheKey::Value { storage_root, storage_key, hash } => - (storage_root, storage_key, hash), - }; - - let (size_update, storage_key) = - match self.known_storage_keys.entry(storage_key.clone()) { - SetEntry::Vacant(v) => { - let len = v.get().len(); - v.insert(); - - // If the key was unknown, we need to also take its length and the size of - // the entry of `known_keys` into account. - (len + base_size + known_keys_entry_size, storage_key) - }, - SetEntry::Occupied(o) => { - // Key is known - (base_size, o.get().clone()) - }, - }; - - self.size_in_bytes += size_update; - - if let Some((r_key, _)) = self - .lru - .push(ValueCacheKey::Value { storage_key, storage_root, hash: key_hash }, value) - { - if let ValueCacheKey::Value { storage_key, .. } = r_key { - update_size_in_bytes( - &mut self.size_in_bytes, - storage_key, - &mut self.known_storage_keys, - ); - } - } + let mut access_count = 0; + let mut add_count = 0; - // Directly ensure that we respect the maximum size. By doing it directly here we - // ensure that the internal map of the [`LruCache`] doesn't grow too much. - while self.maximum_cache_size.exceeds(self.size_in_bytes) { - // This should always be `Some(_)`, otherwise something is wrong! - if let Some((r_key, _)) = self.lru.pop_lru() { - if let ValueCacheKey::Value { storage_key, .. } = r_key { - update_size_in_bytes( - &mut self.size_in_bytes, - storage_key, - &mut self.known_storage_keys, - ); - } - } + for hash in accessed { + // Access every node in the map to put it to the front. + // + // Since we are only comparing the hashes here it may lead us to promoting the wrong + // values as the most recently accessed ones. However this is harmless as the only + // consequence is that we may accidentally prune a recently used value too early. + self.lru.get_by_hash(hash.raw(), |existing_key, _| existing_key.hash == hash); + access_count += 1; + } + + // Insert all of the new items which were *not* found in the shared cache. + // + // Limit how many items we'll replace in the shared cache in one go so that + // we don't evict the whole shared cache nor we keep spinning our wheels + // evicting items which we've added ourselves in previous iterations of this loop. + + self.lru.limiter_mut().items_evicted = 0; + self.lru.limiter_mut().max_items_evicted = + self.lru.len() * 100 / super::SHARED_VALUE_CACHE_MAX_REPLACE_PERCENT; + + for (key, value) in added { + self.lru.insert(key, value); + add_count += 1; + + if self.lru.limiter().items_evicted > self.lru.limiter().max_items_evicted { + // Stop when we've evicted a big enough chunk of the shared cache. + break } - }); + } + + tracing::debug!( + target: super::LOG_TARGET, + "Updated the shared value cache: {} accesses, {} new values, {}/{} evicted (length = {}, known_storage_keys = {}, inline size={}/{}, heap size={}/{})", + access_count, + add_count, + self.lru.limiter().items_evicted, + self.lru.limiter().max_items_evicted, + self.lru.len(), + self.lru.limiter().known_storage_keys.len(), + self.lru.memory_usage(), + self.lru.limiter().max_inline_size, + self.lru.limiter().heap_size, + self.lru.limiter().max_heap_size + ); } /// Reset the cache. fn reset(&mut self) { - self.size_in_bytes = 0; self.lru.clear(); - self.known_storage_keys.clear(); } } @@ -477,6 +571,7 @@ pub(super) struct SharedTrieCacheInner { impl SharedTrieCacheInner { /// Returns a reference to the [`SharedValueCache`]. + #[cfg(test)] pub(super) fn value_cache(&self) -> &SharedValueCache { &self.value_cache } @@ -487,6 +582,7 @@ impl SharedTrieCacheInner { } /// Returns a reference to the [`SharedNodeCache`]. + #[cfg(test)] pub(super) fn node_cache(&self) -> &SharedNodeCache { &self.node_cache } @@ -517,23 +613,50 @@ impl Clone for SharedTrieCache { impl SharedTrieCache { /// Create a new [`SharedTrieCache`]. pub fn new(cache_size: CacheSize) -> Self { - let (node_cache_size, value_cache_size) = match cache_size { - CacheSize::Maximum(max) => { - // Allocate 20% for the value cache. - let value_cache_size_in_bytes = (max as f32 * 0.20) as usize; - - ( - CacheSize::Maximum(max - value_cache_size_in_bytes), - CacheSize::Maximum(value_cache_size_in_bytes), - ) - }, - CacheSize::Unlimited => (CacheSize::Unlimited, CacheSize::Unlimited), - }; + let total_budget = cache_size.0; + + // Split our memory budget between the two types of caches. + let value_cache_budget = (total_budget as f32 * 0.20) as usize; // 20% for the value cache + let node_cache_budget = total_budget - value_cache_budget; // 80% for the node cache + + // Split our memory budget between what we'll be holding inline in the map, + // and what we'll be holding on the heap. + let value_cache_inline_budget = (value_cache_budget as f32 * 0.70) as usize; + let node_cache_inline_budget = (node_cache_budget as f32 * 0.70) as usize; + + // Calculate how much memory the maps will be allowed to hold inline given our budget. + let value_cache_max_inline_size = + SharedValueCacheMap::::memory_usage_for_memory_budget( + value_cache_inline_budget, + ); + + let node_cache_max_inline_size = + SharedNodeCacheMap::::memory_usage_for_memory_budget(node_cache_inline_budget); + + // And this is how much data we'll at most keep on the heap for each cache. + let value_cache_max_heap_size = value_cache_budget - value_cache_max_inline_size; + let node_cache_max_heap_size = node_cache_budget - node_cache_max_inline_size; + + tracing::debug!( + target: super::LOG_TARGET, + "Configured a shared trie cache with a budget of ~{} bytes (node_cache_max_inline_size = {}, node_cache_max_heap_size = {}, value_cache_max_inline_size = {}, value_cache_max_heap_size = {})", + total_budget, + node_cache_max_inline_size, + node_cache_max_heap_size, + value_cache_max_inline_size, + value_cache_max_heap_size, + ); Self { inner: Arc::new(RwLock::new(SharedTrieCacheInner { - node_cache: SharedNodeCache::new(node_cache_size), - value_cache: SharedValueCache::new(value_cache_size), + node_cache: SharedNodeCache::new( + node_cache_max_inline_size, + node_cache_max_heap_size, + ), + value_cache: SharedValueCache::new( + value_cache_max_inline_size, + value_cache_max_heap_size, + ), })), } } @@ -544,16 +667,50 @@ impl SharedTrieCache { shared: self.clone(), node_cache: Default::default(), value_cache: Default::default(), - shared_node_cache_access: Default::default(), - shared_value_cache_access: Default::default(), + shared_value_cache_access: Mutex::new(super::ValueAccessSet::with_hasher( + schnellru::ByLength::new(super::SHARED_VALUE_CACHE_MAX_PROMOTED_KEYS), + Default::default(), + )), + stats: Default::default(), } } + /// Get a copy of the node for `key`. + /// + /// This will temporarily lock the shared cache for reading. + /// + /// This doesn't change the least recently order in the internal [`LruMap`]. + #[inline] + pub fn peek_node(&self, key: &H::Out) -> Option> { + self.inner.read().node_cache.lru.peek(key).cloned() + } + + /// Get a copy of the [`CachedValue`] for `key`. + /// + /// This will temporarily lock the shared cache for reading. + /// + /// This doesn't reorder any of the elements in the internal [`LruMap`]. + pub fn peek_value_by_hash( + &self, + hash: ValueCacheKeyHash, + storage_root: &H::Out, + storage_key: &[u8], + ) -> Option> { + self.inner + .read() + .value_cache + .lru + .peek_by_hash(hash.0, |existing_key, _| existing_key.is_eq(storage_root, storage_key)) + .cloned() + } + /// Returns the used memory size of this cache in bytes. pub fn used_memory_size(&self) -> usize { let inner = self.inner.read(); - let value_cache_size = inner.value_cache.size_in_bytes; - let node_cache_size = inner.node_cache.size_in_bytes; + let value_cache_size = + inner.value_cache.lru.memory_usage() + inner.value_cache.lru.limiter().heap_size; + let node_cache_size = + inner.node_cache.lru.memory_usage() + inner.node_cache.lru.limiter().heap_size; node_cache_size + value_cache_size } @@ -575,13 +732,19 @@ impl SharedTrieCache { } /// Returns the read locked inner. - pub(super) fn read_lock_inner(&self) -> RwLockReadGuard<'_, SharedTrieCacheInner> { + #[cfg(test)] + pub(super) fn read_lock_inner( + &self, + ) -> parking_lot::RwLockReadGuard<'_, SharedTrieCacheInner> { self.inner.read() } /// Returns the write locked inner. - pub(super) fn write_lock_inner(&self) -> RwLockWriteGuard<'_, SharedTrieCacheInner> { - self.inner.write() + pub(super) fn write_lock_inner(&self) -> Option>> { + // This should never happen, but we *really* don't want to deadlock. So let's have it + // timeout, just in case. At worst it'll do nothing, and at best it'll avert a catastrophe + // and notify us that there's a problem. + self.inner.try_write_for(super::SHARED_CACHE_WRITE_LOCK_TIMEOUT) } } @@ -592,12 +755,7 @@ mod tests { #[test] fn shared_value_cache_works() { - let base_size = mem::size_of::>() + mem::size_of::>(); - let arc_size = mem::size_of::>(); - - let mut cache = SharedValueCache::::new(CacheSize::Maximum( - (base_size + arc_size + 10) * 10, - )); + let mut cache = SharedValueCache::::new(usize::MAX, 10 * 10); let key = vec![0; 10]; @@ -613,65 +771,85 @@ mod tests { ); // Ensure that the basics are working - assert_eq!(1, cache.known_storage_keys.len()); - assert_eq!(3, Arc::strong_count(cache.known_storage_keys.get(&key[..]).unwrap())); - assert_eq!(base_size * 2 + key.len() + arc_size, cache.size_in_bytes); + assert_eq!(1, cache.lru.limiter_mut().known_storage_keys.len()); + assert_eq!( + 3, // Two instances inside the cache + one extra in `known_storage_keys`. + Arc::strong_count(cache.lru.limiter_mut().known_storage_keys.get(&key[..]).unwrap()) + ); + assert_eq!(key.len(), cache.lru.limiter().heap_size); + assert_eq!(cache.lru.len(), 2); + assert_eq!(cache.lru.peek_newest().unwrap().0.storage_root, root1); + assert_eq!(cache.lru.peek_oldest().unwrap().0.storage_root, root0); + assert!(cache.lru.limiter().heap_size <= cache.lru.limiter().max_heap_size); + assert_eq!(cache.lru.limiter().heap_size, 10); // Just accessing a key should not change anything on the size and number of entries. cache.update(vec![], vec![ValueCacheKey::hash_data(&key[..], &root0)]); - assert_eq!(1, cache.known_storage_keys.len()); - assert_eq!(3, Arc::strong_count(cache.known_storage_keys.get(&key[..]).unwrap())); - assert_eq!(base_size * 2 + key.len() + arc_size, cache.size_in_bytes); - - // Add 9 other entries and this should move out the key for `root1`. + assert_eq!(1, cache.lru.limiter_mut().known_storage_keys.len()); + assert_eq!( + 3, + Arc::strong_count(cache.lru.limiter_mut().known_storage_keys.get(&key[..]).unwrap()) + ); + assert_eq!(key.len(), cache.lru.limiter().heap_size); + assert_eq!(cache.lru.len(), 2); + assert_eq!(cache.lru.peek_newest().unwrap().0.storage_root, root0); + assert_eq!(cache.lru.peek_oldest().unwrap().0.storage_root, root1); + assert!(cache.lru.limiter().heap_size <= cache.lru.limiter().max_heap_size); + assert_eq!(cache.lru.limiter().heap_size, 10); + + // Updating the cache again with exactly the same data should not change anything. cache.update( - (1..10) + vec![ + (ValueCacheKey::new_value(&key[..], root1), CachedValue::NonExisting), + (ValueCacheKey::new_value(&key[..], root0), CachedValue::NonExisting), + ], + vec![], + ); + assert_eq!(1, cache.lru.limiter_mut().known_storage_keys.len()); + assert_eq!( + 3, + Arc::strong_count(cache.lru.limiter_mut().known_storage_keys.get(&key[..]).unwrap()) + ); + assert_eq!(key.len(), cache.lru.limiter().heap_size); + assert_eq!(cache.lru.len(), 2); + assert_eq!(cache.lru.peek_newest().unwrap().0.storage_root, root0); + assert_eq!(cache.lru.peek_oldest().unwrap().0.storage_root, root1); + assert!(cache.lru.limiter().heap_size <= cache.lru.limiter().max_heap_size); + assert_eq!(cache.lru.limiter().items_evicted, 0); + assert_eq!(cache.lru.limiter().heap_size, 10); + + // Add 10 other entries and this should move out two of the initial entries. + cache.update( + (1..11) .map(|i| vec![i; 10]) .map(|key| (ValueCacheKey::new_value(&key[..], root0), CachedValue::NonExisting)), vec![], ); - assert_eq!(10, cache.known_storage_keys.len()); - assert_eq!(2, Arc::strong_count(cache.known_storage_keys.get(&key[..]).unwrap())); - assert_eq!((base_size + key.len() + arc_size) * 10, cache.size_in_bytes); + assert_eq!(cache.lru.limiter().items_evicted, 2); + assert_eq!(10, cache.lru.len()); + assert_eq!(10, cache.lru.limiter_mut().known_storage_keys.len()); + assert!(cache.lru.limiter_mut().known_storage_keys.get(&key[..]).is_none()); + assert_eq!(key.len() * 10, cache.lru.limiter().heap_size); + assert_eq!(cache.lru.len(), 10); + assert!(cache.lru.limiter().heap_size <= cache.lru.limiter().max_heap_size); + assert_eq!(cache.lru.limiter().heap_size, 100); + assert!(matches!( - cache.get(&ValueCacheKey::new_ref(&key, root0)).unwrap(), + cache.lru.peek(&ValueCacheKey::new_value(&[1; 10][..], root0)).unwrap(), CachedValue::::NonExisting )); - assert!(cache.get(&ValueCacheKey::new_ref(&key, root1)).is_none()); + + assert!(cache.lru.peek(&ValueCacheKey::new_value(&[1; 10][..], root1)).is_none(),); + + assert!(cache.lru.peek(&ValueCacheKey::new_value(&key[..], root0)).is_none()); + assert!(cache.lru.peek(&ValueCacheKey::new_value(&key[..], root1)).is_none()); cache.update( vec![(ValueCacheKey::new_value(vec![10; 10], root0), CachedValue::NonExisting)], vec![], ); - assert!(cache.known_storage_keys.get(&key[..]).is_none()); - } - - #[test] - fn value_cache_key_eq_works() { - let storage_key = &b"something"[..]; - let storage_key2 = &b"something2"[..]; - let storage_root = Hash::random(); - - let value = ValueCacheKey::new_value(storage_key, storage_root); - // Ref gets the same hash, but a different storage key - let ref_ = - ValueCacheKey::Ref { storage_root, storage_key: storage_key2, hash: value.get_hash() }; - let hash = ValueCacheKey::Hash { - hash: value.get_hash(), - _i_read_the_documentation: IReadTheDocumentation(()), - }; - - // Ensure that the hash variants is equal to `value`, `ref_` and itself. - assert!(hash == value); - assert!(value == hash); - assert!(hash == ref_); - assert!(ref_ == hash); - assert!(hash == hash); - - // But when we compare `value` and `ref_` the different storage key is detected. - assert!(value != ref_); - assert!(ref_ != value); + assert!(cache.lru.limiter_mut().known_storage_keys.get(&key[..]).is_none()); } } From 64a1a360eaf5c467c0f836a1ca4ae4cde8663e43 Mon Sep 17 00:00:00 2001 From: Andrei Sandu <54316454+sandreim@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:22:51 +0200 Subject: [PATCH 57/80] Add task type label to metrics (#13240) Signed-off-by: Andrei Sandu Signed-off-by: Andrei Sandu --- client/service/src/task_manager/mod.rs | 41 +++++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/client/service/src/task_manager/mod.rs b/client/service/src/task_manager/mod.rs index d792122576..f2987e684d 100644 --- a/client/service/src/task_manager/mod.rs +++ b/client/service/src/task_manager/mod.rs @@ -129,12 +129,20 @@ impl SpawnTaskHandle { GroupName::Default => DEFAULT_GROUP_NAME, }; + let task_type_label = match task_type { + TaskType::Blocking => "blocking", + TaskType::Async => "async", + }; + // Note that we increase the started counter here and not within the future. This way, // we could properly visualize on Prometheus situations where the spawning doesn't work. if let Some(metrics) = &self.metrics { - metrics.tasks_spawned.with_label_values(&[name, group]).inc(); + metrics.tasks_spawned.with_label_values(&[name, group, task_type_label]).inc(); // We do a dummy increase in order for the task to show up in metrics. - metrics.tasks_ended.with_label_values(&[name, "finished", group]).inc_by(0); + metrics + .tasks_ended + .with_label_values(&[name, "finished", group, task_type_label]) + .inc_by(0); } let future = async move { @@ -145,8 +153,10 @@ impl SpawnTaskHandle { if let Some(metrics) = metrics { // Add some wrappers around `task`. let task = { - let poll_duration = metrics.poll_duration.with_label_values(&[name, group]); - let poll_start = metrics.poll_start.with_label_values(&[name, group]); + let poll_duration = + metrics.poll_duration.with_label_values(&[name, group, task_type_label]); + let poll_start = + metrics.poll_start.with_label_values(&[name, group, task_type_label]); let inner = prometheus_future::with_poll_durations(poll_duration, poll_start, task); // The logic of `AssertUnwindSafe` here is ok considering that we throw @@ -157,15 +167,24 @@ impl SpawnTaskHandle { match select(on_exit, task).await { Either::Right((Err(payload), _)) => { - metrics.tasks_ended.with_label_values(&[name, "panic", group]).inc(); + metrics + .tasks_ended + .with_label_values(&[name, "panic", group, task_type_label]) + .inc(); panic::resume_unwind(payload) }, Either::Right((Ok(()), _)) => { - metrics.tasks_ended.with_label_values(&[name, "finished", group]).inc(); + metrics + .tasks_ended + .with_label_values(&[name, "finished", group, task_type_label]) + .inc(); }, Either::Left(((), _)) => { // The `on_exit` has triggered. - metrics.tasks_ended.with_label_values(&[name, "interrupted", group]).inc(); + metrics + .tasks_ended + .with_label_values(&[name, "interrupted", group, task_type_label]) + .inc(); }, } } else { @@ -433,28 +452,28 @@ impl Metrics { buckets: exponential_buckets(0.001, 4.0, 9) .expect("function parameters are constant and always valid; qed"), }, - &["task_name", "task_group"] + &["task_name", "task_group", "kind"] )?, registry)?, poll_start: register(CounterVec::new( Opts::new( "substrate_tasks_polling_started_total", "Total number of times we started invoking Future::poll" ), - &["task_name", "task_group"] + &["task_name", "task_group", "kind"] )?, registry)?, tasks_spawned: register(CounterVec::new( Opts::new( "substrate_tasks_spawned_total", "Total number of tasks that have been spawned on the Service" ), - &["task_name", "task_group"] + &["task_name", "task_group", "kind"] )?, registry)?, tasks_ended: register(CounterVec::new( Opts::new( "substrate_tasks_ended_total", "Total number of tasks for which Future::poll has returned Ready(()) or panicked" ), - &["task_name", "reason", "task_group"] + &["task_name", "reason", "task_group", "kind"] )?, registry)?, }) } From f4bc99303e6faa0ae0461b4606c1699b4463ff4b Mon Sep 17 00:00:00 2001 From: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Date: Thu, 26 Jan 2023 08:59:18 +0100 Subject: [PATCH 58/80] upgrade nix to 0.26.1 (#13230) --- Cargo.lock | 15 +-------------- bin/node/cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c412030d5..43f67695fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4640,19 +4640,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "nix" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" -dependencies = [ - "bitflags", - "cc", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.24.3" @@ -4731,7 +4718,7 @@ dependencies = [ "jsonrpsee", "kitchensink-runtime", "log", - "nix 0.23.2", + "nix 0.26.1", "node-executor", "node-inspect", "node-primitives", diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 8a883ee011..b55b35c056 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -117,7 +117,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" futures = "0.3.21" tempfile = "3.1.0" assert_cmd = "2.0.2" -nix = "0.23" +nix = { version = "0.26.1", features = ["signal"] } serde_json = "1.0" regex = "1.6.0" platforms = "2.0" From 2dbf62591fd35725c6e39f8ddfd27c3695dab594 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Thu, 26 Jan 2023 07:39:20 -0700 Subject: [PATCH 59/80] Add WeightToFee and LengthToFee impls to transaction-payment Runtime API (#13110) * Add WeightToFee and LengthToFee impls to RPC * Remove RPC additions * Update frame/transaction-payment/rpc/runtime-api/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Add comments to length_to_fee and weight_to_fee Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Oliver Tale-Yazdi --- bin/node-template/runtime/src/lib.rs | 12 ++++++++++++ bin/node/runtime/src/lib.rs | 12 ++++++++++++ frame/transaction-payment/rpc/runtime-api/src/lib.rs | 12 ++++++++++-- frame/transaction-payment/src/lib.rs | 7 +++++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index f4372af525..baba5d9b05 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -477,6 +477,12 @@ impl_runtime_apis! { ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_fee_details(uxt, len) } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } } impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi @@ -494,6 +500,12 @@ impl_runtime_apis! { ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_call_fee_details(call, len) } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } } #[cfg(feature = "runtime-benchmarks")] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 1f85d118ea..0121f1ee3a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -2120,6 +2120,12 @@ impl_runtime_apis! { fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { TransactionPayment::query_fee_details(uxt, len) } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } } impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi @@ -2131,6 +2137,12 @@ impl_runtime_apis! { fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } } impl pallet_mmr::primitives::MmrApi< diff --git a/frame/transaction-payment/rpc/runtime-api/src/lib.rs b/frame/transaction-payment/rpc/runtime-api/src/lib.rs index 10fd2a9e61..760f9e3693 100644 --- a/frame/transaction-payment/rpc/runtime-api/src/lib.rs +++ b/frame/transaction-payment/rpc/runtime-api/src/lib.rs @@ -25,7 +25,7 @@ use sp_runtime::traits::MaybeDisplay; pub use pallet_transaction_payment::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; sp_api::decl_runtime_apis! { - #[api_version(2)] + #[api_version(3)] pub trait TransactionPaymentApi where Balance: Codec + MaybeDisplay, { @@ -33,9 +33,11 @@ sp_api::decl_runtime_apis! { fn query_info(uxt: Block::Extrinsic, len: u32) -> RuntimeDispatchInfo; fn query_info(uxt: Block::Extrinsic, len: u32) -> RuntimeDispatchInfo; fn query_fee_details(uxt: Block::Extrinsic, len: u32) -> FeeDetails; + fn query_weight_to_fee(weight: sp_weights::Weight) -> Balance; + fn query_length_to_fee(length: u32) -> Balance; } - #[api_version(2)] + #[api_version(3)] pub trait TransactionPaymentCallApi where Balance: Codec + MaybeDisplay, @@ -46,5 +48,11 @@ sp_api::decl_runtime_apis! { /// Query fee details of a given encoded `Call`. fn query_call_fee_details(call: Call, len: u32) -> FeeDetails; + + /// Query the output of the current `WeightToFee` given some input. + fn query_weight_to_fee(weight: sp_weights::Weight) -> Balance; + + /// Query the output of the current `LengthToFee` given some input. + fn query_length_to_fee(length: u32) -> Balance; } } diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 13adbf89c4..fb4381c524 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -612,11 +612,14 @@ where } } - fn length_to_fee(length: u32) -> BalanceOf { + /// Compute the length portion of a fee by invoking the configured `LengthToFee` impl. + pub fn length_to_fee(length: u32) -> BalanceOf { T::LengthToFee::weight_to_fee(&Weight::from_ref_time(length as u64)) } - fn weight_to_fee(weight: Weight) -> BalanceOf { + /// Compute the unadjusted portion of the weight fee by invoking the configured `WeightToFee` + /// impl. Note that the input `weight` is capped by the maximum block weight before computation. + pub fn weight_to_fee(weight: Weight) -> BalanceOf { // cap the weight to the maximum defined in runtime, otherwise it will be the // `Bounded` maximum of its data type, which is not desired. let capped_weight = weight.min(T::BlockWeights::get().max_block); From 495cc0e2b3b06bd3f6b746416fc0d635adcefa7c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Thu, 26 Jan 2023 17:13:38 +0100 Subject: [PATCH 60/80] Correct arithmetical semantic of `PerDispatchClass` (#13194) * Fix PerDispatchClass arithmetic Signed-off-by: Oliver Tale-Yazdi * Test PerDispatchClass arithmetic Signed-off-by: Oliver Tale-Yazdi * Add helpers for Weight Signed-off-by: Oliver Tale-Yazdi * Remove stale doc Signed-off-by: Oliver Tale-Yazdi * Dont mention Polkadot in Substrate Signed-off-by: Oliver Tale-Yazdi * Tests Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * Remove saturating_ prefix Signed-off-by: Oliver Tale-Yazdi * Fix tests Signed-off-by: Oliver Tale-Yazdi * Fix usage Signed-off-by: Oliver Tale-Yazdi Signed-off-by: Oliver Tale-Yazdi --- frame/support/src/dispatch.rs | 209 ++++++++++++++++++-- frame/support/src/weights.rs | 10 +- frame/system/src/extensions/check_weight.rs | 6 +- frame/system/src/lib.rs | 2 +- primitives/weights/src/lib.rs | 7 - primitives/weights/src/weight_v2.rs | 109 ++++++++++ 6 files changed, 307 insertions(+), 36 deletions(-) diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 93cf08c131..291abdd128 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -423,33 +423,35 @@ impl PerDispatchClass { impl PerDispatchClass { /// Returns the total weight consumed by all extrinsics in the block. + /// + /// Saturates on overflow. pub fn total(&self) -> Weight { let mut sum = Weight::zero(); for class in DispatchClass::all() { - sum = sum.saturating_add(*self.get(*class)); + sum.saturating_accrue(*self.get(*class)); } sum } - /// Add some weight of a specific dispatch class, saturating at the numeric bounds of `Weight`. - pub fn add(&mut self, weight: Weight, class: DispatchClass) { - let value = self.get_mut(class); - *value = value.saturating_add(weight); + /// Add some weight to the given class. Saturates at the numeric bounds. + pub fn add(mut self, weight: Weight, class: DispatchClass) -> Self { + self.accrue(weight, class); + self + } + + /// Increase the weight of the given class. Saturates at the numeric bounds. + pub fn accrue(&mut self, weight: Weight, class: DispatchClass) { + self.get_mut(class).saturating_accrue(weight); } - /// Try to add some weight of a specific dispatch class, returning Err(()) if overflow would - /// occur. - pub fn checked_add(&mut self, weight: Weight, class: DispatchClass) -> Result<(), ()> { - let value = self.get_mut(class); - *value = value.checked_add(&weight).ok_or(())?; - Ok(()) + /// Try to increase the weight of the given class. Saturates at the numeric bounds. + pub fn checked_accrue(&mut self, weight: Weight, class: DispatchClass) -> Result<(), ()> { + self.get_mut(class).checked_accrue(weight).ok_or(()) } - /// Subtract some weight of a specific dispatch class, saturating at the numeric bounds of - /// `Weight`. - pub fn sub(&mut self, weight: Weight, class: DispatchClass) { - let value = self.get_mut(class); - *value = value.saturating_sub(weight); + /// Reduce the weight of the given class. Saturates at the numeric bounds. + pub fn reduce(&mut self, weight: Weight, class: DispatchClass) { + self.get_mut(class).saturating_reduce(weight); } } @@ -3693,3 +3695,178 @@ mod weight_tests { assert_eq!(extract_actual_pays_fee(&Ok((Some(1000), Pays::Yes).into()), &pre), Pays::No); } } + +#[cfg(test)] +mod per_dispatch_class_tests { + use super::*; + use sp_runtime::traits::Zero; + use DispatchClass::*; + + #[test] + fn add_works() { + let a = PerDispatchClass { + normal: (5, 10).into(), + operational: (20, 30).into(), + mandatory: Weight::MAX, + }; + assert_eq!( + a.clone() + .add((20, 5).into(), Normal) + .add((10, 10).into(), Operational) + .add((u64::MAX, 3).into(), Mandatory), + PerDispatchClass { + normal: (25, 15).into(), + operational: (30, 40).into(), + mandatory: Weight::MAX + } + ); + let b = a + .add(Weight::MAX, Normal) + .add(Weight::MAX, Operational) + .add(Weight::MAX, Mandatory); + assert_eq!( + b, + PerDispatchClass { + normal: Weight::MAX, + operational: Weight::MAX, + mandatory: Weight::MAX + } + ); + assert_eq!(b.total(), Weight::MAX); + } + + #[test] + fn accrue_works() { + let mut a = PerDispatchClass::default(); + + a.accrue((10, 15).into(), Normal); + assert_eq!(a.normal, (10, 15).into()); + assert_eq!(a.total(), (10, 15).into()); + + a.accrue((20, 25).into(), Operational); + assert_eq!(a.operational, (20, 25).into()); + assert_eq!(a.total(), (30, 40).into()); + + a.accrue((30, 35).into(), Mandatory); + assert_eq!(a.mandatory, (30, 35).into()); + assert_eq!(a.total(), (60, 75).into()); + + a.accrue((u64::MAX, 10).into(), Operational); + assert_eq!(a.operational, (u64::MAX, 35).into()); + assert_eq!(a.total(), (u64::MAX, 85).into()); + + a.accrue((10, u64::MAX).into(), Normal); + assert_eq!(a.normal, (20, u64::MAX).into()); + assert_eq!(a.total(), Weight::MAX); + } + + #[test] + fn reduce_works() { + let mut a = PerDispatchClass { + normal: (10, u64::MAX).into(), + mandatory: (u64::MAX, 10).into(), + operational: (20, 20).into(), + }; + + a.reduce((5, 100).into(), Normal); + assert_eq!(a.normal, (5, u64::MAX - 100).into()); + assert_eq!(a.total(), (u64::MAX, u64::MAX - 70).into()); + + a.reduce((15, 5).into(), Operational); + assert_eq!(a.operational, (5, 15).into()); + assert_eq!(a.total(), (u64::MAX, u64::MAX - 75).into()); + + a.reduce((50, 0).into(), Mandatory); + assert_eq!(a.mandatory, (u64::MAX - 50, 10).into()); + assert_eq!(a.total(), (u64::MAX - 40, u64::MAX - 75).into()); + + a.reduce((u64::MAX, 100).into(), Operational); + assert!(a.operational.is_zero()); + assert_eq!(a.total(), (u64::MAX - 45, u64::MAX - 90).into()); + + a.reduce((5, u64::MAX).into(), Normal); + assert!(a.normal.is_zero()); + assert_eq!(a.total(), (u64::MAX - 50, 10).into()); + } + + #[test] + fn checked_accrue_works() { + let mut a = PerDispatchClass::default(); + + a.checked_accrue((1, 2).into(), Normal).unwrap(); + a.checked_accrue((3, 4).into(), Operational).unwrap(); + a.checked_accrue((5, 6).into(), Mandatory).unwrap(); + a.checked_accrue((7, 8).into(), Operational).unwrap(); + a.checked_accrue((9, 0).into(), Normal).unwrap(); + + assert_eq!( + a, + PerDispatchClass { + normal: (10, 2).into(), + operational: (10, 12).into(), + mandatory: (5, 6).into(), + } + ); + + a.checked_accrue((u64::MAX - 10, u64::MAX - 2).into(), Normal).unwrap(); + a.checked_accrue((0, 0).into(), Normal).unwrap(); + a.checked_accrue((1, 0).into(), Normal).unwrap_err(); + a.checked_accrue((0, 1).into(), Normal).unwrap_err(); + + assert_eq!( + a, + PerDispatchClass { + normal: Weight::MAX, + operational: (10, 12).into(), + mandatory: (5, 6).into(), + } + ); + } + + #[test] + fn checked_accrue_does_not_modify_on_error() { + let mut a = PerDispatchClass { + normal: 0.into(), + operational: Weight::MAX / 2 + 2.into(), + mandatory: 10.into(), + }; + + a.checked_accrue(Weight::MAX / 2, Operational).unwrap_err(); + a.checked_accrue(Weight::MAX - 9.into(), Mandatory).unwrap_err(); + a.checked_accrue(Weight::MAX, Normal).unwrap(); // This one works + + assert_eq!( + a, + PerDispatchClass { + normal: Weight::MAX, + operational: Weight::MAX / 2 + 2.into(), + mandatory: 10.into(), + } + ); + } + + #[test] + fn total_works() { + assert!(PerDispatchClass::default().total().is_zero()); + + assert_eq!( + PerDispatchClass { + normal: 0.into(), + operational: (10, 20).into(), + mandatory: (20, u64::MAX).into(), + } + .total(), + (30, u64::MAX).into() + ); + + assert_eq!( + PerDispatchClass { + normal: (u64::MAX - 10, 10).into(), + operational: (3, u64::MAX).into(), + mandatory: (4, u64::MAX).into(), + } + .total(), + (u64::MAX - 3, u64::MAX).into() + ); + } +} diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index 9ff49b97bf..d52380b832 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -15,15 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Re-exports `sp-weights` public API, and contains benchmarked weight constants specific to -//! FRAME. -//! -//! Latest machine specification used to benchmark are: -//! - Digital Ocean: ubuntu-s-2vcpu-4gb-ams3-01 -//! - 2x Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz -//! - 4GB RAM -//! - Ubuntu 19.10 (GNU/Linux 5.3.0-18-generic x86_64) -//! - rustc 1.42.0 (b8cedc004 2020-03-09) +//! Re-exports `sp-weights` public API, and contains benchmarked weight constants specific to FRAME. mod block_weights; mod extrinsic_weights; diff --git a/frame/system/src/extensions/check_weight.rs b/frame/system/src/extensions/check_weight.rs index 757b2197bc..590d05474f 100644 --- a/frame/system/src/extensions/check_weight.rs +++ b/frame/system/src/extensions/check_weight.rs @@ -135,10 +135,10 @@ where // add the weight. If class is unlimited, use saturating add instead of checked one. if limit_per_class.max_total.is_none() && limit_per_class.reserved.is_none() { - all_weight.add(extrinsic_weight, info.class) + all_weight.accrue(extrinsic_weight, info.class) } else { all_weight - .checked_add(extrinsic_weight, info.class) + .checked_accrue(extrinsic_weight, info.class) .map_err(|_| InvalidTransaction::ExhaustsResources)?; } @@ -229,7 +229,7 @@ where let unspent = post_info.calc_unspent(info); if unspent.any_gt(Weight::zero()) { crate::BlockWeight::::mutate(|current_weight| { - current_weight.sub(unspent, info.class); + current_weight.reduce(unspent, info.class); }) } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 4bd5cf6298..c5d1706006 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1321,7 +1321,7 @@ impl Pallet { /// Another potential use-case could be for the `on_initialize` and `on_finalize` hooks. pub fn register_extra_weight_unchecked(weight: Weight, class: DispatchClass) { BlockWeight::::mutate(|current_weight| { - current_weight.add(weight, class); + current_weight.accrue(weight, class); }); } diff --git a/primitives/weights/src/lib.rs b/primitives/weights/src/lib.rs index 928080d139..59852815d7 100644 --- a/primitives/weights/src/lib.rs +++ b/primitives/weights/src/lib.rs @@ -16,13 +16,6 @@ // limitations under the License. //! # Primitives for transaction weighting. -//! -//! Latest machine specification used to benchmark are: -//! - Digital Ocean: ubuntu-s-2vcpu-4gb-ams3-01 -//! - 2x Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz -//! - 4GB RAM -//! - Ubuntu 19.10 (GNU/Linux 5.3.0-18-generic x86_64) -//! - rustc 1.42.0 (b8cedc004 2020-03-09) #![cfg_attr(not(feature = "std"), no_std)] diff --git a/primitives/weights/src/weight_v2.rs b/primitives/weights/src/weight_v2.rs index 2933d80099..33e61b6954 100644 --- a/primitives/weights/src/weight_v2.rs +++ b/primitives/weights/src/weight_v2.rs @@ -117,6 +117,11 @@ impl Weight { Self { ref_time, proof_size } } + /// Construct [`Weight`] from the same weight for all parts. + pub const fn from_all(value: u64) -> Self { + Self { ref_time: value, proof_size: value } + } + /// Saturating [`Weight`] addition. Computes `self + rhs`, saturating at the numeric bounds of /// all fields instead of overflowing. pub const fn saturating_add(self, rhs: Self) -> Self { @@ -167,6 +172,11 @@ impl Weight { *self = self.saturating_add(amount); } + /// Reduce [`Weight`] by `amount` via saturating subtraction. + pub fn saturating_reduce(&mut self, amount: Self) { + *self = self.saturating_sub(amount); + } + /// Checked [`Weight`] addition. Computes `self + rhs`, returning `None` if overflow occurred. pub const fn checked_add(&self, rhs: &Self) -> Option { let ref_time = match self.ref_time.checked_add(rhs.ref_time) { @@ -222,6 +232,16 @@ impl Weight { Some(Self { ref_time, proof_size }) } + /// Try to increase `self` by `amount` via checked addition. + pub fn checked_accrue(&mut self, amount: Self) -> Option<()> { + self.checked_add(&amount).map(|new_self| *self = new_self) + } + + /// Try to reduce `self` by `amount` via checked subtraction. + pub fn checked_reduce(&mut self, amount: Self) -> Option<()> { + self.checked_sub(&amount).map(|new_self| *self = new_self) + } + /// Return a [`Weight`] where all fields are zero. pub const fn zero() -> Self { Self { ref_time: 0, proof_size: 0 } @@ -352,6 +372,20 @@ where } } +#[cfg(any(test, feature = "std", feature = "runtime-benchmarks"))] +impl From for Weight { + fn from(value: u64) -> Self { + Self::from_parts(value, value) + } +} + +#[cfg(any(test, feature = "std", feature = "runtime-benchmarks"))] +impl From<(u64, u64)> for Weight { + fn from(value: (u64, u64)) -> Self { + Self::from_parts(value.0, value.1) + } +} + macro_rules! weight_mul_per_impl { ($($t:ty),* $(,)?) => { $( @@ -459,4 +493,79 @@ mod tests { assert!(!Weight::from_parts(0, 1).is_zero()); assert!(!Weight::MAX.is_zero()); } + + #[test] + fn from_parts_works() { + assert_eq!(Weight::from_parts(0, 0), Weight { ref_time: 0, proof_size: 0 }); + assert_eq!(Weight::from_parts(5, 5), Weight { ref_time: 5, proof_size: 5 }); + assert_eq!( + Weight::from_parts(u64::MAX, u64::MAX), + Weight { ref_time: u64::MAX, proof_size: u64::MAX } + ); + } + + #[test] + fn from_all_works() { + assert_eq!(Weight::from_all(0), Weight::from_parts(0, 0)); + assert_eq!(Weight::from_all(5), Weight::from_parts(5, 5)); + assert_eq!(Weight::from_all(u64::MAX), Weight::from_parts(u64::MAX, u64::MAX)); + } + + #[test] + fn from_u64_works() { + assert_eq!(Weight::from_all(0), 0_u64.into()); + assert_eq!(Weight::from_all(123), 123_u64.into()); + assert_eq!(Weight::from_all(u64::MAX), u64::MAX.into()); + } + + #[test] + fn from_u64_pair_works() { + assert_eq!(Weight::from_parts(0, 1), (0, 1).into()); + assert_eq!(Weight::from_parts(123, 321), (123u64, 321u64).into()); + assert_eq!(Weight::from_parts(u64::MAX, 0), (u64::MAX, 0).into()); + } + + #[test] + fn saturating_reduce_works() { + let mut weight = Weight::from_parts(10, 20); + weight.saturating_reduce(Weight::from_all(5)); + assert_eq!(weight, Weight::from_parts(5, 15)); + weight.saturating_reduce(Weight::from_all(5)); + assert_eq!(weight, Weight::from_parts(0, 10)); + weight.saturating_reduce(Weight::from_all(11)); + assert!(weight.is_zero()); + weight.saturating_reduce(Weight::from_all(u64::MAX)); + assert!(weight.is_zero()); + } + + #[test] + fn checked_accrue_works() { + let mut weight = Weight::from_parts(10, 20); + assert!(weight.checked_accrue(Weight::from_all(2)).is_some()); + assert_eq!(weight, Weight::from_parts(12, 22)); + assert!(weight.checked_accrue(Weight::from_parts(u64::MAX, 0)).is_none()); + assert!(weight.checked_accrue(Weight::from_parts(0, u64::MAX)).is_none()); + assert_eq!(weight, Weight::from_parts(12, 22)); + assert!(weight + .checked_accrue(Weight::from_parts(u64::MAX - 12, u64::MAX - 22)) + .is_some()); + assert_eq!(weight, Weight::MAX); + assert!(weight.checked_accrue(Weight::from_parts(1, 0)).is_none()); + assert!(weight.checked_accrue(Weight::from_parts(0, 1)).is_none()); + assert_eq!(weight, Weight::MAX); + } + + #[test] + fn checked_reduce_works() { + let mut weight = Weight::from_parts(10, 20); + assert!(weight.checked_reduce(Weight::from_all(2)).is_some()); + assert_eq!(weight, Weight::from_parts(8, 18)); + assert!(weight.checked_reduce(Weight::from_parts(9, 0)).is_none()); + assert!(weight.checked_reduce(Weight::from_parts(0, 19)).is_none()); + assert_eq!(weight, Weight::from_parts(8, 18)); + assert!(weight.checked_reduce(Weight::from_parts(8, 0)).is_some()); + assert_eq!(weight, Weight::from_parts(0, 18)); + assert!(weight.checked_reduce(Weight::from_parts(0, 18)).is_some()); + assert!(weight.is_zero()); + } } From 65d1d03ff6551afeebf4bb4ca8b972db5e8869a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 26 Jan 2023 21:37:51 +0100 Subject: [PATCH 61/80] Aura: Fix warp syncing (#13221) * Aura: Fix warp syncing We need to set the fork choice rule! When using Cumulus this is done by the `ParachainsBlockImport`, but for standalone chains we still need this! Closes: https://github.com/paritytech/substrate/issues/13220 * Improve fork choice --- client/consensus/aura/src/import_queue.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/consensus/aura/src/import_queue.rs b/client/consensus/aura/src/import_queue.rs index 3ac26345db..4c8722c31f 100644 --- a/client/consensus/aura/src/import_queue.rs +++ b/client/consensus/aura/src/import_queue.rs @@ -186,16 +186,15 @@ where &mut self, mut block: BlockImportParams, ) -> Result<(BlockImportParams, Option)>>), String> { - // When importing whole state we don't verify the seal as the state is not available. - if block.with_state() { - return Ok((block, Default::default())) - } - - // Skip checks that include execution, if being told so. + // Skip checks that include execution, if being told so or when importing only state. // // This is done for example when gap syncing and it is expected that the block after the gap // was checked/chosen properly, e.g. by warp syncing to this block using a finality proof. - if block.state_action.skip_execution_checks() { + // Or when we are importing state only and can not verify the seal. + if block.with_state() || block.state_action.skip_execution_checks() { + // When we are importing only the state of a block, it will be the best block. + block.fork_choice = Some(ForkChoiceStrategy::Custom(block.with_state())); + return Ok((block, Default::default())) } From ff9921a260a67e3a71f25c8b402cd5c7da787a96 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 26 Jan 2023 19:35:39 -0300 Subject: [PATCH 62/80] Add Proof Size to Weight Output (#11637) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial impl * add template test * linear fit proof size * always record proof when tracking storage * calculate worst case pov * remove duplicate worst case * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs * more comment output * add cli for worst case map size * update name * clap does not support underscores * rename * expose worst case map values * improve some comments * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs * update template * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs * fix fmt * more fmt * more fmt * Dont panic when there is no proof Signed-off-by: Oliver Tale-Yazdi * Fix test features Signed-off-by: Oliver Tale-Yazdi * Whitelist :extrinsic_index Signed-off-by: Oliver Tale-Yazdi * Use whitelist when recording proof Signed-off-by: Oliver Tale-Yazdi * Add logs Signed-off-by: Oliver Tale-Yazdi * Add PoV testing pallet Signed-off-by: Oliver Tale-Yazdi * Deploy PoV testing pallet Signed-off-by: Oliver Tale-Yazdi * Storage benches reside in the PoV pallet Signed-off-by: Oliver Tale-Yazdi * Linear regress PoV per component Splits the PoV calculation into "measured" and "estimated". The measured part is reported by the Proof recorder and linear regressed over all components at once. The estimated part is calculated as worst-case by using the max PoV size per storage access and calculating one linear regress per component. This gives each component a (possibly) independent PoV. For now the measured size will always be lower than the PoV on Polkadot since it is measured on an empty snapshot. The measured part is therefor only used as diagnostic for debugging. Signed-off-by: Oliver Tale-Yazdi * Put PoV into the weight templates Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * Extra alanysis choise for PoV Signed-off-by: Oliver Tale-Yazdi * Add+Fix tests Signed-off-by: Oliver Tale-Yazdi * Make benches faster Signed-off-by: Oliver Tale-Yazdi * Cleanup Signed-off-by: Oliver Tale-Yazdi * Use same template comments Signed-off-by: Oliver Tale-Yazdi * ".git/.scripts/bench-bot.sh" pallet dev pallet_balances * ".git/.scripts/bench-bot.sh" pallet dev pallet_democracy * Update referenda mock BlockWeights Signed-off-by: Oliver Tale-Yazdi * Take measured value size into account Signed-off-by: Oliver Tale-Yazdi * clippy Signed-off-by: Oliver Tale-Yazdi * ".git/.scripts/bench-bot.sh" pallet dev pallet_scheduler * WIP Signed-off-by: Oliver Tale-Yazdi * proof_size: None Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * ugly, but works Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * wup Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * WIP Signed-off-by: Oliver Tale-Yazdi * Add pov_mode attribute to the benchmarks! macro Signed-off-by: Oliver Tale-Yazdi * Use pov_mode attribute in PoV benchmarking Signed-off-by: Oliver Tale-Yazdi * Update tests Signed-off-by: Oliver Tale-Yazdi * Scheduler, Whitelist: Add pov_mode attr Signed-off-by: Oliver Tale-Yazdi * Update PoV weights * Add CLI arg: default-pov-mode Signed-off-by: Oliver Tale-Yazdi * Fix tests Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * fix Signed-off-by: Oliver Tale-Yazdi * Revert "Update PoV weights" This reverts commit 2f3ac2387396470b118122a6ff8fa4ee12216f4b. * Revert "WIP" This reverts commit c34b538cd2bc45da4544e887180184e30957904a. * Revert first approach This reverts commit range 8ddaa2fffe5930f225a30bee314d0b7c94c344dd^..4c84f8748e5395852a9e0e25b0404953fee1a59e Signed-off-by: Oliver Tale-Yazdi * Clippy Signed-off-by: Oliver Tale-Yazdi * Add extra benchmarks Signed-off-by: Oliver Tale-Yazdi * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_alliance * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_whitelist * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_scheduler * fmt Signed-off-by: Oliver Tale-Yazdi * Clippy Signed-off-by: Oliver Tale-Yazdi * Clippy 🤦 Signed-off-by: Oliver Tale-Yazdi * Add reference benchmarks Signed-off-by: Oliver Tale-Yazdi * Fix doc comments Signed-off-by: Oliver Tale-Yazdi * Undo logging Signed-off-by: Oliver Tale-Yazdi * Add 'Ignored' pov_mode Signed-off-by: Oliver Tale-Yazdi * Allow multiple attributes per benchmark Turns out that the current benchmarking syntax does not support multiple attributes per bench 🤦. Changing it to support that since otherwise the `pov_mode` would conflict with the others. Signed-off-by: Oliver Tale-Yazdi * Validate pov_mode syntax Signed-off-by: Oliver Tale-Yazdi * Ignore PoV for all contract benchmarks Signed-off-by: Oliver Tale-Yazdi * Test Signed-off-by: Oliver Tale-Yazdi * test Signed-off-by: Oliver Tale-Yazdi * Bump macro recursion limit Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * Update contract weights They dont have a PoV component anymore. Signed-off-by: Oliver Tale-Yazdi * fix test ffs Signed-off-by: Oliver Tale-Yazdi * pov_mode is unsupported in V2 syntax Signed-off-by: Oliver Tale-Yazdi * Fix pallet ui tests Signed-off-by: Oliver Tale-Yazdi * update pallet ui Signed-off-by: Oliver Tale-Yazdi * Fix pallet ui tests Signed-off-by: Oliver Tale-Yazdi * Update weights Signed-off-by: Oliver Tale-Yazdi Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Parity Bot Co-authored-by: Oliver Tale-Yazdi Co-authored-by: command-bot <> Co-authored-by: Your Name --- .maintain/frame-weight-template.hbs | 35 +- Cargo.lock | 15 + Cargo.toml | 1 + bin/node/runtime/Cargo.toml | 8 +- bin/node/runtime/src/lib.rs | 6 + client/db/src/bench.rs | 4 + client/db/src/upgrade.rs | 2 +- client/db/src/utils.rs | 7 +- frame/alliance/src/weights.rs | 1174 ++-- frame/assets/src/weights.rs | 1061 ++-- frame/bags-list/src/weights.rs | 149 +- frame/balances/src/weights.rs | 201 +- frame/benchmarking/Cargo.toml | 1 + frame/benchmarking/pov/Cargo.toml | 43 + frame/benchmarking/pov/src/benchmarking.rs | 371 ++ frame/benchmarking/pov/src/lib.rs | 131 + frame/benchmarking/pov/src/tests.rs | 211 + frame/benchmarking/pov/src/weights.rs | 807 +++ frame/benchmarking/src/baseline.rs | 63 +- frame/benchmarking/src/lib.rs | 132 +- frame/benchmarking/src/utils.rs | 1 + frame/benchmarking/src/weights.rs | 147 +- frame/bounties/src/weights.rs | 450 +- frame/child-bounties/src/weights.rs | 411 +- frame/collective/src/weights.rs | 659 ++- frame/contracts/src/benchmarking/mod.rs | 120 + frame/contracts/src/lib.rs | 2 +- frame/contracts/src/weights.rs | 4964 +++++++++++------ frame/conviction-voting/src/weights.rs | 351 +- frame/democracy/src/weights.rs | 995 ++-- .../src/weights.rs | 553 +- frame/elections-phragmen/src/weights.rs | 649 ++- frame/identity/src/weights.rs | 829 +-- frame/im-online/src/weights.rs | 77 +- frame/indices/src/weights.rs | 157 +- frame/lottery/src/weights.rs | 290 +- frame/membership/src/weights.rs | 397 +- frame/message-queue/src/weights.rs | 318 +- frame/multisig/src/weights.rs | 277 +- frame/nfts/src/weights.rs | 1814 +++--- frame/nis/src/weights.rs | 522 +- frame/nomination-pools/src/weights.rs | 1199 ++-- frame/preimage/src/weights.rs | 389 +- frame/proxy/src/weights.rs | 431 +- frame/ranked-collective/src/weights.rs | 317 +- frame/recovery/src/weights.rs | 345 +- frame/referenda/src/mock.rs | 2 +- frame/referenda/src/weights.rs | 1162 ++-- frame/remark/src/weights.rs | 27 +- frame/scheduler/src/benchmarking.rs | 4 + frame/scheduler/src/weights.rs | 351 +- frame/session/src/weights.rs | 85 +- frame/staking/src/weights.rs | 1914 ++++--- frame/state-trie-migration/src/weights.rs | 185 +- frame/support/procedural/src/benchmark.rs | 3 + frame/support/src/storage/transactional.rs | 2 + frame/support/src/weights/block_weights.rs | 20 +- .../support/src/weights/extrinsic_weights.rs | 20 +- frame/system/src/weights.rs | 173 +- frame/timestamp/src/weights.rs | 53 +- frame/tips/src/weights.rs | 281 +- frame/transaction-storage/src/weights.rs | 151 +- frame/treasury/src/weights.rs | 241 +- frame/uniques/src/weights.rs | 1127 ++-- frame/utility/src/weights.rs | 99 +- frame/vesting/src/weights.rs | 441 +- frame/whitelist/src/benchmarking.rs | 4 + frame/whitelist/src/weights.rs | 172 +- primitives/storage/src/lib.rs | 2 + scripts/run_all_benchmarks.sh | 2 + .../benchmarking-cli/src/pallet/command.rs | 178 +- .../frame/benchmarking-cli/src/pallet/mod.rs | 31 +- .../benchmarking-cli/src/pallet/template.hbs | 15 +- .../benchmarking-cli/src/pallet/writer.rs | 868 ++- 74 files changed, 19128 insertions(+), 9571 deletions(-) create mode 100644 frame/benchmarking/pov/Cargo.toml create mode 100644 frame/benchmarking/pov/src/benchmarking.rs create mode 100644 frame/benchmarking/pov/src/lib.rs create mode 100644 frame/benchmarking/pov/src/tests.rs create mode 100644 frame/benchmarking/pov/src/weights.rs diff --git a/.maintain/frame-weight-template.hbs b/.maintain/frame-weight-template.hbs index 9c9e297800..ff69fcb4a2 100644 --- a/.maintain/frame-weight-template.hbs +++ b/.maintain/frame-weight-template.hbs @@ -2,7 +2,8 @@ //! Autogenerated weights for {{pallet}} //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} -//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}` //! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` //! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} @@ -38,7 +39,7 @@ impl WeightInfo for SubstrateWeight { {{/if}} {{#each benchmarks as |benchmark|}} {{#each benchmark.comments as |comment|}} - // {{comment}} + /// {{comment}} {{/each}} {{#each benchmark.component_ranges as |range|}} /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. @@ -48,24 +49,34 @@ impl WeightInfo for SubstrateWeight { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { + // Proof Size summary in bytes: + // Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. + {{#if (ne benchmark.base_calculated_proof_size "0")}} + Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}}) + {{else}} Weight::from_ref_time({{underscore benchmark.base_weight}}) + {{/if}} {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64)) {{/if}} {{#each benchmark.component_reads as |cr|}} .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64)) {{/if}} {{#each benchmark.component_writes as |cw|}} .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} + {{#each benchmark.component_calculated_proof_size as |cp|}} + .saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into())) + {{/each}} } {{/each}} } @@ -74,7 +85,7 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { {{#each benchmarks as |benchmark|}} {{#each benchmark.comments as |comment|}} - // {{comment}} + /// {{comment}} {{/each}} {{#each benchmark.component_ranges as |range|}} /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. @@ -84,24 +95,34 @@ impl WeightInfo for () { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { + // Proof Size summary in bytes: + // Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. + {{#if (ne benchmark.base_calculated_proof_size "0")}} + Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}}) + {{else}} Weight::from_ref_time({{underscore benchmark.base_weight}}) + {{/if}} {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}})) + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}_u64)) {{/if}} {{#each benchmark.component_reads as |cr|}} .saturating_add(RocksDbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}})) + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}}_u64)) {{/if}} {{#each benchmark.component_writes as |cw|}} .saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} + {{#each benchmark.component_calculated_proof_size as |cp|}} + .saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into())) + {{/each}} } {{/each}} } diff --git a/Cargo.lock b/Cargo.lock index 43f67695fa..7bbe546921 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2203,6 +2203,20 @@ dependencies = [ "thousands", ] +[[package]] +name = "frame-benchmarking-pallet-pov" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" @@ -3453,6 +3467,7 @@ name = "kitchensink-runtime" version = "3.0.0-dev" dependencies = [ "frame-benchmarking", + "frame-benchmarking-pallet-pov", "frame-election-provider-support", "frame-executive", "frame-support", diff --git a/Cargo.toml b/Cargo.toml index f7eedadd1e..bb52305162 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,6 +88,7 @@ members = [ "frame/beefy-mmr", "frame/beefy-mmr/primitives", "frame/benchmarking", + "frame/benchmarking/pov", "frame/bounties", "frame/child-bounties", "frame/collective", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 76fca730ef..1ff8eb0abd 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -43,7 +43,8 @@ sp-io = { version = "7.0.0", default-features = false, path = "../../../primitiv # frame dependencies frame-executive = { version = "4.0.0-dev", default-features = false, path = "../../../frame/executive" } -frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking", optional = true } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking" } +frame-benchmarking-pallet-pov = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking/pov" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system" } frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system/benchmarking", optional = true } @@ -178,7 +179,8 @@ std = [ "sp-session/std", "pallet-sudo/std", "frame-support/std", - "frame-benchmarking?/std", + "frame-benchmarking/std", + "frame-benchmarking-pallet-pov/std", "frame-system-rpc-runtime-api/std", "frame-system/std", "pallet-election-provider-multi-phase/std", @@ -209,6 +211,7 @@ std = [ ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", + "frame-benchmarking-pallet-pov/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -263,6 +266,7 @@ runtime-benchmarks = [ ] try-runtime = [ "frame-try-runtime/try-runtime", + "frame-benchmarking-pallet-pov/try-runtime", "frame-executive/try-runtime", "frame-system/try-runtime", "frame-support/try-runtime", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 0121f1ee3a..bd8a395d15 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1696,6 +1696,10 @@ impl pallet_alliance::Config for Runtime { type RetirementPeriod = RetirementPeriod; } +impl frame_benchmarking_pallet_pov::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + construct_runtime!( pub enum Runtime where Block = Block, @@ -1762,6 +1766,7 @@ construct_runtime!( RankedCollective: pallet_ranked_collective, FastUnstake: pallet_fast_unstake, MessageQueue: pallet_message_queue, + Pov: frame_benchmarking_pallet_pov, } ); @@ -1830,6 +1835,7 @@ mod mmr { mod benches { frame_benchmarking::define_benchmarks!( [frame_benchmarking, BaselineBench::] + [frame_benchmarking_pallet_pov, Pov] [pallet_alliance, Alliance] [pallet_assets, Assets] [pallet_babe, Babe] diff --git a/client/db/src/bench.rs b/client/db/src/bench.rs index e53209f277..a744762876 100644 --- a/client/db/src/bench.rs +++ b/client/db/src/bench.rs @@ -606,10 +606,14 @@ impl StateBackend> for BenchmarkingState { let proof_recorder_root = self.proof_recorder_root.get(); if proof_recorder_root == Default::default() || proof_size == 1 { // empty trie + log::debug!(target: "benchmark", "Some proof size: {}", &proof_size); proof_size } else { if let Some(size) = proof.encoded_compact_size::>(proof_recorder_root) { size as u32 + } else if proof_recorder_root == self.root.get() { + log::debug!(target: "benchmark", "No changes - no proof"); + 0 } else { panic!( "proof rec root {:?}, root {:?}, genesis {:?}, rec_len {:?}", diff --git a/client/db/src/upgrade.rs b/client/db/src/upgrade.rs index 51750bf689..98517acad6 100644 --- a/client/db/src/upgrade.rs +++ b/client/db/src/upgrade.rs @@ -190,7 +190,7 @@ fn version_file_path(path: &Path) -> PathBuf { file_path } -#[cfg(test)] +#[cfg(all(test, feature = "rocksdb"))] mod tests { use super::*; use crate::{tests::Block, DatabaseSource}; diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index 567950d089..e998511016 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -583,12 +583,12 @@ mod tests { use super::*; use codec::Input; use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper}; - use std::path::PathBuf; type Block = RawBlock>; - #[cfg(any(feature = "rocksdb", test))] + #[cfg(feature = "rocksdb")] #[test] fn database_type_subdir_migration() { + use std::path::PathBuf; type Block = RawBlock>; fn check_dir_for_db_type( @@ -685,6 +685,7 @@ mod tests { assert_eq!(joined.remaining_len().unwrap(), Some(0)); } + #[cfg(feature = "rocksdb")] #[test] fn test_open_database_auto_new() { let db_dir = tempfile::TempDir::new().unwrap(); @@ -730,6 +731,7 @@ mod tests { } } + #[cfg(feature = "rocksdb")] #[test] fn test_open_database_rocksdb_new() { let db_dir = tempfile::TempDir::new().unwrap(); @@ -780,6 +782,7 @@ mod tests { } } + #[cfg(feature = "rocksdb")] #[test] fn test_open_database_paritydb_new() { let db_dir = tempfile::TempDir::new().unwrap(); diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 1cfc83dfc4..9ff6ce612f 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_alliance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_alliance // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_alliance -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/alliance/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -73,530 +73,832 @@ pub trait WeightInfo { /// Weights for pallet_alliance using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalCount (r:1 w:1) - // Storage: AllianceMotion Voting (r:0 w:1) + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion ProposalOf (r:1 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalCount (r:1 w:1) + /// Proof Skipped: AllianceMotion ProposalCount (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Voting (r:0 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. - fn propose_proposed(_b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 45_945 nanoseconds. - Weight::from_ref_time(44_195_340) - // Standard Error: 2_212 - .saturating_add(Weight::from_ref_time(73_715).saturating_mul(m.into())) - // Standard Error: 2_184 - .saturating_add(Weight::from_ref_time(172_373).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) + fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `692 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `11659 + m * (132 ±0) + p * (144 ±0)` + // Minimum execution time: 28_849 nanoseconds. + Weight::from_parts(29_823_933, 11659) + // Standard Error: 74 + .saturating_add(Weight::from_ref_time(830).saturating_mul(b.into())) + // Standard Error: 775 + .saturating_add(Weight::from_ref_time(22_980).saturating_mul(m.into())) + // Standard Error: 765 + .saturating_add(Weight::from_ref_time(90_520).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_proof_size(132).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(144).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - // Minimum execution time: 41_578 nanoseconds. - Weight::from_ref_time(44_299_385) - // Standard Error: 3_727 - .saturating_add(Weight::from_ref_time(138_681).saturating_mul(m.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `1177 + m * (64 ±0)` + // Estimated: `9337 + m * (64 ±0)` + // Minimum execution time: 23_570 nanoseconds. + Weight::from_parts(25_473_196, 9337) + // Standard Error: 824 + .saturating_add(Weight::from_ref_time(54_603).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(64).saturating_mul(m.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:0 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 53_033 nanoseconds. - Weight::from_ref_time(44_608_804) - // Standard Error: 2_306 - .saturating_add(Weight::from_ref_time(102_842).saturating_mul(m.into())) - // Standard Error: 2_248 - .saturating_add(Weight::from_ref_time(172_018).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) - // Storage: AllianceMotion Proposals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `730 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `11979 + m * (388 ±0) + p * (148 ±0)` + // Minimum execution time: 35_373 nanoseconds. + Weight::from_parts(32_763_656, 11979) + // Standard Error: 2_041 + .saturating_add(Weight::from_ref_time(52_915).saturating_mul(m.into())) + // Standard Error: 1_991 + .saturating_add(Weight::from_ref_time(78_594).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(388).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(148).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:1 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 61_157 nanoseconds. - Weight::from_ref_time(53_647_510) - // Standard Error: 235 - .saturating_add(Weight::from_ref_time(88).saturating_mul(b.into())) - // Standard Error: 2_486 - .saturating_add(Weight::from_ref_time(103_912).saturating_mul(m.into())) - // Standard Error: 2_424 - .saturating_add(Weight::from_ref_time(197_471).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion Prime (r:1 w:0) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `1139 + m * (96 ±0) + p * (41 ±0)` + // Estimated: `15730 + m * (388 ±0) + p * (164 ±0)` + // Minimum execution time: 44_590 nanoseconds. + Weight::from_parts(43_367_913, 15730) + // Standard Error: 71 + .saturating_add(Weight::from_ref_time(819).saturating_mul(b.into())) + // Standard Error: 751 + .saturating_add(Weight::from_ref_time(39_124).saturating_mul(m.into())) + // Standard Error: 732 + .saturating_add(Weight::from_ref_time(90_469).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(388).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(164).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:1 w:0) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:0 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 53_830 nanoseconds. - Weight::from_ref_time(43_926_698) - // Standard Error: 2_495 - .saturating_add(Weight::from_ref_time(112_814).saturating_mul(m.into())) - // Standard Error: 2_465 - .saturating_add(Weight::from_ref_time(186_422).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion Prime (r:1 w:0) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `730 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `13201 + m * (485 ±0) + p * (185 ±0)` + // Minimum execution time: 36_796 nanoseconds. + Weight::from_parts(34_578_765, 13201) + // Standard Error: 1_037 + .saturating_add(Weight::from_ref_time(43_508).saturating_mul(m.into())) + // Standard Error: 1_024 + .saturating_add(Weight::from_ref_time(77_084).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(485).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(185).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:1 w:0) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:0 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[5, 100]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(_b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 53_665 nanoseconds. - Weight::from_ref_time(44_914_913) - // Standard Error: 2_244 - .saturating_add(Weight::from_ref_time(105_848).saturating_mul(m.into())) - // Standard Error: 2_164 - .saturating_add(Weight::from_ref_time(190_830).saturating_mul(p.into())) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:2 w:2) - // Storage: AllianceMotion Members (r:1 w:1) + fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `757 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `13146 + m * (480 ±0) + p * (185 ±0)` + // Minimum execution time: 36_897 nanoseconds. + Weight::from_parts(34_169_666, 13146) + // Standard Error: 47 + .saturating_add(Weight::from_ref_time(972).saturating_mul(b.into())) + // Standard Error: 510 + .saturating_add(Weight::from_ref_time(38_084).saturating_mul(m.into())) + // Standard Error: 492 + .saturating_add(Weight::from_ref_time(78_576).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(480).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(185).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:2 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Members (r:1 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. /// The range of component `z` is `[0, 100]`. fn init_members(m: u32, z: u32, ) -> Weight { - // Minimum execution time: 46_486 nanoseconds. - Weight::from_ref_time(34_596_922) - // Standard Error: 1_807 - .saturating_add(Weight::from_ref_time(143_225).saturating_mul(m.into())) - // Standard Error: 1_786 - .saturating_add(Weight::from_ref_time(125_729).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:2 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: Alliance DepositOf (r:101 w:50) - // Storage: System Account (r:50 w:50) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `217` + // Estimated: `12084` + // Minimum execution time: 29_313 nanoseconds. + Weight::from_parts(20_502_244, 12084) + // Standard Error: 304 + .saturating_add(Weight::from_ref_time(107_994).saturating_mul(m.into())) + // Standard Error: 300 + .saturating_add(Weight::from_ref_time(92_645).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Alliance Members (r:2 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Alliance DepositOf (r:200 w:50) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: System Account (r:50 w:50) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `x` is `[1, 100]`. /// The range of component `y` is `[0, 100]`. /// The range of component `z` is `[0, 50]`. fn disband(x: u32, y: u32, z: u32, ) -> Weight { - // Minimum execution time: 251_640 nanoseconds. - Weight::from_ref_time(252_446_000) - // Standard Error: 20_419 - .saturating_add(Weight::from_ref_time(486_667).saturating_mul(x.into())) - // Standard Error: 20_320 - .saturating_add(Weight::from_ref_time(498_890).saturating_mul(y.into())) - // Standard Error: 40_604 - .saturating_add(Weight::from_ref_time(9_411_242).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Proof Size summary in bytes: + // Measured: `0 + x * (50 ±0) + y * (51 ±0) + z * (283 ±0)` + // Estimated: `32201 + x * (2587 ±0) + y * (2590 ±0) + z * (3209 ±1)` + // Minimum execution time: 232_895 nanoseconds. + Weight::from_parts(233_860_000, 32201) + // Standard Error: 19_092 + .saturating_add(Weight::from_ref_time(445_664).saturating_mul(x.into())) + // Standard Error: 19_000 + .saturating_add(Weight::from_ref_time(432_571).saturating_mul(y.into())) + // Standard Error: 37_965 + .saturating_add(Weight::from_ref_time(9_386_151).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(z.into()))) + .saturating_add(Weight::from_proof_size(2587).saturating_mul(x.into())) + .saturating_add(Weight::from_proof_size(2590).saturating_mul(y.into())) + .saturating_add(Weight::from_proof_size(3209).saturating_mul(z.into())) } - // Storage: Alliance Rule (r:0 w:1) + /// Storage: Alliance Rule (r:0 w:1) + /// Proof: Alliance Rule (max_values: Some(1), max_size: Some(87), added: 582, mode: MaxEncodedLen) fn set_rule() -> Weight { - // Minimum execution time: 18_867 nanoseconds. - Weight::from_ref_time(19_155_000) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Alliance Announcements (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_156 nanoseconds. + Weight::from_ref_time(9_376_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Announcements (r:1 w:1) + /// Proof: Alliance Announcements (max_values: Some(1), max_size: Some(8702), added: 9197, mode: MaxEncodedLen) fn announce() -> Weight { - // Minimum execution time: 21_942 nanoseconds. - Weight::from_ref_time(22_319_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Alliance Announcements (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `9197` + // Minimum execution time: 12_163 nanoseconds. + Weight::from_parts(12_397_000, 9197) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Announcements (r:1 w:1) + /// Proof: Alliance Announcements (max_values: Some(1), max_size: Some(8702), added: 9197, mode: MaxEncodedLen) fn remove_announcement() -> Weight { - // Minimum execution time: 23_419 nanoseconds. - Weight::from_ref_time(23_854_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Alliance Members (r:3 w:1) - // Storage: Alliance UnscrupulousAccounts (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Alliance DepositOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `9197` + // Minimum execution time: 12_778 nanoseconds. + Weight::from_parts(12_991_000, 9197) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Members (r:3 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousAccounts (r:1 w:0) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Alliance DepositOf (r:0 w:1) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) fn join_alliance() -> Weight { - // Minimum execution time: 53_016 nanoseconds. - Weight::from_ref_time(53_768_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:3 w:1) - // Storage: Alliance UnscrupulousAccounts (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `562` + // Estimated: `23358` + // Minimum execution time: 40_216 nanoseconds. + Weight::from_parts(40_535_000, 23358) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Alliance Members (r:3 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousAccounts (r:1 w:0) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) fn nominate_ally() -> Weight { - // Minimum execution time: 40_019 nanoseconds. - Weight::from_ref_time(41_087_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Alliance Members (r:2 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `429` + // Estimated: `20755` + // Minimum execution time: 28_027 nanoseconds. + Weight::from_parts(28_392_000, 20755) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Members (r:2 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn elevate_ally() -> Weight { - // Minimum execution time: 35_973 nanoseconds. - Weight::from_ref_time(36_365_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Alliance Members (r:4 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) - // Storage: Alliance RetiringMembers (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `13382` + // Minimum execution time: 24_427 nanoseconds. + Weight::from_parts(24_952_000, 13382) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Alliance Members (r:4 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Alliance RetiringMembers (r:0 w:1) + /// Proof: Alliance RetiringMembers (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn give_retirement_notice() -> Weight { - // Minimum execution time: 44_949 nanoseconds. - Weight::from_ref_time(46_284_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: Alliance RetiringMembers (r:1 w:1) - // Storage: Alliance Members (r:1 w:1) - // Storage: Alliance DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `24754` + // Minimum execution time: 33_163 nanoseconds. + Weight::from_parts(33_556_000, 24754) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Alliance RetiringMembers (r:1 w:1) + /// Proof: Alliance RetiringMembers (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Alliance Members (r:1 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: Alliance DepositOf (r:1 w:1) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn retire() -> Weight { - // Minimum execution time: 45_989 nanoseconds. - Weight::from_ref_time(46_586_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Alliance Members (r:3 w:1) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: Alliance DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `750` + // Estimated: `13355` + // Minimum execution time: 32_980 nanoseconds. + Weight::from_parts(33_452_000, 13355) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Alliance Members (r:3 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Alliance DepositOf (r:1 w:1) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn kick_member() -> Weight { - // Minimum execution time: 67_333 nanoseconds. - Weight::from_ref_time(68_302_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: Alliance UnscrupulousAccounts (r:1 w:1) - // Storage: Alliance UnscrupulousWebsites (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `801` + // Estimated: `25098` + // Minimum execution time: 54_660 nanoseconds. + Weight::from_parts(55_186_000, 25098) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Alliance UnscrupulousAccounts (r:1 w:1) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousWebsites (r:1 w:1) + /// Proof: Alliance UnscrupulousWebsites (max_values: Some(1), max_size: Some(25702), added: 26197, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. /// The range of component `l` is `[0, 255]`. fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { - // Minimum execution time: 16_911 nanoseconds. - Weight::from_ref_time(17_204_000) - // Standard Error: 2_688 - .saturating_add(Weight::from_ref_time(1_324_527).saturating_mul(n.into())) - // Standard Error: 1_052 - .saturating_add(Weight::from_ref_time(73_828).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Alliance UnscrupulousAccounts (r:1 w:1) - // Storage: Alliance UnscrupulousWebsites (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `29894` + // Minimum execution time: 7_709 nanoseconds. + Weight::from_parts(7_773_000, 29894) + // Standard Error: 2_645 + .saturating_add(Weight::from_ref_time(1_266_755).saturating_mul(n.into())) + // Standard Error: 1_036 + .saturating_add(Weight::from_ref_time(67_359).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Alliance UnscrupulousAccounts (r:1 w:1) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousWebsites (r:1 w:1) + /// Proof: Alliance UnscrupulousWebsites (max_values: Some(1), max_size: Some(25702), added: 26197, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. /// The range of component `l` is `[0, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { - // Minimum execution time: 17_117 nanoseconds. - Weight::from_ref_time(17_291_000) - // Standard Error: 166_132 - .saturating_add(Weight::from_ref_time(13_173_211).saturating_mul(n.into())) - // Standard Error: 65_064 - .saturating_add(Weight::from_ref_time(478_626).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Alliance Members (r:3 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0 + n * (289 ±0) + l * (100 ±0)` + // Estimated: `29894` + // Minimum execution time: 7_438 nanoseconds. + Weight::from_parts(7_570_000, 29894) + // Standard Error: 165_072 + .saturating_add(Weight::from_ref_time(13_026_975).saturating_mul(n.into())) + // Standard Error: 64_649 + .saturating_add(Weight::from_ref_time(485_565).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Alliance Members (r:3 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn abdicate_fellow_status() -> Weight { - // Minimum execution time: 43_347 nanoseconds. - Weight::from_ref_time(43_986_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `19068` + // Minimum execution time: 31_326 nanoseconds. + Weight::from_parts(31_768_000, 19068) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalCount (r:1 w:1) - // Storage: AllianceMotion Voting (r:0 w:1) + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion ProposalOf (r:1 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalCount (r:1 w:1) + /// Proof Skipped: AllianceMotion ProposalCount (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Voting (r:0 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. - fn propose_proposed(_b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 45_945 nanoseconds. - Weight::from_ref_time(44_195_340) - // Standard Error: 2_212 - .saturating_add(Weight::from_ref_time(73_715).saturating_mul(m.into())) - // Standard Error: 2_184 - .saturating_add(Weight::from_ref_time(172_373).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) + fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `692 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `11659 + m * (132 ±0) + p * (144 ±0)` + // Minimum execution time: 28_849 nanoseconds. + Weight::from_parts(29_823_933, 11659) + // Standard Error: 74 + .saturating_add(Weight::from_ref_time(830).saturating_mul(b.into())) + // Standard Error: 775 + .saturating_add(Weight::from_ref_time(22_980).saturating_mul(m.into())) + // Standard Error: 765 + .saturating_add(Weight::from_ref_time(90_520).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_proof_size(132).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(144).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - // Minimum execution time: 41_578 nanoseconds. - Weight::from_ref_time(44_299_385) - // Standard Error: 3_727 - .saturating_add(Weight::from_ref_time(138_681).saturating_mul(m.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `1177 + m * (64 ±0)` + // Estimated: `9337 + m * (64 ±0)` + // Minimum execution time: 23_570 nanoseconds. + Weight::from_parts(25_473_196, 9337) + // Standard Error: 824 + .saturating_add(Weight::from_ref_time(54_603).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(64).saturating_mul(m.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:0 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 53_033 nanoseconds. - Weight::from_ref_time(44_608_804) - // Standard Error: 2_306 - .saturating_add(Weight::from_ref_time(102_842).saturating_mul(m.into())) - // Standard Error: 2_248 - .saturating_add(Weight::from_ref_time(172_018).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) - // Storage: AllianceMotion Proposals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `730 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `11979 + m * (388 ±0) + p * (148 ±0)` + // Minimum execution time: 35_373 nanoseconds. + Weight::from_parts(32_763_656, 11979) + // Standard Error: 2_041 + .saturating_add(Weight::from_ref_time(52_915).saturating_mul(m.into())) + // Standard Error: 1_991 + .saturating_add(Weight::from_ref_time(78_594).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(388).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(148).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:1 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 61_157 nanoseconds. - Weight::from_ref_time(53_647_510) - // Standard Error: 235 - .saturating_add(Weight::from_ref_time(88).saturating_mul(b.into())) - // Standard Error: 2_486 - .saturating_add(Weight::from_ref_time(103_912).saturating_mul(m.into())) - // Standard Error: 2_424 - .saturating_add(Weight::from_ref_time(197_471).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion Prime (r:1 w:0) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `1139 + m * (96 ±0) + p * (41 ±0)` + // Estimated: `15730 + m * (388 ±0) + p * (164 ±0)` + // Minimum execution time: 44_590 nanoseconds. + Weight::from_parts(43_367_913, 15730) + // Standard Error: 71 + .saturating_add(Weight::from_ref_time(819).saturating_mul(b.into())) + // Standard Error: 751 + .saturating_add(Weight::from_ref_time(39_124).saturating_mul(m.into())) + // Standard Error: 732 + .saturating_add(Weight::from_ref_time(90_469).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(388).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(164).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:1 w:0) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:0 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 53_830 nanoseconds. - Weight::from_ref_time(43_926_698) - // Standard Error: 2_495 - .saturating_add(Weight::from_ref_time(112_814).saturating_mul(m.into())) - // Standard Error: 2_465 - .saturating_add(Weight::from_ref_time(186_422).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion Voting (r:1 w:1) - // Storage: AllianceMotion Members (r:1 w:0) - // Storage: AllianceMotion Prime (r:1 w:0) - // Storage: AllianceMotion Proposals (r:1 w:1) - // Storage: AllianceMotion ProposalOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `730 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `13201 + m * (485 ±0) + p * (185 ±0)` + // Minimum execution time: 36_796 nanoseconds. + Weight::from_parts(34_578_765, 13201) + // Standard Error: 1_037 + .saturating_add(Weight::from_ref_time(43_508).saturating_mul(m.into())) + // Standard Error: 1_024 + .saturating_add(Weight::from_ref_time(77_084).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(485).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(185).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:1 w:0) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Voting (r:1 w:1) + /// Proof Skipped: AllianceMotion Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:1 w:0) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:1 w:0) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Proposals (r:1 w:1) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion ProposalOf (r:0 w:1) + /// Proof Skipped: AllianceMotion ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `b` is `[1, 1024]`. /// The range of component `m` is `[5, 100]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(_b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 53_665 nanoseconds. - Weight::from_ref_time(44_914_913) - // Standard Error: 2_244 - .saturating_add(Weight::from_ref_time(105_848).saturating_mul(m.into())) - // Standard Error: 2_164 - .saturating_add(Weight::from_ref_time(190_830).saturating_mul(p.into())) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:2 w:2) - // Storage: AllianceMotion Members (r:1 w:1) + fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `757 + m * (96 ±0) + p * (36 ±0)` + // Estimated: `13146 + m * (480 ±0) + p * (185 ±0)` + // Minimum execution time: 36_897 nanoseconds. + Weight::from_parts(34_169_666, 13146) + // Standard Error: 47 + .saturating_add(Weight::from_ref_time(972).saturating_mul(b.into())) + // Standard Error: 510 + .saturating_add(Weight::from_ref_time(38_084).saturating_mul(m.into())) + // Standard Error: 492 + .saturating_add(Weight::from_ref_time(78_576).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(480).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(185).saturating_mul(p.into())) + } + /// Storage: Alliance Members (r:2 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Members (r:1 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. /// The range of component `z` is `[0, 100]`. fn init_members(m: u32, z: u32, ) -> Weight { - // Minimum execution time: 46_486 nanoseconds. - Weight::from_ref_time(34_596_922) - // Standard Error: 1_807 - .saturating_add(Weight::from_ref_time(143_225).saturating_mul(m.into())) - // Standard Error: 1_786 - .saturating_add(Weight::from_ref_time(125_729).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:2 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: Alliance DepositOf (r:101 w:50) - // Storage: System Account (r:50 w:50) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `217` + // Estimated: `12084` + // Minimum execution time: 29_313 nanoseconds. + Weight::from_parts(20_502_244, 12084) + // Standard Error: 304 + .saturating_add(Weight::from_ref_time(107_994).saturating_mul(m.into())) + // Standard Error: 300 + .saturating_add(Weight::from_ref_time(92_645).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Alliance Members (r:2 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Alliance DepositOf (r:200 w:50) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: System Account (r:50 w:50) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `x` is `[1, 100]`. /// The range of component `y` is `[0, 100]`. /// The range of component `z` is `[0, 50]`. fn disband(x: u32, y: u32, z: u32, ) -> Weight { - // Minimum execution time: 251_640 nanoseconds. - Weight::from_ref_time(252_446_000) - // Standard Error: 20_419 - .saturating_add(Weight::from_ref_time(486_667).saturating_mul(x.into())) - // Standard Error: 20_320 - .saturating_add(Weight::from_ref_time(498_890).saturating_mul(y.into())) - // Standard Error: 40_604 - .saturating_add(Weight::from_ref_time(9_411_242).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(3)) + // Proof Size summary in bytes: + // Measured: `0 + x * (50 ±0) + y * (51 ±0) + z * (283 ±0)` + // Estimated: `32201 + x * (2587 ±0) + y * (2590 ±0) + z * (3209 ±1)` + // Minimum execution time: 232_895 nanoseconds. + Weight::from_parts(233_860_000, 32201) + // Standard Error: 19_092 + .saturating_add(Weight::from_ref_time(445_664).saturating_mul(x.into())) + // Standard Error: 19_000 + .saturating_add(Weight::from_ref_time(432_571).saturating_mul(y.into())) + // Standard Error: 37_965 + .saturating_add(Weight::from_ref_time(9_386_151).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(RocksDbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(z.into()))) + .saturating_add(Weight::from_proof_size(2587).saturating_mul(x.into())) + .saturating_add(Weight::from_proof_size(2590).saturating_mul(y.into())) + .saturating_add(Weight::from_proof_size(3209).saturating_mul(z.into())) } - // Storage: Alliance Rule (r:0 w:1) + /// Storage: Alliance Rule (r:0 w:1) + /// Proof: Alliance Rule (max_values: Some(1), max_size: Some(87), added: 582, mode: MaxEncodedLen) fn set_rule() -> Weight { - // Minimum execution time: 18_867 nanoseconds. - Weight::from_ref_time(19_155_000) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Alliance Announcements (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_156 nanoseconds. + Weight::from_ref_time(9_376_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Announcements (r:1 w:1) + /// Proof: Alliance Announcements (max_values: Some(1), max_size: Some(8702), added: 9197, mode: MaxEncodedLen) fn announce() -> Weight { - // Minimum execution time: 21_942 nanoseconds. - Weight::from_ref_time(22_319_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Alliance Announcements (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `9197` + // Minimum execution time: 12_163 nanoseconds. + Weight::from_parts(12_397_000, 9197) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Announcements (r:1 w:1) + /// Proof: Alliance Announcements (max_values: Some(1), max_size: Some(8702), added: 9197, mode: MaxEncodedLen) fn remove_announcement() -> Weight { - // Minimum execution time: 23_419 nanoseconds. - Weight::from_ref_time(23_854_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Alliance Members (r:3 w:1) - // Storage: Alliance UnscrupulousAccounts (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Alliance DepositOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `9197` + // Minimum execution time: 12_778 nanoseconds. + Weight::from_parts(12_991_000, 9197) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Members (r:3 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousAccounts (r:1 w:0) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Alliance DepositOf (r:0 w:1) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) fn join_alliance() -> Weight { - // Minimum execution time: 53_016 nanoseconds. - Weight::from_ref_time(53_768_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Alliance Members (r:3 w:1) - // Storage: Alliance UnscrupulousAccounts (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `562` + // Estimated: `23358` + // Minimum execution time: 40_216 nanoseconds. + Weight::from_parts(40_535_000, 23358) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Alliance Members (r:3 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousAccounts (r:1 w:0) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) fn nominate_ally() -> Weight { - // Minimum execution time: 40_019 nanoseconds. - Weight::from_ref_time(41_087_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Alliance Members (r:2 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `429` + // Estimated: `20755` + // Minimum execution time: 28_027 nanoseconds. + Weight::from_parts(28_392_000, 20755) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Alliance Members (r:2 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn elevate_ally() -> Weight { - // Minimum execution time: 35_973 nanoseconds. - Weight::from_ref_time(36_365_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Alliance Members (r:4 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) - // Storage: Alliance RetiringMembers (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `13382` + // Minimum execution time: 24_427 nanoseconds. + Weight::from_parts(24_952_000, 13382) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Alliance Members (r:4 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Alliance RetiringMembers (r:0 w:1) + /// Proof: Alliance RetiringMembers (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn give_retirement_notice() -> Weight { - // Minimum execution time: 44_949 nanoseconds. - Weight::from_ref_time(46_284_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(5)) - } - // Storage: Alliance RetiringMembers (r:1 w:1) - // Storage: Alliance Members (r:1 w:1) - // Storage: Alliance DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `24754` + // Minimum execution time: 33_163 nanoseconds. + Weight::from_parts(33_556_000, 24754) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Alliance RetiringMembers (r:1 w:1) + /// Proof: Alliance RetiringMembers (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Alliance Members (r:1 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: Alliance DepositOf (r:1 w:1) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn retire() -> Weight { - // Minimum execution time: 45_989 nanoseconds. - Weight::from_ref_time(46_586_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Alliance Members (r:3 w:1) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: Alliance DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `750` + // Estimated: `13355` + // Minimum execution time: 32_980 nanoseconds. + Weight::from_parts(33_452_000, 13355) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Alliance Members (r:3 w:1) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Alliance DepositOf (r:1 w:1) + /// Proof: Alliance DepositOf (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn kick_member() -> Weight { - // Minimum execution time: 67_333 nanoseconds. - Weight::from_ref_time(68_302_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(5)) - } - // Storage: Alliance UnscrupulousAccounts (r:1 w:1) - // Storage: Alliance UnscrupulousWebsites (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `801` + // Estimated: `25098` + // Minimum execution time: 54_660 nanoseconds. + Weight::from_parts(55_186_000, 25098) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Alliance UnscrupulousAccounts (r:1 w:1) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousWebsites (r:1 w:1) + /// Proof: Alliance UnscrupulousWebsites (max_values: Some(1), max_size: Some(25702), added: 26197, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. /// The range of component `l` is `[0, 255]`. fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { - // Minimum execution time: 16_911 nanoseconds. - Weight::from_ref_time(17_204_000) - // Standard Error: 2_688 - .saturating_add(Weight::from_ref_time(1_324_527).saturating_mul(n.into())) - // Standard Error: 1_052 - .saturating_add(Weight::from_ref_time(73_828).saturating_mul(l.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Alliance UnscrupulousAccounts (r:1 w:1) - // Storage: Alliance UnscrupulousWebsites (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `246` + // Estimated: `29894` + // Minimum execution time: 7_709 nanoseconds. + Weight::from_parts(7_773_000, 29894) + // Standard Error: 2_645 + .saturating_add(Weight::from_ref_time(1_266_755).saturating_mul(n.into())) + // Standard Error: 1_036 + .saturating_add(Weight::from_ref_time(67_359).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Alliance UnscrupulousAccounts (r:1 w:1) + /// Proof: Alliance UnscrupulousAccounts (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: Alliance UnscrupulousWebsites (r:1 w:1) + /// Proof: Alliance UnscrupulousWebsites (max_values: Some(1), max_size: Some(25702), added: 26197, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. /// The range of component `l` is `[0, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { - // Minimum execution time: 17_117 nanoseconds. - Weight::from_ref_time(17_291_000) - // Standard Error: 166_132 - .saturating_add(Weight::from_ref_time(13_173_211).saturating_mul(n.into())) - // Standard Error: 65_064 - .saturating_add(Weight::from_ref_time(478_626).saturating_mul(l.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Alliance Members (r:3 w:2) - // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: AllianceMotion Members (r:0 w:1) - // Storage: AllianceMotion Prime (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0 + n * (289 ±0) + l * (100 ±0)` + // Estimated: `29894` + // Minimum execution time: 7_438 nanoseconds. + Weight::from_parts(7_570_000, 29894) + // Standard Error: 165_072 + .saturating_add(Weight::from_ref_time(13_026_975).saturating_mul(n.into())) + // Standard Error: 64_649 + .saturating_add(Weight::from_ref_time(485_565).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Alliance Members (r:3 w:2) + /// Proof: Alliance Members (max_values: None, max_size: Some(3211), added: 5686, mode: MaxEncodedLen) + /// Storage: AllianceMotion Proposals (r:1 w:0) + /// Proof Skipped: AllianceMotion Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Members (r:0 w:1) + /// Proof Skipped: AllianceMotion Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: AllianceMotion Prime (r:0 w:1) + /// Proof Skipped: AllianceMotion Prime (max_values: Some(1), max_size: None, mode: Measured) fn abdicate_fellow_status() -> Weight { - // Minimum execution time: 43_347 nanoseconds. - Weight::from_ref_time(43_986_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `505` + // Estimated: `19068` + // Minimum execution time: 31_326 nanoseconds. + Weight::from_parts(31_768_000, 19068) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } } diff --git a/frame/assets/src/weights.rs b/frame/assets/src/weights.rs index 747198ae3e..c2028105cd 100644 --- a/frame/assets/src/weights.rs +++ b/frame/assets/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_assets //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -50,8 +51,8 @@ pub trait WeightInfo { fn create() -> Weight; fn force_create() -> Weight; fn start_destroy() -> Weight; - fn destroy_accounts(c: u32) -> Weight; - fn destroy_approvals(m: u32) -> Weight; + fn destroy_accounts(c: u32, ) -> Weight; + fn destroy_approvals(a: u32, ) -> Weight; fn finish_destroy() -> Weight; fn mint() -> Weight; fn burn() -> Weight; @@ -78,464 +79,728 @@ pub trait WeightInfo { /// Weights for pallet_assets using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Assets Asset (r:1 w:1) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 33_241 nanoseconds. - Weight::from_ref_time(33_873_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `325` + // Estimated: `5288` + // Minimum execution time: 23_623 nanoseconds. + Weight::from_parts(24_072_000, 5288) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn force_create() -> Weight { - // Minimum execution time: 19_883 nanoseconds. - Weight::from_ref_time(20_651_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `153` + // Estimated: `2685` + // Minimum execution time: 13_145 nanoseconds. + Weight::from_parts(13_572_000, 2685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn start_destroy() -> Weight { - Weight::from_ref_time(31_000_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:0) - // Storage: System Account (r:20 w:20) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `2685` + // Minimum execution time: 13_420 nanoseconds. + Weight::from_parts(13_649_000, 2685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1000 w:1000) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `c` is `[0, 1000]`. fn destroy_accounts(c: u32, ) -> Weight { - Weight::from_ref_time(37_000_000 as u64) - // Standard Error: 19_301 - .saturating_add(Weight::from_ref_time(25_467_908 as u64).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64))) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `25 + c * (240 ±0)` + // Estimated: `5262 + c * (5180 ±0)` + // Minimum execution time: 17_565 nanoseconds. + Weight::from_parts(17_757_000, 5262) + // Standard Error: 15_192 + .saturating_add(Weight::from_ref_time(13_799_167).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_proof_size(5180).saturating_mul(c.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) /// The range of component `a` is `[0, 1000]`. fn destroy_approvals(a: u32, ) -> Weight { - Weight::from_ref_time(39_000_000 as u64) - // Standard Error: 14_298 - .saturating_add(Weight::from_ref_time(27_632_144 as u64).saturating_mul(a as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(a as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(a as u64))) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Metadata (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `554 + a * (86 ±0)` + // Estimated: `5308 + a * (2623 ±0)` + // Minimum execution time: 18_251 nanoseconds. + Weight::from_parts(18_359_000, 5308) + // Standard Error: 10_051 + .saturating_add(Weight::from_ref_time(13_613_342).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_proof_size(2623).saturating_mul(a.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn finish_destroy() -> Weight { - Weight::from_ref_time(33_000_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5300` + // Minimum execution time: 14_344 nanoseconds. + Weight::from_parts(14_619_000, 5300) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn mint() -> Weight { - // Minimum execution time: 36_782 nanoseconds. - Weight::from_ref_time(37_340_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5262` + // Minimum execution time: 24_992 nanoseconds. + Weight::from_parts(25_784_000, 5262) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn burn() -> Weight { - // Minimum execution time: 44_425 nanoseconds. - Weight::from_ref_time(45_485_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `491` + // Estimated: `5262` + // Minimum execution time: 31_233 nanoseconds. + Weight::from_parts(31_511_000, 5262) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 58_294 nanoseconds. - Weight::from_ref_time(59_447_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `10442` + // Minimum execution time: 43_002 nanoseconds. + Weight::from_parts(43_533_000, 10442) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { - // Minimum execution time: 46_704 nanoseconds. - Weight::from_ref_time(47_521_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `10442` + // Minimum execution time: 38_220 nanoseconds. + Weight::from_parts(38_639_000, 10442) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { - // Minimum execution time: 57_647 nanoseconds. - Weight::from_ref_time(58_417_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `10442` + // Minimum execution time: 43_171 nanoseconds. + Weight::from_parts(43_543_000, 10442) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn freeze() -> Weight { - // Minimum execution time: 26_827 nanoseconds. - Weight::from_ref_time(27_373_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `491` + // Estimated: `5262` + // Minimum execution time: 16_972 nanoseconds. + Weight::from_parts(17_498_000, 5262) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn thaw() -> Weight { - // Minimum execution time: 26_291 nanoseconds. - Weight::from_ref_time(26_854_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `491` + // Estimated: `5262` + // Minimum execution time: 17_471 nanoseconds. + Weight::from_parts(17_842_000, 5262) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn freeze_asset() -> Weight { - // Minimum execution time: 22_694 nanoseconds. - Weight::from_ref_time(23_613_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `2685` + // Minimum execution time: 13_497 nanoseconds. + Weight::from_parts(13_719_000, 2685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn thaw_asset() -> Weight { - // Minimum execution time: 22_572 nanoseconds. - Weight::from_ref_time(24_121_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Metadata (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `2685` + // Minimum execution time: 13_424 nanoseconds. + Weight::from_parts(13_764_000, 2685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { - // Minimum execution time: 23_949 nanoseconds. - Weight::from_ref_time(24_347_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5300` + // Minimum execution time: 15_028 nanoseconds. + Weight::from_parts(15_366_000, 5300) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn set_team() -> Weight { - // Minimum execution time: 23_102 nanoseconds. - Weight::from_ref_time(23_518_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `2685` + // Minimum execution time: 14_197 nanoseconds. + Weight::from_parts(14_437_000, 2685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn set_metadata(_n: u32, s: u32, ) -> Weight { - // Minimum execution time: 41_032 nanoseconds. - Weight::from_ref_time(42_845_624 as u64) - // Standard Error: 1_274 - .saturating_add(Weight::from_ref_time(1_875 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + fn set_metadata(n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5300` + // Minimum execution time: 23_707 nanoseconds. + Weight::from_parts(24_466_834, 5300) + // Standard Error: 635 + .saturating_add(Weight::from_ref_time(730).saturating_mul(n.into())) + // Standard Error: 635 + .saturating_add(Weight::from_ref_time(3_975).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 42_570 nanoseconds. - Weight::from_ref_time(42_957_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `5300` + // Minimum execution time: 23_997 nanoseconds. + Weight::from_parts(24_812_000, 5300) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn force_set_metadata(n: u32, s: u32, ) -> Weight { - // Minimum execution time: 22_768 nanoseconds. - Weight::from_ref_time(23_868_816 as u64) - // Standard Error: 612 - .saturating_add(Weight::from_ref_time(1_602 as u64).saturating_mul(n as u64)) - // Standard Error: 612 - .saturating_add(Weight::from_ref_time(2_097 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + fn force_set_metadata(_n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `190` + // Estimated: `5300` + // Minimum execution time: 14_028 nanoseconds. + Weight::from_parts(15_217_669, 5300) + // Standard Error: 2_266 + .saturating_add(Weight::from_ref_time(2_045).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn force_clear_metadata() -> Weight { - // Minimum execution time: 41_863 nanoseconds. - Weight::from_ref_time(42_643_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `5300` + // Minimum execution time: 23_754 nanoseconds. + Weight::from_parts(24_154_000, 5300) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn force_asset_status() -> Weight { - // Minimum execution time: 21_747 nanoseconds. - Weight::from_ref_time(22_595_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `2685` + // Minimum execution time: 13_128 nanoseconds. + Weight::from_parts(13_428_000, 2685) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn approve_transfer() -> Weight { - // Minimum execution time: 45_602 nanoseconds. - Weight::from_ref_time(46_004_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Assets Approvals (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `5308` + // Minimum execution time: 27_224 nanoseconds. + Weight::from_parts(27_665_000, 5308) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_approved() -> Weight { - // Minimum execution time: 70_944 nanoseconds. - Weight::from_ref_time(71_722_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `700` + // Estimated: `13065` + // Minimum execution time: 55_837 nanoseconds. + Weight::from_parts(56_636_000, 13065) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn cancel_approval() -> Weight { - // Minimum execution time: 46_316 nanoseconds. - Weight::from_ref_time(46_910_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `587` + // Estimated: `5308` + // Minimum execution time: 28_915 nanoseconds. + Weight::from_parts(29_325_000, 5308) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn force_cancel_approval() -> Weight { - // Minimum execution time: 47_145 nanoseconds. - Weight::from_ref_time(47_611_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `587` + // Estimated: `5308` + // Minimum execution time: 29_103 nanoseconds. + Weight::from_parts(29_599_000, 5308) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Assets Asset (r:1 w:1) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 33_241 nanoseconds. - Weight::from_ref_time(33_873_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `325` + // Estimated: `5288` + // Minimum execution time: 23_623 nanoseconds. + Weight::from_parts(24_072_000, 5288) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn force_create() -> Weight { - // Minimum execution time: 19_883 nanoseconds. - Weight::from_ref_time(20_651_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `153` + // Estimated: `2685` + // Minimum execution time: 13_145 nanoseconds. + Weight::from_parts(13_572_000, 2685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn start_destroy() -> Weight { - Weight::from_ref_time(31_000_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:0) - // Storage: System Account (r:20 w:20) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `2685` + // Minimum execution time: 13_420 nanoseconds. + Weight::from_parts(13_649_000, 2685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1001 w:1000) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1000 w:1000) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `c` is `[0, 1000]`. fn destroy_accounts(c: u32, ) -> Weight { - Weight::from_ref_time(37_000_000 as u64) - // Standard Error: 19_301 - .saturating_add(Weight::from_ref_time(25_467_908 as u64).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64))) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `25 + c * (240 ±0)` + // Estimated: `5262 + c * (5180 ±0)` + // Minimum execution time: 17_565 nanoseconds. + Weight::from_parts(17_757_000, 5262) + // Standard Error: 15_192 + .saturating_add(Weight::from_ref_time(13_799_167).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(c.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_proof_size(5180).saturating_mul(c.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1001 w:1000) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) /// The range of component `a` is `[0, 1000]`. fn destroy_approvals(a: u32, ) -> Weight { - Weight::from_ref_time(39_000_000 as u64) - // Standard Error: 14_298 - .saturating_add(Weight::from_ref_time(27_632_144 as u64).saturating_mul(a as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(a as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(a as u64))) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Metadata (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `554 + a * (86 ±0)` + // Estimated: `5308 + a * (2623 ±0)` + // Minimum execution time: 18_251 nanoseconds. + Weight::from_parts(18_359_000, 5308) + // Standard Error: 10_051 + .saturating_add(Weight::from_ref_time(13_613_342).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_proof_size(2623).saturating_mul(a.into())) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn finish_destroy() -> Weight { - Weight::from_ref_time(33_000_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5300` + // Minimum execution time: 14_344 nanoseconds. + Weight::from_parts(14_619_000, 5300) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn mint() -> Weight { - // Minimum execution time: 36_782 nanoseconds. - Weight::from_ref_time(37_340_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5262` + // Minimum execution time: 24_992 nanoseconds. + Weight::from_parts(25_784_000, 5262) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn burn() -> Weight { - // Minimum execution time: 44_425 nanoseconds. - Weight::from_ref_time(45_485_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `491` + // Estimated: `5262` + // Minimum execution time: 31_233 nanoseconds. + Weight::from_parts(31_511_000, 5262) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 58_294 nanoseconds. - Weight::from_ref_time(59_447_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `10442` + // Minimum execution time: 43_002 nanoseconds. + Weight::from_parts(43_533_000, 10442) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { - // Minimum execution time: 46_704 nanoseconds. - Weight::from_ref_time(47_521_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `10442` + // Minimum execution time: 38_220 nanoseconds. + Weight::from_parts(38_639_000, 10442) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { - // Minimum execution time: 57_647 nanoseconds. - Weight::from_ref_time(58_417_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `530` + // Estimated: `10442` + // Minimum execution time: 43_171 nanoseconds. + Weight::from_parts(43_543_000, 10442) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn freeze() -> Weight { - // Minimum execution time: 26_827 nanoseconds. - Weight::from_ref_time(27_373_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `491` + // Estimated: `5262` + // Minimum execution time: 16_972 nanoseconds. + Weight::from_parts(17_498_000, 5262) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn thaw() -> Weight { - // Minimum execution time: 26_291 nanoseconds. - Weight::from_ref_time(26_854_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `491` + // Estimated: `5262` + // Minimum execution time: 17_471 nanoseconds. + Weight::from_parts(17_842_000, 5262) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn freeze_asset() -> Weight { - // Minimum execution time: 22_694 nanoseconds. - Weight::from_ref_time(23_613_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `2685` + // Minimum execution time: 13_497 nanoseconds. + Weight::from_parts(13_719_000, 2685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn thaw_asset() -> Weight { - // Minimum execution time: 22_572 nanoseconds. - Weight::from_ref_time(24_121_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Metadata (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `2685` + // Minimum execution time: 13_424 nanoseconds. + Weight::from_parts(13_764_000, 2685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:0) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { - // Minimum execution time: 23_949 nanoseconds. - Weight::from_ref_time(24_347_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5300` + // Minimum execution time: 15_028 nanoseconds. + Weight::from_parts(15_366_000, 5300) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn set_team() -> Weight { - // Minimum execution time: 23_102 nanoseconds. - Weight::from_ref_time(23_518_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `2685` + // Minimum execution time: 14_197 nanoseconds. + Weight::from_parts(14_437_000, 2685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn set_metadata(_n: u32, s: u32, ) -> Weight { - // Minimum execution time: 41_032 nanoseconds. - Weight::from_ref_time(42_845_624 as u64) - // Standard Error: 1_274 - .saturating_add(Weight::from_ref_time(1_875 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + fn set_metadata(n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `5300` + // Minimum execution time: 23_707 nanoseconds. + Weight::from_parts(24_466_834, 5300) + // Standard Error: 635 + .saturating_add(Weight::from_ref_time(730).saturating_mul(n.into())) + // Standard Error: 635 + .saturating_add(Weight::from_ref_time(3_975).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 42_570 nanoseconds. - Weight::from_ref_time(42_957_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `5300` + // Minimum execution time: 23_997 nanoseconds. + Weight::from_parts(24_812_000, 5300) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) /// The range of component `n` is `[0, 50]`. /// The range of component `s` is `[0, 50]`. - fn force_set_metadata(n: u32, s: u32, ) -> Weight { - // Minimum execution time: 22_768 nanoseconds. - Weight::from_ref_time(23_868_816 as u64) - // Standard Error: 612 - .saturating_add(Weight::from_ref_time(1_602 as u64).saturating_mul(n as u64)) - // Standard Error: 612 - .saturating_add(Weight::from_ref_time(2_097 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:0) - // Storage: Assets Metadata (r:1 w:1) + fn force_set_metadata(_n: u32, s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `190` + // Estimated: `5300` + // Minimum execution time: 14_028 nanoseconds. + Weight::from_parts(15_217_669, 5300) + // Standard Error: 2_266 + .saturating_add(Weight::from_ref_time(2_045).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:0) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Metadata (r:1 w:1) + /// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn force_clear_metadata() -> Weight { - // Minimum execution time: 41_863 nanoseconds. - Weight::from_ref_time(42_643_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `579` + // Estimated: `5300` + // Minimum execution time: 23_754 nanoseconds. + Weight::from_parts(24_154_000, 5300) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) fn force_asset_status() -> Weight { - // Minimum execution time: 21_747 nanoseconds. - Weight::from_ref_time(22_595_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `383` + // Estimated: `2685` + // Minimum execution time: 13_128 nanoseconds. + Weight::from_parts(13_428_000, 2685) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn approve_transfer() -> Weight { - // Minimum execution time: 45_602 nanoseconds. - Weight::from_ref_time(46_004_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Assets Approvals (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:2 w:2) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `417` + // Estimated: `5308` + // Minimum execution time: 27_224 nanoseconds. + Weight::from_parts(27_665_000, 5308) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) + /// Storage: Assets Account (r:2 w:2) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_approved() -> Weight { - // Minimum execution time: 70_944 nanoseconds. - Weight::from_ref_time(71_722_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `700` + // Estimated: `13065` + // Minimum execution time: 55_837 nanoseconds. + Weight::from_parts(56_636_000, 13065) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn cancel_approval() -> Weight { - // Minimum execution time: 46_316 nanoseconds. - Weight::from_ref_time(46_910_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Approvals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `587` + // Estimated: `5308` + // Minimum execution time: 28_915 nanoseconds. + Weight::from_parts(29_325_000, 5308) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Approvals (r:1 w:1) + /// Proof: Assets Approvals (max_values: None, max_size: Some(148), added: 2623, mode: MaxEncodedLen) fn force_cancel_approval() -> Weight { - // Minimum execution time: 47_145 nanoseconds. - Weight::from_ref_time(47_611_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `587` + // Estimated: `5308` + // Minimum execution time: 29_103 nanoseconds. + Weight::from_parts(29_599_000, 5308) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/bags-list/src/weights.rs b/frame/bags-list/src/weights.rs index a298dc3172..d06f7b0db6 100644 --- a/frame/bags-list/src/weights.rs +++ b/frame/bags-list/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_bags_list //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -55,70 +56,114 @@ pub trait WeightInfo { /// Weights for pallet_bags_list using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: VoterList ListNodes (r:4 w:4) - // Storage: VoterList ListBags (r:1 w:1) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:4 w:4) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_non_terminal() -> Weight { - // Minimum execution time: 73_553 nanoseconds. - Weight::from_ref_time(74_366_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1916` + // Estimated: `19186` + // Minimum execution time: 54_348 nanoseconds. + Weight::from_parts(55_024_000, 19186) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_terminal() -> Weight { - // Minimum execution time: 72_700 nanoseconds. - Weight::from_ref_time(73_322_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1810` + // Estimated: `19114` + // Minimum execution time: 53_306 nanoseconds. + Weight::from_parts(54_263_000, 19114) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: VoterList ListNodes (r:4 w:4) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Ledger (r:2 w:0) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) + /// Storage: VoterList ListNodes (r:4 w:4) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:2 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:2 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn put_in_front_of() -> Weight { - // Minimum execution time: 71_691 nanoseconds. - Weight::from_ref_time(72_798_000 as u64) - .saturating_add(T::DbWeight::get().reads(10 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Proof Size summary in bytes: + // Measured: `2154` + // Estimated: `25798` + // Minimum execution time: 59_513 nanoseconds. + Weight::from_parts(60_717_000, 25798) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: VoterList ListNodes (r:4 w:4) - // Storage: VoterList ListBags (r:1 w:1) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:4 w:4) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_non_terminal() -> Weight { - // Minimum execution time: 73_553 nanoseconds. - Weight::from_ref_time(74_366_000 as u64) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1916` + // Estimated: `19186` + // Minimum execution time: 54_348 nanoseconds. + Weight::from_parts(55_024_000, 19186) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn rebag_terminal() -> Weight { - // Minimum execution time: 72_700 nanoseconds. - Weight::from_ref_time(73_322_000 as u64) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1810` + // Estimated: `19114` + // Minimum execution time: 53_306 nanoseconds. + Weight::from_parts(54_263_000, 19114) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: VoterList ListNodes (r:4 w:4) - // Storage: Staking Bonded (r:2 w:0) - // Storage: Staking Ledger (r:2 w:0) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) + /// Storage: VoterList ListNodes (r:4 w:4) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:2 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:2 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn put_in_front_of() -> Weight { - // Minimum execution time: 71_691 nanoseconds. - Weight::from_ref_time(72_798_000 as u64) - .saturating_add(RocksDbWeight::get().reads(10 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) + // Proof Size summary in bytes: + // Measured: `2154` + // Estimated: `25798` + // Minimum execution time: 59_513 nanoseconds. + Weight::from_parts(60_717_000, 25798) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } } diff --git a/frame/balances/src/weights.rs b/frame/balances/src/weights.rs index 6324745fd4..3266fcbcd4 100644 --- a/frame/balances/src/weights.rs +++ b/frame/balances/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_balances //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -59,106 +60,162 @@ pub trait WeightInfo { /// Weights for pallet_balances using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 48_134 nanoseconds. - Weight::from_ref_time(48_811_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1723` + // Estimated: `2603` + // Minimum execution time: 47_557 nanoseconds. + Weight::from_parts(48_314_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { - // Minimum execution time: 36_586 nanoseconds. - Weight::from_ref_time(36_966_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1607` + // Estimated: `2603` + // Minimum execution time: 36_372 nanoseconds. + Weight::from_parts(37_432_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_creating() -> Weight { - // Minimum execution time: 28_486 nanoseconds. - Weight::from_ref_time(28_940_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1757` + // Estimated: `2603` + // Minimum execution time: 26_671 nanoseconds. + Weight::from_parts(28_287_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_killing() -> Weight { - // Minimum execution time: 31_225 nanoseconds. - Weight::from_ref_time(31_946_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1757` + // Estimated: `2603` + // Minimum execution time: 30_122 nanoseconds. + Weight::from_parts(30_615_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Account (r:2 w:2) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { - // Minimum execution time: 47_347 nanoseconds. - Weight::from_ref_time(48_005_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `1719` + // Estimated: `5206` + // Minimum execution time: 47_891 nanoseconds. + Weight::from_parts(48_496_000, 5206) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_all() -> Weight { - // Minimum execution time: 41_668 nanoseconds. - Weight::from_ref_time(42_232_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1607` + // Estimated: `2603` + // Minimum execution time: 42_470 nanoseconds. + Weight::from_parts(42_950_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_unreserve() -> Weight { - // Minimum execution time: 23_741 nanoseconds. - Weight::from_ref_time(24_073_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `2603` + // Minimum execution time: 23_230 nanoseconds. + Weight::from_parts(23_951_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 48_134 nanoseconds. - Weight::from_ref_time(48_811_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1723` + // Estimated: `2603` + // Minimum execution time: 47_557 nanoseconds. + Weight::from_parts(48_314_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_keep_alive() -> Weight { - // Minimum execution time: 36_586 nanoseconds. - Weight::from_ref_time(36_966_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1607` + // Estimated: `2603` + // Minimum execution time: 36_372 nanoseconds. + Weight::from_parts(37_432_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_creating() -> Weight { - // Minimum execution time: 28_486 nanoseconds. - Weight::from_ref_time(28_940_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1757` + // Estimated: `2603` + // Minimum execution time: 26_671 nanoseconds. + Weight::from_parts(28_287_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn set_balance_killing() -> Weight { - // Minimum execution time: 31_225 nanoseconds. - Weight::from_ref_time(31_946_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1757` + // Estimated: `2603` + // Minimum execution time: 30_122 nanoseconds. + Weight::from_parts(30_615_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Account (r:2 w:2) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { - // Minimum execution time: 47_347 nanoseconds. - Weight::from_ref_time(48_005_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `1719` + // Estimated: `5206` + // Minimum execution time: 47_891 nanoseconds. + Weight::from_parts(48_496_000, 5206) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer_all() -> Weight { - // Minimum execution time: 41_668 nanoseconds. - Weight::from_ref_time(42_232_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1607` + // Estimated: `2603` + // Minimum execution time: 42_470 nanoseconds. + Weight::from_parts(42_950_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_unreserve() -> Weight { - // Minimum execution time: 23_741 nanoseconds. - Weight::from_ref_time(24_073_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `2603` + // Minimum execution time: 23_230 nanoseconds. + Weight::from_parts(23_951_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/benchmarking/Cargo.toml b/frame/benchmarking/Cargo.toml index 168b260573..b2a9621ebf 100644 --- a/frame/benchmarking/Cargo.toml +++ b/frame/benchmarking/Cargo.toml @@ -56,4 +56,5 @@ std = [ ] runtime-benchmarks = [ "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", ] diff --git a/frame/benchmarking/pov/Cargo.toml b/frame/benchmarking/pov/Cargo.toml new file mode 100644 index 0000000000..d885821bc1 --- /dev/null +++ b/frame/benchmarking/pov/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "frame-benchmarking-pallet-pov" +version = "4.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "Pallet for testing FRAME PoV benchmarking" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } +frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../" } +frame-support = { version = "4.0.0-dev", default-features = false, path = "../../support" } +frame-system = { version = "4.0.0-dev", default-features = false, path = "../../system" } +sp-io = { version = "7.0.0", default-features = false, path = "../../../primitives/io" } +sp-runtime = { version = "7.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-std = { version = "5.0.0", default-features = false, path = "../../../primitives/std" } + +[features] +default = ["std"] +std = [ + "codec/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "scale-info/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", +] +runtime-benchmarks = [ + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", +] diff --git a/frame/benchmarking/pov/src/benchmarking.rs b/frame/benchmarking/pov/src/benchmarking.rs new file mode 100644 index 0000000000..608077e2df --- /dev/null +++ b/frame/benchmarking/pov/src/benchmarking.rs @@ -0,0 +1,371 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! All benchmarks in this file are just for debugging the PoV calculation logic, they are unused. + +#![cfg(feature = "runtime-benchmarks")] + +use super::*; + +use frame_support::traits::UnfilteredDispatchable; +use frame_system::{Pallet as System, RawOrigin}; +use sp_runtime::traits::Hash; + +frame_benchmarking::benchmarks! { + storage_single_value_read { + Value::::put(123); + }: { + assert_eq!(Value::::get(), Some(123)); + } + + #[pov_mode = Ignored] + storage_single_value_ignored_read { + Value::::put(123); + }: { + assert_eq!(Value::::get(), Some(123)); + } + + storage_single_value_read_twice { + Value::::put(123); + }: { + assert_eq!(Value::::get(), Some(123)); + assert_eq!(Value::::get(), Some(123)); + } + + storage_single_value_write { + }: { + Value::::put(123); + } verify { + assert_eq!(Value::::get(), Some(123)); + } + + storage_single_value_kill { + Value::::put(123); + }: { + Value::::kill(); + } verify { + assert!(!Value::::exists()); + } + + // This benchmark and the following are testing a storage map with adjacent storage items. + // + // First a storage map is filled and a specific number of other storage items is + // created. Then the one value is read from the map. This demonstrates that the number of other + // nodes in the Trie influences the proof size. The number of inserted nodes can be interpreted + // as the number of `StorageMap`/`StorageValue` in the whole runtime. + #[pov_mode = Measured] + storage_1m_map_read_one_value_two_additional_layers { + (0..(1<<10)).for_each(|i| Map1M::::insert(i, i)); + // Assume there are 16-256 other storage items. + (0..(1u32<<4)).for_each(|i| { + let k = T::Hashing::hash(&i.to_be_bytes()); + frame_support::storage::unhashed::put(k.as_ref(), &i); + }); + }: { + assert_eq!(Map1M::::get(1<<9), Some(1<<9)); + } + + #[pov_mode = Measured] + storage_1m_map_read_one_value_three_additional_layers { + (0..(1<<10)).for_each(|i| Map1M::::insert(i, i)); + // Assume there are 256-4096 other storage items. + (0..(1u32<<8)).for_each(|i| { + let k = T::Hashing::hash(&i.to_be_bytes()); + frame_support::storage::unhashed::put(k.as_ref(), &i); + }); + }: { + assert_eq!(Map1M::::get(1<<9), Some(1<<9)); + } + + #[pov_mode = Measured] + storage_1m_map_read_one_value_four_additional_layers { + (0..(1<<10)).for_each(|i| Map1M::::insert(i, i)); + // Assume there are 4096-65536 other storage items. + (0..(1u32<<12)).for_each(|i| { + let k = T::Hashing::hash(&i.to_be_bytes()); + frame_support::storage::unhashed::put(k.as_ref(), &i); + }); + }: { + assert_eq!(Map1M::::get(1<<9), Some(1<<9)); + } + + // Reads from both storage maps each `n` and `m` times. Should result in two linear components. + storage_map_read_per_component { + let n in 0 .. 100; + let m in 0 .. 100; + + (0..m*10).for_each(|i| Map1M::::insert(i, i)); + (0..n*10).for_each(|i| Map16M::::insert(i, i)); + }: { + (0..m).for_each(|i| + assert_eq!(Map1M::::get(i*10), Some(i*10))); + (0..n).for_each(|i| + assert_eq!(Map16M::::get(i*10), Some(i*10))); + } + + #[pov_mode = MaxEncodedLen { + Pov::Map1M: Ignored + }] + storage_map_read_per_component_one_ignored { + let n in 0 .. 100; + let m in 0 .. 100; + + (0..m*10).for_each(|i| Map1M::::insert(i, i)); + (0..n*10).for_each(|i| Map16M::::insert(i, i)); + }: { + (0..m).for_each(|i| + assert_eq!(Map1M::::get(i*10), Some(i*10))); + (0..n).for_each(|i| + assert_eq!(Map16M::::get(i*10), Some(i*10))); + } + + // Reads the same value from a storage map. Should not result in a component. + storage_1m_map_one_entry_repeated_read { + let n in 0 .. 100; + Map1M::::insert(0, 0); + }: { + (0..n).for_each(|i| + assert_eq!(Map1M::::get(0), Some(0))); + } + + // Reads the same values from a storage map. Should result in a `1x` linear component. + storage_1m_map_multiple_entry_repeated_read { + let n in 0 .. 100; + (0..n).for_each(|i| Map1M::::insert(i, i)); + }: { + (0..n).for_each(|i| { + // Reading the same value 10 times does nothing. + (0..10).for_each(|j| + assert_eq!(Map1M::::get(i), Some(i))); + }); + } + + storage_1m_double_map_read_per_component { + let n in 0 .. 1024; + (0..(1<<10)).for_each(|i| DoubleMap1M::::insert(i, i, i)); + }: { + (0..n).for_each(|i| + assert_eq!(DoubleMap1M::::get(i, i), Some(i))); + } + + storage_value_bounded_read { + }: { + assert!(BoundedValue::::get().is_none()); + } + + // Reading unbounded values will produce no mathematical worst case PoV size for this component. + storage_value_unbounded_read { + }: { + assert!(UnboundedValue::::get().is_none()); + } + + #[pov_mode = Ignored] + storage_value_unbounded_ignored_read { + }: { + assert!(UnboundedValue::::get().is_none()); + } + + // Same as above, but we still expect a mathematical worst case PoV size for the bounded one. + storage_value_bounded_and_unbounded_read { + }: { + assert!(UnboundedValue::::get().is_none()); + assert!(BoundedValue::::get().is_none()); + } + + #[pov_mode = Measured] + measured_storage_value_read_linear_size { + let l in 0 .. 1<<22; + let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + LargeValue::::put(&v); + }: { + assert!(LargeValue::::get().is_some()); + } + + #[pov_mode = MaxEncodedLen] + mel_storage_value_read_linear_size { + let l in 0 .. 1<<22; + let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + LargeValue::::put(&v); + }: { + assert!(LargeValue::::get().is_some()); + } + + #[pov_mode = Measured] + measured_storage_double_value_read_linear_size { + let l in 0 .. 1<<22; + let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + LargeValue::::put(&v); + LargeValue2::::put(&v); + }: { + assert!(LargeValue::::get().is_some()); + assert!(LargeValue2::::get().is_some()); + } + + #[pov_mode = MaxEncodedLen] + mel_storage_double_value_read_linear_size { + let l in 0 .. 1<<22; + let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + LargeValue::::put(&v); + LargeValue2::::put(&v); + }: { + assert!(LargeValue::::get().is_some()); + assert!(LargeValue2::::get().is_some()); + } + + #[pov_mode = MaxEncodedLen { + Pov::LargeValue2: Measured + }] + mel_mixed_storage_double_value_read_linear_size { + let l in 0 .. 1<<22; + let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + LargeValue::::put(&v); + LargeValue2::::put(&v); + }: { + assert!(LargeValue::::get().is_some()); + assert!(LargeValue2::::get().is_some()); + } + + #[pov_mode = Measured { + Pov::LargeValue2: MaxEncodedLen + }] + measured_mixed_storage_double_value_read_linear_size { + let l in 0 .. 1<<22; + let v: sp_runtime::BoundedVec = sp_std::vec![0u8; l as usize].try_into().unwrap(); + LargeValue::::put(&v); + LargeValue2::::put(&v); + }: { + assert!(LargeValue::::get().is_some()); + assert!(LargeValue2::::get().is_some()); + } + + #[pov_mode = Measured] + storage_map_unbounded_both_measured_read { + let i in 0 .. 1000; + + UnboundedMap::::insert(i, sp_std::vec![0; i as usize]); + UnboundedMap2::::insert(i, sp_std::vec![0; i as usize]); + }: { + assert!(UnboundedMap::::get(i).is_some()); + assert!(UnboundedMap2::::get(i).is_some()); + } + + #[pov_mode = MaxEncodedLen { + Pov::UnboundedMap: Measured + }] + storage_map_partial_unbounded_read { + let i in 0 .. 1000; + + Map1M::::insert(i, 0); + UnboundedMap::::insert(i, sp_std::vec![0; i as usize]); + }: { + assert!(Map1M::::get(i).is_some()); + assert!(UnboundedMap::::get(i).is_some()); + } + + #[pov_mode = MaxEncodedLen { + Pov::UnboundedMap: Ignored + }] + storage_map_partial_unbounded_ignored_read { + let i in 0 .. 1000; + + Map1M::::insert(i, 0); + UnboundedMap::::insert(i, sp_std::vec![0; i as usize]); + }: { + assert!(Map1M::::get(i).is_some()); + assert!(UnboundedMap::::get(i).is_some()); + } + + // Emitting an event will not incur any PoV. + emit_event { + // Emit a single event. + let call = Call::::emit_event { }; + }: { call.dispatch_bypass_filter(RawOrigin::Root.into()).unwrap(); } + verify { + assert_eq!(System::::events().len(), 1); + } + + // A No-OP will not incur any PoV. + noop { + let call = Call::::noop { }; + }: { + call.dispatch_bypass_filter(RawOrigin::Root.into()).unwrap(); + } + + impl_benchmark_test_suite!( + Pallet, + mock::new_test_ext(), + mock::Test, + ); +} + +#[cfg(test)] +mod mock { + use sp_runtime::testing::H256; + + type AccountId = u64; + type AccountIndex = u32; + type BlockNumber = u64; + + type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; + + frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Baseline: crate::{Pallet, Call, Storage, Event}, + } + ); + + impl frame_system::Config for Test { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = AccountIndex; + type BlockNumber = BlockNumber; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; + type AccountId = AccountId; + type Lookup = sp_runtime::traits::IdentityLookup; + type Header = sp_runtime::testing::Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; + } + + impl crate::Config for Test { + type RuntimeEvent = RuntimeEvent; + } + + pub fn new_test_ext() -> sp_io::TestExternalities { + frame_system::GenesisConfig::default().build_storage::().unwrap().into() + } +} diff --git a/frame/benchmarking/pov/src/lib.rs b/frame/benchmarking/pov/src/lib.rs new file mode 100644 index 0000000000..6618ce60d8 --- /dev/null +++ b/frame/benchmarking/pov/src/lib.rs @@ -0,0 +1,131 @@ +// This file is part of Substrate. + +// Copyright (C) 2020-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! End-to-end testing pallet for PoV benchmarking. Should only be deployed in a testing runtime. + +#![cfg_attr(not(feature = "std"), no_std)] + +mod benchmarking; +mod tests; +mod weights; + +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + use sp_std::prelude::*; + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(PhantomData); + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + #[pallet::storage] + pub(crate) type Value = StorageValue; + + #[pallet::storage] + pub(crate) type Value2 = StorageValue; + + /// A value without a MEL bound. + #[pallet::storage] + #[pallet::unbounded] + pub(crate) type UnboundedValue = + StorageValue, QueryKind = OptionQuery>; + + /// A value with a MEL bound of 32 byte. + #[pallet::storage] + pub(crate) type BoundedValue = + StorageValue>, QueryKind = OptionQuery>; + + /// 4MiB value. + #[pallet::storage] + pub(crate) type LargeValue = + StorageValue>, QueryKind = OptionQuery>; + + #[pallet::storage] + pub(crate) type LargeValue2 = + StorageValue>, QueryKind = OptionQuery>; + + /// A map with a maximum of 1M entries. + #[pallet::storage] + pub(crate) type Map1M = StorageMap< + Hasher = Blake2_256, + Key = u32, + Value = u32, + QueryKind = OptionQuery, + MaxValues = ConstU32<1_000_000>, + >; + + /// A map with a maximum of 16M entries. + #[pallet::storage] + pub(crate) type Map16M = StorageMap< + Hasher = Blake2_256, + Key = u32, + Value = u32, + QueryKind = OptionQuery, + MaxValues = ConstU32<16_000_000>, + >; + + #[pallet::storage] + pub(crate) type DoubleMap1M = StorageDoubleMap< + Hasher1 = Blake2_256, + Hasher2 = Blake2_256, + Key1 = u32, + Key2 = u32, + Value = u32, + QueryKind = OptionQuery, + MaxValues = ConstU32<1_000_000>, + >; + + #[pallet::storage] + #[pallet::unbounded] + pub(crate) type UnboundedMap = + StorageMap, QueryKind = OptionQuery>; + + #[pallet::storage] + #[pallet::unbounded] + pub(crate) type UnboundedMap2 = + StorageMap, QueryKind = OptionQuery>; + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + TestEvent, + } + + #[pallet::call] + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(0)] + pub fn emit_event(_origin: OriginFor) -> DispatchResult { + Self::deposit_event(Event::TestEvent); + Ok(()) + } + + #[pallet::call_index(1)] + #[pallet::weight(0)] + pub fn noop(_origin: OriginFor) -> DispatchResult { + Ok(()) + } + } +} diff --git a/frame/benchmarking/pov/src/tests.rs b/frame/benchmarking/pov/src/tests.rs new file mode 100644 index 0000000000..1100fdc46f --- /dev/null +++ b/frame/benchmarking/pov/src/tests.rs @@ -0,0 +1,211 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Test the produces weight functions. + +#![cfg(test)] + +use super::weights::WeightInfo; +use mock::Test as T; +type W = crate::weights::SubstrateWeight; + +#[test] +fn writing_is_free() { + let w = W::storage_single_value_write().proof_size(); + assert_eq!(w, 0, "Writing is free"); +} + +#[test] +fn killing_is_free() { + // NOTE: This only applies to state version 1. + let w = W::storage_single_value_kill().proof_size(); + assert_eq!(w, 0, "Killing is free"); +} + +#[test] +fn reading_twice_is_the_same_as_once() { + let w = W::storage_single_value_read().proof_size(); + let w2 = W::storage_single_value_read_twice().proof_size(); + assert_eq!(w, w2, "Reading twice is the same as once"); +} + +#[test] +fn storage_single_value_ignored_read_no_pov() { + let w = W::storage_single_value_ignored_read(); + assert_eq!(w.proof_size(), 0, "Ignored PoV does not result in PoV"); +} + +#[test] +fn storage_single_value_ignored_some_read_has_pov() { + let w = W::storage_single_value_ignored_some_read(); + assert!(w.proof_size() != 0, "Ignored some does result in PoV"); +} + +/// Reading the same value from a map does not increase the PoV. +#[test] +fn storage_1m_map_one_entry_repeated_read_const() { + let weight = W::storage_1m_map_one_entry_repeated_read; + let w0 = weight(0).proof_size(); + assert!(w0 > 0, "There is a base weight"); + + let w1 = weight(1).proof_size(); + assert_eq!(w0, w1, "Component does not matter"); +} + +/// Reading multiple values multiple times from a map increases the PoV by the number of reads. +#[test] +fn storage_1m_map_multiple_entry_repeated_read_single_linear() { + let weight = W::storage_1m_map_multiple_entry_repeated_read; + let w0 = weight(0).proof_size(); + + let w1 = weight(1).proof_size() - w0; + assert!(w1 > 0, "Component matters"); + + let wm = weight(1000).proof_size(); + assert_eq!(w1 * 1000 + w0, wm, "x scales linearly"); +} + +/// Check that reading two maps at once increases the PoV linearly per map. +#[test] +fn storage_map_read_per_component_double_linear() { + let weight = W::storage_map_read_per_component; + let w00 = weight(0, 0).proof_size(); + + let w10 = weight(1, 0).proof_size() - w00; + let w01 = weight(0, 1).proof_size() - w00; + assert!(w10 > 0 && w01 > 0, "Components matter"); + assert!(w10 != w01, "Each map has its own component"); + + let wm0 = weight(1000, 0).proof_size(); + let w0m = weight(0, 1000).proof_size(); + assert_eq!(w00 + w10 * 1000, wm0, "x scales linearly"); + assert_eq!(w00 + w01 * 1000, w0m, "y scales linearly"); + + let wmm = weight(1000, 1000).proof_size(); + assert_eq!(wmm + w00, wm0 + w0m, "x + y scales linearly"); +} + +/// The proof size estimation takes the measured sizes into account and therefore increases with the +/// number of layers. +#[test] +fn additional_layers_do_not_matter() { + let w2 = W::storage_1m_map_read_one_value_two_additional_layers().proof_size(); + let w3 = W::storage_1m_map_read_one_value_three_additional_layers().proof_size(); + let w4 = W::storage_1m_map_read_one_value_four_additional_layers().proof_size(); + assert!(w3 > w2 && w4 > w3, "Additional layers do matter"); +} + +/// Check that the measured value size instead of the MEL is used. +#[test] +fn linear_measured_size_works() { + let weight = W::measured_storage_value_read_linear_size; + + let w0 = weight(0).proof_size(); + let w1 = weight(1).proof_size() - w0; + + assert_eq!(w1, 1, "x scales with a factor of 1"); + let wm = weight(1000).proof_size(); + assert_eq!(w1 * 1000 + w0, wm, "x scales linearly"); +} + +// vice-versa of above `linear_measured_size_works`. +#[test] +fn linear_mel_size_works() { + let weight = W::mel_storage_value_read_linear_size; + + let w1 = weight(1).proof_size(); + let wm = weight(1000).proof_size(); + assert_eq!(w1, wm, "PoV size is const"); +} + +/// Although there is no estimation possible, it uses the recorded proof size as best effort. +#[test] +fn unbounded_read_best_effort() { + let w = W::storage_value_unbounded_read().proof_size(); + assert!(w > 0, "There is a weight"); +} + +/// For mixed unbounded and bounded reads, the bounded part still increases the PoV. +#[test] +fn partial_unbounded_read_best_effort() { + let w_unbounded = W::storage_value_unbounded_read().proof_size(); + let w_bounded = W::storage_value_bounded_read().proof_size(); + let w_partial = W::storage_value_bounded_and_unbounded_read().proof_size(); + + assert_eq!(w_bounded + w_unbounded, w_partial, "The bounded part increases the PoV"); +} + +#[test] +fn emit_event_is_free() { + let w = W::emit_event().proof_size(); + assert_eq!(w, 0, "Emitting an event is free"); +} + +#[test] +fn noop_is_free() { + let w = W::noop().proof_size(); + assert_eq!(w, 0, "Noop is free"); +} + +mod mock { + use sp_runtime::testing::H256; + + type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; + type Block = frame_system::mocking::MockBlock; + + frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Baseline: crate::{Pallet, Call, Storage, Event}, + } + ); + + impl frame_system::Config for Test { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = (); + type BlockLength = (); + type DbWeight = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = u32; + type BlockNumber = u64; + type RuntimeCall = RuntimeCall; + type Hash = H256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; + type AccountId = u32; + type Lookup = sp_runtime::traits::IdentityLookup; + type Header = sp_runtime::testing::Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = (); + type OnNewAccount = (); + type OnKilledAccount = (); + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; + } + + impl crate::Config for Test { + type RuntimeEvent = RuntimeEvent; + } +} diff --git a/frame/benchmarking/pov/src/weights.rs b/frame/benchmarking/pov/src/weights.rs new file mode 100644 index 0000000000..e890e9b2ef --- /dev/null +++ b/frame/benchmarking/pov/src/weights.rs @@ -0,0 +1,807 @@ + +//! Autogenerated weights for frame_benchmarking_pallet_pov +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-01-23, STEPS: `50`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `oty-parity`, CPU: `11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/substrate +// benchmark +// pallet +// --dev +// --pallet +// frame-benchmarking-pallet-pov +// --extrinsic +// +// --steps +// 50 +// --repeat +// 1 +// --template=.maintain/frame-weight-template.hbs +// --output=frame/benchmarking/pov/src/weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for frame_benchmarking_pallet_pov. +pub trait WeightInfo { + fn storage_single_value_read() -> Weight; + fn storage_single_value_ignored_read() -> Weight; + fn storage_single_value_ignored_some_read() -> Weight; + fn storage_single_value_read_twice() -> Weight; + fn storage_single_value_write() -> Weight; + fn storage_single_value_kill() -> Weight; + fn storage_1m_map_read_one_value_two_additional_layers() -> Weight; + fn storage_1m_map_read_one_value_three_additional_layers() -> Weight; + fn storage_1m_map_read_one_value_four_additional_layers() -> Weight; + fn storage_map_read_per_component(n: u32, m: u32, ) -> Weight; + fn storage_map_read_per_component_one_ignored(n: u32, m: u32, ) -> Weight; + fn storage_1m_map_one_entry_repeated_read(n: u32, ) -> Weight; + fn storage_1m_map_multiple_entry_repeated_read(n: u32, ) -> Weight; + fn storage_1m_double_map_read_per_component(n: u32, ) -> Weight; + fn storage_value_bounded_read() -> Weight; + fn storage_value_unbounded_read() -> Weight; + fn storage_value_unbounded_ignored_read() -> Weight; + fn storage_value_bounded_and_unbounded_read() -> Weight; + fn measured_storage_value_read_linear_size(l: u32, ) -> Weight; + fn mel_storage_value_read_linear_size(l: u32, ) -> Weight; + fn measured_storage_double_value_read_linear_size(l: u32, ) -> Weight; + fn mel_storage_double_value_read_linear_size(l: u32, ) -> Weight; + fn mel_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight; + fn measured_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight; + fn storage_map_unbounded_both_measured_read(i: u32, ) -> Weight; + fn storage_map_partial_unbounded_read(i: u32, ) -> Weight; + fn storage_map_partial_unbounded_ignored_read(i: u32, ) -> Weight; + fn emit_event() -> Weight; + fn noop() -> Weight; +} + +/// Weights for frame_benchmarking_pallet_pov using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `499` + // Minimum execution time: 3_291 nanoseconds. + Weight::from_parts(3_291_000, 499) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: Ignored) + fn storage_single_value_ignored_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `0` + // Minimum execution time: 2_918 nanoseconds. + Weight::from_ref_time(2_918_000) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Pov Value2 (r:1 w:0) + /// Proof: Pov Value2 (max_values: Some(1), max_size: Some(4), added: 499, mode: Ignored) + fn storage_single_value_ignored_some_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `659` + // Minimum execution time: 4_056 nanoseconds. + Weight::from_parts(4_056_000, 659) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_read_twice() -> Weight { + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `499` + // Minimum execution time: 3_552 nanoseconds. + Weight::from_parts(3_552_000, 499) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Value (r:0 w:1) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_write() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 795 nanoseconds. + Weight::from_ref_time(795_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Pov Value (r:0 w:1) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_kill() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 865 nanoseconds. + Weight::from_ref_time(865_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Measured) + fn storage_1m_map_read_one_value_two_additional_layers() -> Weight { + // Proof Size summary in bytes: + // Measured: `1275` + // Estimated: `3750` + // Minimum execution time: 9_571 nanoseconds. + Weight::from_parts(9_571_000, 3750) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Measured) + fn storage_1m_map_read_one_value_three_additional_layers() -> Weight { + // Proof Size summary in bytes: + // Measured: `1544` + // Estimated: `4019` + // Minimum execution time: 14_597 nanoseconds. + Weight::from_parts(14_597_000, 4019) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Measured) + fn storage_1m_map_read_one_value_four_additional_layers() -> Weight { + // Proof Size summary in bytes: + // Measured: `2044` + // Estimated: `4519` + // Minimum execution time: 19_793 nanoseconds. + Weight::from_parts(19_793_000, 4519) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:100 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// Storage: Pov Map16M (r:100 w:0) + /// Proof: Pov Map16M (max_values: Some(16000000), max_size: Some(36), added: 3006, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + fn storage_map_read_per_component(n: u32, m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `515 + n * (188 ±0) + m * (188 ±0)` + // Estimated: `0 + n * (3006 ±0) + m * (2511 ±0)` + // Minimum execution time: 266_160 nanoseconds. + Weight::from_ref_time(190_477_747) + // Standard Error: 96_405 + .saturating_add(Weight::from_ref_time(1_049_993).saturating_mul(n.into())) + // Standard Error: 96_405 + .saturating_add(Weight::from_ref_time(1_202_546).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) + .saturating_add(Weight::from_proof_size(3006).saturating_mul(n.into())) + .saturating_add(Weight::from_proof_size(2511).saturating_mul(m.into())) + } + /// Storage: Pov Map1M (r:100 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Ignored) + /// Storage: Pov Map16M (r:100 w:0) + /// Proof: Pov Map16M (max_values: Some(16000000), max_size: Some(36), added: 3006, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + fn storage_map_read_per_component_one_ignored(n: u32, m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `515 + n * (188 ±0) + m * (188 ±0)` + // Estimated: `695 + n * (3195 ±2) + m * (189 ±2)` + // Minimum execution time: 265_113 nanoseconds. + Weight::from_parts(215_943_973, 695) + // Standard Error: 199_907 + .saturating_add(Weight::from_ref_time(988_371).saturating_mul(n.into())) + // Standard Error: 199_907 + .saturating_add(Weight::from_ref_time(1_145_693).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) + .saturating_add(Weight::from_proof_size(3195).saturating_mul(n.into())) + .saturating_add(Weight::from_proof_size(189).saturating_mul(m.into())) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + fn storage_1m_map_one_entry_repeated_read(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `170` + // Estimated: `2511` + // Minimum execution time: 119 nanoseconds. + Weight::from_parts(3_649_405, 2511) + // Standard Error: 4_472 + .saturating_add(Weight::from_ref_time(432_147).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:100 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + fn storage_1m_map_multiple_entry_repeated_read(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `147 + n * (40 ±0)` + // Estimated: `0 + n * (2511 ±0)` + // Minimum execution time: 106 nanoseconds. + Weight::from_ref_time(59_892_609) + // Standard Error: 418_004 + .saturating_add(Weight::from_ref_time(5_919_793).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2511).saturating_mul(n.into())) + } + /// Storage: Pov DoubleMap1M (r:1024 w:0) + /// Proof: Pov DoubleMap1M (max_values: Some(1000000), max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 1024]`. + fn storage_1m_double_map_read_per_component(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `21938 + n * (57 ±0)` + // Estimated: `0 + n * (2543 ±0)` + // Minimum execution time: 550 nanoseconds. + Weight::from_ref_time(65_431_603) + // Standard Error: 66_935 + .saturating_add(Weight::from_ref_time(2_825_371).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2543).saturating_mul(n.into())) + } + /// Storage: Pov BoundedValue (r:1 w:0) + /// Proof: Pov BoundedValue (max_values: Some(1), max_size: Some(33), added: 528, mode: MaxEncodedLen) + fn storage_value_bounded_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `528` + // Minimum execution time: 2_541 nanoseconds. + Weight::from_parts(2_541_000, 528) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov UnboundedValue (r:1 w:0) + /// Proof Skipped: Pov UnboundedValue (max_values: Some(1), max_size: None, mode: Measured) + fn storage_value_unbounded_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `604` + // Minimum execution time: 2_226 nanoseconds. + Weight::from_parts(2_226_000, 604) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov UnboundedValue (r:1 w:0) + /// Proof Skipped: Pov UnboundedValue (max_values: Some(1), max_size: None, mode: Ignored) + fn storage_value_unbounded_ignored_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `0` + // Minimum execution time: 2_100 nanoseconds. + Weight::from_ref_time(2_100_000) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov UnboundedValue (r:1 w:0) + /// Proof Skipped: Pov UnboundedValue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Pov BoundedValue (r:1 w:0) + /// Proof: Pov BoundedValue (max_values: Some(1), max_size: Some(33), added: 528, mode: MaxEncodedLen) + fn storage_value_bounded_and_unbounded_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `1132` + // Minimum execution time: 2_808 nanoseconds. + Weight::from_parts(2_808_000, 1132) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// The range of component `l` is `[0, 4194304]`. + fn measured_storage_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `174 + l * (1 ±0)` + // Estimated: `666 + l * (1 ±0)` + // Minimum execution time: 3_385 nanoseconds. + Weight::from_parts(3_385_000, 666) + // Standard Error: 10 + .saturating_add(Weight::from_ref_time(356).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(l.into())) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// The range of component `l` is `[0, 4194304]`. + fn mel_storage_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `174 + l * (1 ±0)` + // Estimated: `4194803` + // Minimum execution time: 3_342 nanoseconds. + Weight::from_parts(3_342_000, 4194803) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(345).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// The range of component `l` is `[0, 4194304]`. + fn measured_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `1448 + l * (4 ±0)` + // Minimum execution time: 4_519 nanoseconds. + Weight::from_parts(4_519_000, 1448) + // Standard Error: 9 + .saturating_add(Weight::from_ref_time(560).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(l.into())) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// The range of component `l` is `[0, 4194304]`. + fn mel_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `8389606` + // Minimum execution time: 4_462 nanoseconds. + Weight::from_parts(4_462_000, 8389606) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(538).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// The range of component `l` is `[0, 4194304]`. + fn mel_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `4195527 + l * (2 ±0)` + // Minimum execution time: 4_552 nanoseconds. + Weight::from_parts(4_552_000, 4195527) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(507).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// The range of component `l` is `[0, 4194304]`. + fn measured_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `4195527 + l * (2 ±0)` + // Minimum execution time: 4_236 nanoseconds. + Weight::from_parts(4_236_000, 4195527) + // Standard Error: 8 + .saturating_add(Weight::from_ref_time(517).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) + } + /// Storage: Pov UnboundedMap (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap (max_values: None, max_size: None, mode: Measured) + /// Storage: Pov UnboundedMap2 (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap2 (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[0, 1000]`. + fn storage_map_unbounded_both_measured_read(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `293 + i * (8 ±0)` + // Estimated: `5524 + i * (16 ±0)` + // Minimum execution time: 5_649 nanoseconds. + Weight::from_parts(6_111_237, 5524) + // Standard Error: 1_060 + .saturating_add(Weight::from_ref_time(2_693).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(16).saturating_mul(i.into())) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// Storage: Pov UnboundedMap (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[0, 1000]`. + fn storage_map_partial_unbounded_read(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `260 + i * (4 ±0)` + // Estimated: `5243 + i * (4 ±0)` + // Minimum execution time: 5_997 nanoseconds. + Weight::from_parts(7_996_508, 5243) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// Storage: Pov UnboundedMap (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap (max_values: None, max_size: None, mode: Ignored) + /// The range of component `i` is `[0, 1000]`. + fn storage_map_partial_unbounded_ignored_read(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `260 + i * (4 ±0)` + // Estimated: `2768 + i * (4 ±0)` + // Minimum execution time: 5_679 nanoseconds. + Weight::from_parts(6_496_804, 2768) + // Standard Error: 611 + .saturating_add(Weight::from_ref_time(930).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) + } + fn emit_event() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_087 nanoseconds. + Weight::from_ref_time(7_087_000) + } + fn noop() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_719 nanoseconds. + Weight::from_ref_time(2_719_000) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `499` + // Minimum execution time: 3_291 nanoseconds. + Weight::from_parts(3_291_000, 499) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: Ignored) + fn storage_single_value_ignored_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `0` + // Minimum execution time: 2_918 nanoseconds. + Weight::from_ref_time(2_918_000) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Pov Value2 (r:1 w:0) + /// Proof: Pov Value2 (max_values: Some(1), max_size: Some(4), added: 499, mode: Ignored) + fn storage_single_value_ignored_some_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `160` + // Estimated: `659` + // Minimum execution time: 4_056 nanoseconds. + Weight::from_parts(4_056_000, 659) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } + /// Storage: Pov Value (r:1 w:0) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_read_twice() -> Weight { + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `499` + // Minimum execution time: 3_552 nanoseconds. + Weight::from_parts(3_552_000, 499) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Value (r:0 w:1) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_write() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 795 nanoseconds. + Weight::from_ref_time(795_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Pov Value (r:0 w:1) + /// Proof: Pov Value (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn storage_single_value_kill() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 865 nanoseconds. + Weight::from_ref_time(865_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Measured) + fn storage_1m_map_read_one_value_two_additional_layers() -> Weight { + // Proof Size summary in bytes: + // Measured: `1275` + // Estimated: `3750` + // Minimum execution time: 9_571 nanoseconds. + Weight::from_parts(9_571_000, 3750) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Measured) + fn storage_1m_map_read_one_value_three_additional_layers() -> Weight { + // Proof Size summary in bytes: + // Measured: `1544` + // Estimated: `4019` + // Minimum execution time: 14_597 nanoseconds. + Weight::from_parts(14_597_000, 4019) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Measured) + fn storage_1m_map_read_one_value_four_additional_layers() -> Weight { + // Proof Size summary in bytes: + // Measured: `2044` + // Estimated: `4519` + // Minimum execution time: 19_793 nanoseconds. + Weight::from_parts(19_793_000, 4519) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:100 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// Storage: Pov Map16M (r:100 w:0) + /// Proof: Pov Map16M (max_values: Some(16000000), max_size: Some(36), added: 3006, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + fn storage_map_read_per_component(n: u32, m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `515 + n * (188 ±0) + m * (188 ±0)` + // Estimated: `0 + n * (3006 ±0) + m * (2511 ±0)` + // Minimum execution time: 266_160 nanoseconds. + Weight::from_ref_time(190_477_747) + // Standard Error: 96_405 + .saturating_add(Weight::from_ref_time(1_049_993).saturating_mul(n.into())) + // Standard Error: 96_405 + .saturating_add(Weight::from_ref_time(1_202_546).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) + .saturating_add(Weight::from_proof_size(3006).saturating_mul(n.into())) + .saturating_add(Weight::from_proof_size(2511).saturating_mul(m.into())) + } + /// Storage: Pov Map1M (r:100 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: Ignored) + /// Storage: Pov Map16M (r:100 w:0) + /// Proof: Pov Map16M (max_values: Some(16000000), max_size: Some(36), added: 3006, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + /// The range of component `m` is `[0, 100]`. + fn storage_map_read_per_component_one_ignored(n: u32, m: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `515 + n * (188 ±0) + m * (188 ±0)` + // Estimated: `695 + n * (3195 ±2) + m * (189 ±2)` + // Minimum execution time: 265_113 nanoseconds. + Weight::from_parts(215_943_973, 695) + // Standard Error: 199_907 + .saturating_add(Weight::from_ref_time(988_371).saturating_mul(n.into())) + // Standard Error: 199_907 + .saturating_add(Weight::from_ref_time(1_145_693).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) + .saturating_add(Weight::from_proof_size(3195).saturating_mul(n.into())) + .saturating_add(Weight::from_proof_size(189).saturating_mul(m.into())) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + fn storage_1m_map_one_entry_repeated_read(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `170` + // Estimated: `2511` + // Minimum execution time: 119 nanoseconds. + Weight::from_parts(3_649_405, 2511) + // Standard Error: 4_472 + .saturating_add(Weight::from_ref_time(432_147).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov Map1M (r:100 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 100]`. + fn storage_1m_map_multiple_entry_repeated_read(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `147 + n * (40 ±0)` + // Estimated: `0 + n * (2511 ±0)` + // Minimum execution time: 106 nanoseconds. + Weight::from_ref_time(59_892_609) + // Standard Error: 418_004 + .saturating_add(Weight::from_ref_time(5_919_793).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2511).saturating_mul(n.into())) + } + /// Storage: Pov DoubleMap1M (r:1024 w:0) + /// Proof: Pov DoubleMap1M (max_values: Some(1000000), max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// The range of component `n` is `[0, 1024]`. + fn storage_1m_double_map_read_per_component(n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `21938 + n * (57 ±0)` + // Estimated: `0 + n * (2543 ±0)` + // Minimum execution time: 550 nanoseconds. + Weight::from_ref_time(65_431_603) + // Standard Error: 66_935 + .saturating_add(Weight::from_ref_time(2_825_371).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(2543).saturating_mul(n.into())) + } + /// Storage: Pov BoundedValue (r:1 w:0) + /// Proof: Pov BoundedValue (max_values: Some(1), max_size: Some(33), added: 528, mode: MaxEncodedLen) + fn storage_value_bounded_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `528` + // Minimum execution time: 2_541 nanoseconds. + Weight::from_parts(2_541_000, 528) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov UnboundedValue (r:1 w:0) + /// Proof Skipped: Pov UnboundedValue (max_values: Some(1), max_size: None, mode: Measured) + fn storage_value_unbounded_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `604` + // Minimum execution time: 2_226 nanoseconds. + Weight::from_parts(2_226_000, 604) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov UnboundedValue (r:1 w:0) + /// Proof Skipped: Pov UnboundedValue (max_values: Some(1), max_size: None, mode: Ignored) + fn storage_value_unbounded_ignored_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `0` + // Minimum execution time: 2_100 nanoseconds. + Weight::from_ref_time(2_100_000) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov UnboundedValue (r:1 w:0) + /// Proof Skipped: Pov UnboundedValue (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Pov BoundedValue (r:1 w:0) + /// Proof: Pov BoundedValue (max_values: Some(1), max_size: Some(33), added: 528, mode: MaxEncodedLen) + fn storage_value_bounded_and_unbounded_read() -> Weight { + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `1132` + // Minimum execution time: 2_808 nanoseconds. + Weight::from_parts(2_808_000, 1132) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// The range of component `l` is `[0, 4194304]`. + fn measured_storage_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `174 + l * (1 ±0)` + // Estimated: `666 + l * (1 ±0)` + // Minimum execution time: 3_385 nanoseconds. + Weight::from_parts(3_385_000, 666) + // Standard Error: 10 + .saturating_add(Weight::from_ref_time(356).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(l.into())) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// The range of component `l` is `[0, 4194304]`. + fn mel_storage_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `174 + l * (1 ±0)` + // Estimated: `4194803` + // Minimum execution time: 3_342 nanoseconds. + Weight::from_parts(3_342_000, 4194803) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(345).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// The range of component `l` is `[0, 4194304]`. + fn measured_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `1448 + l * (4 ±0)` + // Minimum execution time: 4_519 nanoseconds. + Weight::from_parts(4_519_000, 1448) + // Standard Error: 9 + .saturating_add(Weight::from_ref_time(560).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(l.into())) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// The range of component `l` is `[0, 4194304]`. + fn mel_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `8389606` + // Minimum execution time: 4_462 nanoseconds. + Weight::from_parts(4_462_000, 8389606) + // Standard Error: 7 + .saturating_add(Weight::from_ref_time(538).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// The range of component `l` is `[0, 4194304]`. + fn mel_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `4195527 + l * (2 ±0)` + // Minimum execution time: 4_552 nanoseconds. + Weight::from_parts(4_552_000, 4195527) + // Standard Error: 6 + .saturating_add(Weight::from_ref_time(507).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) + } + /// Storage: Pov LargeValue (r:1 w:0) + /// Proof: Pov LargeValue (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: Measured) + /// Storage: Pov LargeValue2 (r:1 w:0) + /// Proof: Pov LargeValue2 (max_values: Some(1), max_size: Some(4194308), added: 4194803, mode: MaxEncodedLen) + /// The range of component `l` is `[0, 4194304]`. + fn measured_mixed_storage_double_value_read_linear_size(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `235 + l * (2 ±0)` + // Estimated: `4195527 + l * (2 ±0)` + // Minimum execution time: 4_236 nanoseconds. + Weight::from_parts(4_236_000, 4195527) + // Standard Error: 8 + .saturating_add(Weight::from_ref_time(517).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(2).saturating_mul(l.into())) + } + /// Storage: Pov UnboundedMap (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap (max_values: None, max_size: None, mode: Measured) + /// Storage: Pov UnboundedMap2 (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap2 (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[0, 1000]`. + fn storage_map_unbounded_both_measured_read(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `293 + i * (8 ±0)` + // Estimated: `5524 + i * (16 ±0)` + // Minimum execution time: 5_649 nanoseconds. + Weight::from_parts(6_111_237, 5524) + // Standard Error: 1_060 + .saturating_add(Weight::from_ref_time(2_693).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(16).saturating_mul(i.into())) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// Storage: Pov UnboundedMap (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap (max_values: None, max_size: None, mode: Measured) + /// The range of component `i` is `[0, 1000]`. + fn storage_map_partial_unbounded_read(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `260 + i * (4 ±0)` + // Estimated: `5243 + i * (4 ±0)` + // Minimum execution time: 5_997 nanoseconds. + Weight::from_parts(7_996_508, 5243) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) + } + /// Storage: Pov Map1M (r:1 w:0) + /// Proof: Pov Map1M (max_values: Some(1000000), max_size: Some(36), added: 2511, mode: MaxEncodedLen) + /// Storage: Pov UnboundedMap (r:1 w:0) + /// Proof Skipped: Pov UnboundedMap (max_values: None, max_size: None, mode: Ignored) + /// The range of component `i` is `[0, 1000]`. + fn storage_map_partial_unbounded_ignored_read(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `260 + i * (4 ±0)` + // Estimated: `2768 + i * (4 ±0)` + // Minimum execution time: 5_679 nanoseconds. + Weight::from_parts(6_496_804, 2768) + // Standard Error: 611 + .saturating_add(Weight::from_ref_time(930).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(i.into())) + } + fn emit_event() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_087 nanoseconds. + Weight::from_ref_time(7_087_000) + } + fn noop() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_719 nanoseconds. + Weight::from_ref_time(2_719_000) + } +} diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 5fd845551d..0d511cbff4 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -16,29 +16,25 @@ // limitations under the License. //! A set of benchmarks which can establish a global baseline for all other -//! benchmarking. +//! benchmarking. These benchmarks do not require a pallet to be deployed. #![cfg(feature = "runtime-benchmarks")] +use super::*; use crate::benchmarks; -use codec::Encode; use frame_system::Pallet as System; -use sp_application_crypto::KeyTypeId; use sp_runtime::{ traits::{AppVerify, Hash}, RuntimeAppPublic, }; -use sp_std::prelude::*; -pub const TEST_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"test"); +mod crypto { + use sp_application_crypto::{app_crypto, sr25519, KeyTypeId}; -mod app_sr25519 { - use super::TEST_KEY_TYPE_ID; - use sp_application_crypto::{app_crypto, sr25519}; + pub const TEST_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"test"); app_crypto!(sr25519, TEST_KEY_TYPE_ID); } - -type SignerId = app_sr25519::Public; +pub type SignerId = crypto::Public; pub struct Pallet(System); pub trait Config: frame_system::Config {} @@ -81,7 +77,6 @@ benchmarks! { } hashing { - let i in 0 .. 100; let mut hash = T::Hash::default(); }: { (0..=100_000u32).for_each(|j| hash = T::Hashing::hash(&j.to_be_bytes())); @@ -106,53 +101,17 @@ benchmarks! { }); } - #[skip_meta] - storage_read { - let i in 0 .. 1_000; - let mut people = Vec::new(); - (0..i).for_each(|j| { - let hash = T::Hashing::hash(&j.to_be_bytes()).encode(); - frame_support::storage::unhashed::put(&hash, &hash); - people.push(hash); - }); - }: { - people.iter().for_each(|hash| { - // This does a storage read - let value = frame_support::storage::unhashed::get(hash); - assert_eq!(value, Some(hash.to_vec())); - }); - } - - #[skip_meta] - storage_write { - let i in 0 .. 1_000; - let mut hashes = Vec::new(); - (0..i).for_each(|j| { - let hash = T::Hashing::hash(&j.to_be_bytes()); - hashes.push(hash.encode()); - }); - }: { - hashes.iter().for_each(|hash| { - // This does a storage write - frame_support::storage::unhashed::put(hash, hash); - }); - } verify { - hashes.iter().for_each(|hash| { - let value = frame_support::storage::unhashed::get(hash); - assert_eq!(value, Some(hash.to_vec())); - }); - } - impl_benchmark_test_suite!( Pallet, - crate::baseline::mock::new_test_ext(), - crate::baseline::mock::Test, + mock::new_test_ext(), + mock::Test, ); } #[cfg(test)] pub mod mock { - use sp_runtime::{testing::H256, traits::IdentityLookup}; + use super::*; + use sp_runtime::testing::H256; type AccountId = u64; type AccountIndex = u32; @@ -183,7 +142,7 @@ pub mod mock { type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; + type Lookup = sp_runtime::traits::IdentityLookup; type Header = sp_runtime::testing::Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index e4ebd2f228..525370e233 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -47,7 +47,7 @@ pub use sp_runtime::traits::Zero; pub use sp_runtime::StateVersion; #[doc(hidden)] pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec}; -pub use sp_storage::TrackedStorageKey; +pub use sp_storage::{well_known_keys, TrackedStorageKey}; pub use utils::*; /// Whitelist the given account. @@ -211,6 +211,7 @@ macro_rules! benchmarks { ( ) ( ) ( ) + ( ) $( $rest )* ); } @@ -231,6 +232,7 @@ macro_rules! benchmarks_instance { ( ) ( ) ( ) + ( ) $( $rest )* ); } @@ -251,6 +253,7 @@ macro_rules! benchmarks_instance_pallet { ( ) ( ) ( ) + ( ) $( $rest )* ); } @@ -268,6 +271,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) impl_benchmark_test_suite!( $bench_module:ident, $new_test_ext:expr, @@ -282,6 +286,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $( $rest )* } }; @@ -293,6 +298,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) impl_benchmark_test_suite!( $bench_module:ident, $new_test_ext:expr, @@ -307,6 +313,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $( $rest )* } }; @@ -318,6 +325,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) where_clause { where $( $where_bound:tt )* } $( $rest:tt )* ) => { @@ -328,6 +336,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $( $rest )* } }; @@ -339,7 +348,9 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) #[skip_meta] + $( #[ $($attributes:tt)+ ] )* $name:ident $( $rest:tt )* ) => { @@ -350,6 +361,8 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* $name ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( #[ $( $attributes )+ ] )* $name $( $rest )* } @@ -362,7 +375,9 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) #[extra] + $( #[ $($attributes:tt)+ ] )* $name:ident $( $rest:tt )* ) => { @@ -373,6 +388,35 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* $name ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( #[ $( $attributes )+ ] )* + $name + $( $rest )* + } + }; + // detect and extract `#[pov_mode = Mode { Pallet::Storage: Mode ... }]` tag: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $old_pov_name:ident: $( $old_storage:path = $old_pov_mode:ident )*; )* ) + #[pov_mode = $mode:ident $( { $( $storage:path: $pov_mode:ident )* } )?] + $( #[ $($attributes:tt)+ ] )* + $name:ident + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $name: ALL = $mode $($( $storage = $pov_mode )*)?; $( $old_pov_name: $( $old_storage = $old_pov_mode )*; )* ) + $( #[ $( $attributes )+ ] )* $name $( $rest )* } @@ -385,6 +429,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) // This contains $( $( { $instance } )? $name:ident )* ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) $name:ident { $( $code:tt )* }: _ $(< $origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) verify $postcode:block $( $rest:tt )* @@ -396,6 +441,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $name { $( $code )* }: $name $(< $origin_type >)? ( $origin $( , $arg )* ) verify $postcode $( $rest )* @@ -409,6 +455,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) $name:ident { $( $code:tt )* }: $dispatch:ident $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) verify $postcode:block $( $rest:tt )* @@ -421,6 +468,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $name { $( $code )* let __call = Call::< @@ -455,6 +503,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) $name:ident { $( $code:tt )* }: $eval:block verify $postcode:block $( $rest:tt )* @@ -483,6 +532,7 @@ macro_rules! benchmarks_iter { ( $( $names )* { $( $instance )? } $name ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $( $rest )* ); }; @@ -494,6 +544,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) ) => { $crate::selected_benchmark!( { $( $where_clause)* } @@ -506,6 +557,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra ),* ) ( $( $names_skip_meta ),* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) ); $crate::impl_test_function!( ( $( $names )* ) @@ -525,6 +577,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) ) => { $crate::selected_benchmark!( { $( $where_clause)* } @@ -537,6 +590,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra ),* ) ( $( $names_skip_meta ),* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) ); }; // add verify block to _() format @@ -547,6 +601,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) $name:ident { $( $code:tt )* }: _ $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) $( $rest:tt )* ) => { @@ -557,6 +612,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $name { $( $code )* }: _ $(<$origin_type>)? ( $origin $( , $arg )* ) verify { } $( $rest )* @@ -570,6 +626,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) $name:ident { $( $code:tt )* }: $dispatch:ident $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) $( $rest:tt )* ) => { @@ -580,6 +637,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $name { $( $code )* }: $dispatch $(<$origin_type>)? ( $origin $( , $arg )* ) verify { } $( $rest )* @@ -593,6 +651,7 @@ macro_rules! benchmarks_iter { ( $( $names:tt )* ) ( $( $names_extra:tt )* ) ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) $name:ident { $( $code:tt )* }: $(<$origin_type:ty>)? $eval:block $( $rest:tt )* ) => { @@ -603,6 +662,7 @@ macro_rules! benchmarks_iter { ( $( $names )* ) ( $( $names_extra )* ) ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) $name { $( $code )* }: $(<$origin_type>)? $eval verify { } $( $rest )* @@ -981,6 +1041,7 @@ macro_rules! impl_benchmark { ( $( { $( $name_inst:ident )? } $name:ident )* ) ( $( $name_extra:ident ),* ) ( $( $name_skip_meta:ident ),* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) ) => { // We only need to implement benchmarks for the runtime-benchmarks feature or testing. #[cfg(any(feature = "runtime-benchmarks", test))] @@ -989,23 +1050,37 @@ macro_rules! impl_benchmark { where T: frame_system::Config, $( $where_clause )* { fn benchmarks(extra: bool) -> $crate::Vec<$crate::BenchmarkMetadata> { + $($crate::validate_pov_mode!( + $pov_name: $( $storage = $pov_mode )*; + );)* let mut all_names = $crate::vec![ $( stringify!($name).as_ref() ),* ]; if !extra { let extra = [ $( stringify!($name_extra).as_ref() ),* ]; all_names.retain(|x| !extra.contains(x)); } + let pov_modes: $crate::Vec<($crate::Vec, $crate::Vec<($crate::Vec, $crate::Vec)>)> = $crate::vec![ + $( + (stringify!($pov_name).as_bytes().to_vec(), + $crate::vec![ + $( ( stringify!($storage).as_bytes().to_vec(), + stringify!($pov_mode).as_bytes().to_vec() ), )* + ]), + )* + ]; all_names.into_iter().map(|benchmark| { let selected_benchmark = match benchmark { $( stringify!($name) => SelectedBenchmark::$name, )* _ => panic!("all benchmarks should be selectable"), }; + let name = benchmark.as_bytes().to_vec(); let components = < SelectedBenchmark as $crate::BenchmarkingSetup >::components(&selected_benchmark); $crate::BenchmarkMetadata { - name: benchmark.as_bytes().to_vec(), + name: name.clone(), components, + pov_modes: pov_modes.iter().find(|p| p.0 == name).map(|p| p.1.clone()).unwrap_or_default(), } }).collect::<$crate::Vec<_>>() } @@ -1037,8 +1112,13 @@ macro_rules! impl_benchmark { $crate::frame_support::storage::transactional::TRANSACTION_LEVEL_KEY.into() ); whitelist.push(transactional_layer_key); + // Whitelist the `:extrinsic_index`. + let extrinsic_index = $crate::TrackedStorageKey::new( + $crate::well_known_keys::EXTRINSIC_INDEX.into() + ); + whitelist.push(extrinsic_index); - $crate::benchmarking::set_whitelist(whitelist); + $crate::benchmarking::set_whitelist(whitelist.clone()); let mut results: $crate::Vec<$crate::BenchmarkResult> = $crate::Vec::new(); @@ -1062,15 +1142,22 @@ macro_rules! impl_benchmark { // This will enable worst case scenario for reading from the database. $crate::benchmarking::commit_db(); + // Access all whitelisted keys to get them into the proof recorder since the + // recorder does now have a whitelist. + for key in &whitelist { + $crate::frame_support::storage::unhashed::get_raw(&key.key); + } + // 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. $crate::log::trace!( target: "benchmark", - "Start Benchmark: {} ({:?})", + "Start Benchmark: {} ({:?}) verify {}", extrinsic, - c + c, + verify ); let start_pov = $crate::benchmarking::proof_size(); @@ -1099,6 +1186,10 @@ macro_rules! impl_benchmark { target: "benchmark", "Read/Write Count {:?}", read_write_count ); + $crate::log::trace!( + target: "benchmark", + "Proof sizes: before {:?} after {:?} diff {}", &start_pov, &end_pov, &diff_pov + ); // Time the storage root recalculation. let start_storage_root = $crate::benchmarking::current_time(); @@ -1421,6 +1512,37 @@ macro_rules! impl_benchmark_test_suite { } } +/// Validates the passed `pov_mode`s. +/// +/// Checks that: +/// - a top-level `ignored` is exclusive +/// - all modes are valid +#[macro_export] +macro_rules! validate_pov_mode { + () => {}; + ( $_bench:ident: ; ) => { }; + ( $_bench:ident: $_car:path = Ignored ; ) => { }; + ( $bench:ident: $_car:path = Ignored $( $storage:path = $_pov_mode:ident )+; ) => { + compile_error!( + concat!(concat!("`pov_mode = Ignored` is exclusive. Please remove the attribute from keys: ", $( stringify!($storage) )+), " on benchmark '", stringify!($bench), "'")); + }; + ( $bench:ident: $car:path = Measured $( $storage:path = $pov_mode:ident )*; ) => { + $crate::validate_pov_mode!( + $bench: $( $storage = $pov_mode )*; + ); + }; + ( $bench:ident: $car:path = MaxEncodedLen $( $storage:path = $pov_mode:ident )*; ) => { + $crate::validate_pov_mode!( + $bench: $( $storage = $pov_mode )*; + ); + }; + ( $bench:ident: $key:path = $unknown:ident $( $_storage:path = $_pov_mode:ident )*; ) => { + compile_error!( + concat!("Unknown pov_mode '", stringify!($unknown) ,"' for benchmark '", stringify!($bench), "' on key '", stringify!($key), "'. Must be one of: Ignored, Measured, MaxEncodedLen") + ); + }; +} + // Takes all arguments from `impl_benchmark_test_suite` and three additional arguments. // // Can be configured to generate one #[test] fn per bench case or diff --git a/frame/benchmarking/src/utils.rs b/frame/benchmarking/src/utils.rs index 654b1c34c0..6ad9ac7bb0 100644 --- a/frame/benchmarking/src/utils.rs +++ b/frame/benchmarking/src/utils.rs @@ -227,6 +227,7 @@ pub struct BenchmarkList { pub struct BenchmarkMetadata { pub name: Vec, pub components: Vec<(BenchmarkParameter, u32, u32)>, + pub pov_modes: Vec<(Vec, Vec)>, } sp_api::decl_runtime_apis! { diff --git a/frame/benchmarking/src/weights.rs b/frame/benchmarking/src/weights.rs index 5e5a2e7ee3..dea9594712 100644 --- a/frame/benchmarking/src/weights.rs +++ b/frame/benchmarking/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for frame_benchmarking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -51,10 +52,8 @@ pub trait WeightInfo { fn subtraction(i: u32, ) -> Weight; fn multiplication(i: u32, ) -> Weight; fn division(i: u32, ) -> Weight; - fn hashing(i: u32, ) -> Weight; + fn hashing() -> Weight; fn sr25519_verification(i: u32, ) -> Weight; - fn storage_read(i: u32, ) -> Weight; - fn storage_write(i: u32, ) -> Weight; } /// Weights for frame_benchmarking using the Substrate node and recommended hardware. @@ -62,53 +61,52 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 1000000]`. fn addition(_i: u32, ) -> Weight { - // Minimum execution time: 108 nanoseconds. - Weight::from_ref_time(137_610 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 138 nanoseconds. + Weight::from_ref_time(199_805) } /// The range of component `i` is `[0, 1000000]`. fn subtraction(_i: u32, ) -> Weight { - // Minimum execution time: 104 nanoseconds. - Weight::from_ref_time(133_508 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 142 nanoseconds. + Weight::from_ref_time(201_435) } /// The range of component `i` is `[0, 1000000]`. fn multiplication(_i: u32, ) -> Weight { - // Minimum execution time: 110 nanoseconds. - Weight::from_ref_time(140_230 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 138 nanoseconds. + Weight::from_ref_time(207_037) } /// The range of component `i` is `[0, 1000000]`. fn division(_i: u32, ) -> Weight { - // Minimum execution time: 96 nanoseconds. - Weight::from_ref_time(136_059 as u64) - } - /// The range of component `i` is `[0, 100]`. - fn hashing(_i: u32, ) -> Weight { - // Minimum execution time: 21_804_747 nanoseconds. - Weight::from_ref_time(22_013_681_386 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 151 nanoseconds. + Weight::from_ref_time(205_150) + } + fn hashing() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 21_950_884 nanoseconds. + Weight::from_ref_time(21_994_001_000) } /// The range of component `i` is `[0, 100]`. fn sr25519_verification(i: u32, ) -> Weight { - // Minimum execution time: 136 nanoseconds. - Weight::from_ref_time(156_000 as u64) - // Standard Error: 4_531 - .saturating_add(Weight::from_ref_time(46_817_640 as u64).saturating_mul(i as u64)) - } - // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[0, 1000]`. - fn storage_read(i: u32, ) -> Weight { - // Minimum execution time: 125 nanoseconds. - Weight::from_ref_time(135_000 as u64) - // Standard Error: 3_651 - .saturating_add(Weight::from_ref_time(2_021_172 as u64).saturating_mul(i as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(i as u64))) - } - // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[0, 1000]`. - fn storage_write(i: u32, ) -> Weight { - // Minimum execution time: 120 nanoseconds. - Weight::from_ref_time(131_000 as u64) - // Standard Error: 348 - .saturating_add(Weight::from_ref_time(377_243 as u64).saturating_mul(i as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 168 nanoseconds. + Weight::from_ref_time(1_680_898) + // Standard Error: 10_291 + .saturating_add(Weight::from_ref_time(46_867_301).saturating_mul(i.into())) } } @@ -116,52 +114,51 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { /// The range of component `i` is `[0, 1000000]`. fn addition(_i: u32, ) -> Weight { - // Minimum execution time: 108 nanoseconds. - Weight::from_ref_time(137_610 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 138 nanoseconds. + Weight::from_ref_time(199_805) } /// The range of component `i` is `[0, 1000000]`. fn subtraction(_i: u32, ) -> Weight { - // Minimum execution time: 104 nanoseconds. - Weight::from_ref_time(133_508 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 142 nanoseconds. + Weight::from_ref_time(201_435) } /// The range of component `i` is `[0, 1000000]`. fn multiplication(_i: u32, ) -> Weight { - // Minimum execution time: 110 nanoseconds. - Weight::from_ref_time(140_230 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 138 nanoseconds. + Weight::from_ref_time(207_037) } /// The range of component `i` is `[0, 1000000]`. fn division(_i: u32, ) -> Weight { - // Minimum execution time: 96 nanoseconds. - Weight::from_ref_time(136_059 as u64) - } - /// The range of component `i` is `[0, 100]`. - fn hashing(_i: u32, ) -> Weight { - // Minimum execution time: 21_804_747 nanoseconds. - Weight::from_ref_time(22_013_681_386 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 151 nanoseconds. + Weight::from_ref_time(205_150) + } + fn hashing() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 21_950_884 nanoseconds. + Weight::from_ref_time(21_994_001_000) } /// The range of component `i` is `[0, 100]`. fn sr25519_verification(i: u32, ) -> Weight { - // Minimum execution time: 136 nanoseconds. - Weight::from_ref_time(156_000 as u64) - // Standard Error: 4_531 - .saturating_add(Weight::from_ref_time(46_817_640 as u64).saturating_mul(i as u64)) - } - // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[0, 1000]`. - fn storage_read(i: u32, ) -> Weight { - // Minimum execution time: 125 nanoseconds. - Weight::from_ref_time(135_000 as u64) - // Standard Error: 3_651 - .saturating_add(Weight::from_ref_time(2_021_172 as u64).saturating_mul(i as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(i as u64))) - } - // Storage: Skipped Metadata (r:0 w:0) - /// The range of component `i` is `[0, 1000]`. - fn storage_write(i: u32, ) -> Weight { - // Minimum execution time: 120 nanoseconds. - Weight::from_ref_time(131_000 as u64) - // Standard Error: 348 - .saturating_add(Weight::from_ref_time(377_243 as u64).saturating_mul(i as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 168 nanoseconds. + Weight::from_ref_time(1_680_898) + // Standard Error: 10_291 + .saturating_add(Weight::from_ref_time(46_867_301).saturating_mul(i.into())) } } diff --git a/frame/bounties/src/weights.rs b/frame/bounties/src/weights.rs index 34e78bfa55..1ae8ab2983 100644 --- a/frame/bounties/src/weights.rs +++ b/frame/bounties/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_bounties //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_bounties // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_bounties -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/bounties/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -64,214 +64,340 @@ pub trait WeightInfo { /// Weights for pallet_bounties using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Bounties BountyCount (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Bounties BountyDescriptions (r:0 w:1) - // Storage: Bounties Bounties (r:0 w:1) + /// Storage: Bounties BountyCount (r:1 w:1) + /// Proof: Bounties BountyCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:0 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) /// The range of component `d` is `[0, 300]`. fn propose_bounty(d: u32, ) -> Weight { - // Minimum execution time: 33_366 nanoseconds. - Weight::from_ref_time(34_444_773) - // Standard Error: 1_161 - .saturating_add(Weight::from_ref_time(4_723).saturating_mul(d.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `308` + // Estimated: `3102` + // Minimum execution time: 22_787 nanoseconds. + Weight::from_parts(23_898_632, 3102) + // Standard Error: 141 + .saturating_add(Weight::from_ref_time(568).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: Bounties BountyApprovals (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_bounty() -> Weight { - // Minimum execution time: 14_478 nanoseconds. - Weight::from_ref_time(14_763_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `3549` + // Minimum execution time: 10_526 nanoseconds. + Weight::from_parts(10_729_000, 3549) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn propose_curator() -> Weight { - // Minimum execution time: 13_376 nanoseconds. - Weight::from_ref_time(13_705_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `420` + // Estimated: `2652` + // Minimum execution time: 9_193 nanoseconds. + Weight::from_parts(9_455_000, 2652) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { - // Minimum execution time: 38_072 nanoseconds. - Weight::from_ref_time(38_676_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `628` + // Estimated: `5255` + // Minimum execution time: 22_592 nanoseconds. + Weight::from_parts(22_952_000, 5255) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { - // Minimum execution time: 33_207 nanoseconds. - Weight::from_ref_time(34_415_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `624` + // Estimated: `5255` + // Minimum execution time: 20_920 nanoseconds. + Weight::from_parts(21_369_000, 5255) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) fn award_bounty() -> Weight { - // Minimum execution time: 28_033 nanoseconds. - Weight::from_ref_time(28_343_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `570` + // Estimated: `5143` + // Minimum execution time: 17_853 nanoseconds. + Weight::from_parts(18_280_000, 5143) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) - // Storage: Bounties BountyDescriptions (r:0 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_bounty() -> Weight { - // Minimum execution time: 75_855 nanoseconds. - Weight::from_ref_time(76_318_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `998` + // Estimated: `12964` + // Minimum execution time: 67_538 nanoseconds. + Weight::from_parts(67_974_000, 12964) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Bounties BountyDescriptions (r:0 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_proposed() -> Weight { - // Minimum execution time: 41_955 nanoseconds. - Weight::from_ref_time(42_733_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `646` + // Estimated: `7746` + // Minimum execution time: 28_380 nanoseconds. + Weight::from_parts(28_859_000, 7746) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Bounties BountyDescriptions (r:0 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_active() -> Weight { - // Minimum execution time: 58_267 nanoseconds. - Weight::from_ref_time(59_604_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `914` + // Estimated: `10349` + // Minimum execution time: 47_739 nanoseconds. + Weight::from_parts(48_388_000, 10349) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: Bounties Bounties (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn extend_bounty_expiry() -> Weight { - // Minimum execution time: 24_893 nanoseconds. - Weight::from_ref_time(25_299_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `456` + // Estimated: `2652` + // Minimum execution time: 14_188 nanoseconds. + Weight::from_parts(14_801_000, 2652) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Bounties Bounties (r:2 w:2) - // Storage: System Account (r:4 w:4) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:100 w:100) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:200 w:200) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32, ) -> Weight { - // Minimum execution time: 8_846 nanoseconds. - Weight::from_ref_time(20_166_004) - // Standard Error: 28_485 - .saturating_add(Weight::from_ref_time(26_712_253).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(1)) + // Proof Size summary in bytes: + // Measured: `31 + b * (360 ±0)` + // Estimated: `897 + b * (7858 ±0)` + // Minimum execution time: 4_685 nanoseconds. + Weight::from_parts(9_932_840, 897) + // Standard Error: 14_301 + .saturating_add(Weight::from_ref_time(27_178_347).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into()))) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into()))) + .saturating_add(Weight::from_proof_size(7858).saturating_mul(b.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Bounties BountyCount (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Bounties BountyDescriptions (r:0 w:1) - // Storage: Bounties Bounties (r:0 w:1) + /// Storage: Bounties BountyCount (r:1 w:1) + /// Proof: Bounties BountyCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:0 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) /// The range of component `d` is `[0, 300]`. fn propose_bounty(d: u32, ) -> Weight { - // Minimum execution time: 33_366 nanoseconds. - Weight::from_ref_time(34_444_773) - // Standard Error: 1_161 - .saturating_add(Weight::from_ref_time(4_723).saturating_mul(d.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `308` + // Estimated: `3102` + // Minimum execution time: 22_787 nanoseconds. + Weight::from_parts(23_898_632, 3102) + // Standard Error: 141 + .saturating_add(Weight::from_ref_time(568).saturating_mul(d.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: Bounties BountyApprovals (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_bounty() -> Weight { - // Minimum execution time: 14_478 nanoseconds. - Weight::from_ref_time(14_763_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `400` + // Estimated: `3549` + // Minimum execution time: 10_526 nanoseconds. + Weight::from_parts(10_729_000, 3549) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn propose_curator() -> Weight { - // Minimum execution time: 13_376 nanoseconds. - Weight::from_ref_time(13_705_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `420` + // Estimated: `2652` + // Minimum execution time: 9_193 nanoseconds. + Weight::from_parts(9_455_000, 2652) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { - // Minimum execution time: 38_072 nanoseconds. - Weight::from_ref_time(38_676_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `628` + // Estimated: `5255` + // Minimum execution time: 22_592 nanoseconds. + Weight::from_parts(22_952_000, 5255) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { - // Minimum execution time: 33_207 nanoseconds. - Weight::from_ref_time(34_415_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `624` + // Estimated: `5255` + // Minimum execution time: 20_920 nanoseconds. + Weight::from_parts(21_369_000, 5255) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) fn award_bounty() -> Weight { - // Minimum execution time: 28_033 nanoseconds. - Weight::from_ref_time(28_343_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `570` + // Estimated: `5143` + // Minimum execution time: 17_853 nanoseconds. + Weight::from_parts(18_280_000, 5143) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) - // Storage: Bounties BountyDescriptions (r:0 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_bounty() -> Weight { - // Minimum execution time: 75_855 nanoseconds. - Weight::from_ref_time(76_318_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `998` + // Estimated: `12964` + // Minimum execution time: 67_538 nanoseconds. + Weight::from_parts(67_974_000, 12964) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Bounties BountyDescriptions (r:0 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_proposed() -> Weight { - // Minimum execution time: 41_955 nanoseconds. - Weight::from_ref_time(42_733_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `646` + // Estimated: `7746` + // Minimum execution time: 28_380 nanoseconds. + Weight::from_parts(28_859_000, 7746) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Bounties Bounties (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Bounties BountyDescriptions (r:0 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:0) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyDescriptions (r:0 w:1) + /// Proof: Bounties BountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_bounty_active() -> Weight { - // Minimum execution time: 58_267 nanoseconds. - Weight::from_ref_time(59_604_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `914` + // Estimated: `10349` + // Minimum execution time: 47_739 nanoseconds. + Weight::from_parts(48_388_000, 10349) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: Bounties Bounties (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:1) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) fn extend_bounty_expiry() -> Weight { - // Minimum execution time: 24_893 nanoseconds. - Weight::from_ref_time(25_299_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `456` + // Estimated: `2652` + // Minimum execution time: 14_188 nanoseconds. + Weight::from_parts(14_801_000, 2652) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Bounties Bounties (r:2 w:2) - // Storage: System Account (r:4 w:4) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:100 w:100) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:200 w:200) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `b` is `[0, 100]`. fn spend_funds(b: u32, ) -> Weight { - // Minimum execution time: 8_846 nanoseconds. - Weight::from_ref_time(20_166_004) - // Standard Error: 28_485 - .saturating_add(Weight::from_ref_time(26_712_253).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(1)) + // Proof Size summary in bytes: + // Measured: `31 + b * (360 ±0)` + // Estimated: `897 + b * (7858 ±0)` + // Minimum execution time: 4_685 nanoseconds. + Weight::from_parts(9_932_840, 897) + // Standard Error: 14_301 + .saturating_add(Weight::from_ref_time(27_178_347).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(b.into()))) - .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into()))) + .saturating_add(Weight::from_proof_size(7858).saturating_mul(b.into())) } } diff --git a/frame/child-bounties/src/weights.rs b/frame/child-bounties/src/weights.rs index 235c84320e..77ab24488e 100644 --- a/frame/child-bounties/src/weights.rs +++ b/frame/child-bounties/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_child_bounties //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -60,176 +61,290 @@ pub trait WeightInfo { /// Weights for pallet_child_bounties using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: ChildBounties ChildBountyCount (r:1 w:1) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) - // Storage: ChildBounties ChildBounties (r:0 w:1) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyCount (r:1 w:1) + /// Proof: ChildBounties ChildBountyCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:0 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) /// The range of component `d` is `[0, 300]`. fn add_child_bounty(d: u32, ) -> Weight { - // Minimum execution time: 59_121 nanoseconds. - Weight::from_ref_time(60_212_235 as u64) - // Standard Error: 149 - .saturating_add(Weight::from_ref_time(412 as u64).saturating_mul(d as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `742` + // Estimated: `10848` + // Minimum execution time: 46_743 nanoseconds. + Weight::from_parts(47_762_924, 10848) + // Standard Error: 135 + .saturating_add(Weight::from_ref_time(599).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn propose_curator() -> Weight { - // Minimum execution time: 20_785 nanoseconds. - Weight::from_ref_time(21_000_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `796` + // Estimated: `7775` + // Minimum execution time: 16_417 nanoseconds. + Weight::from_parts(16_712_000, 7775) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { - // Minimum execution time: 37_874 nanoseconds. - Weight::from_ref_time(38_322_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `974` + // Estimated: `7875` + // Minimum execution time: 25_548 nanoseconds. + Weight::from_parts(25_919_000, 7875) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { - // Minimum execution time: 43_385 nanoseconds. - Weight::from_ref_time(43_774_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `974` + // Estimated: `7875` + // Minimum execution time: 27_645 nanoseconds. + Weight::from_parts(27_947_000, 7875) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) fn award_child_bounty() -> Weight { - // Minimum execution time: 31_390 nanoseconds. - Weight::from_ref_time(31_802_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `839` + // Estimated: `5272` + // Minimum execution time: 20_002 nanoseconds. + Weight::from_parts(20_512_000, 5272) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_child_bounty() -> Weight { - // Minimum execution time: 74_956 nanoseconds. - Weight::from_ref_time(75_850_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `744` + // Estimated: `12920` + // Minimum execution time: 63_752 nanoseconds. + Weight::from_parts(64_179_000, 12920) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_added() -> Weight { - // Minimum execution time: 57_215 nanoseconds. - Weight::from_ref_time(58_285_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `1106` + // Estimated: `15472` + // Minimum execution time: 47_388 nanoseconds. + Weight::from_parts(47_946_000, 15472) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_active() -> Weight { - // Minimum execution time: 67_641 nanoseconds. - Weight::from_ref_time(69_184_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(7 as u64)) + // Proof Size summary in bytes: + // Measured: `1325` + // Estimated: `18075` + // Minimum execution time: 58_008 nanoseconds. + Weight::from_parts(58_586_000, 18075) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: ChildBounties ChildBountyCount (r:1 w:1) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) - // Storage: ChildBounties ChildBounties (r:0 w:1) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyCount (r:1 w:1) + /// Proof: ChildBounties ChildBountyCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:0 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) /// The range of component `d` is `[0, 300]`. fn add_child_bounty(d: u32, ) -> Weight { - // Minimum execution time: 59_121 nanoseconds. - Weight::from_ref_time(60_212_235 as u64) - // Standard Error: 149 - .saturating_add(Weight::from_ref_time(412 as u64).saturating_mul(d as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `742` + // Estimated: `10848` + // Minimum execution time: 46_743 nanoseconds. + Weight::from_parts(47_762_924, 10848) + // Standard Error: 135 + .saturating_add(Weight::from_ref_time(599).saturating_mul(d.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn propose_curator() -> Weight { - // Minimum execution time: 20_785 nanoseconds. - Weight::from_ref_time(21_000_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `796` + // Estimated: `7775` + // Minimum execution time: 16_417 nanoseconds. + Weight::from_parts(16_712_000, 7775) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn accept_curator() -> Weight { - // Minimum execution time: 37_874 nanoseconds. - Weight::from_ref_time(38_322_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: Bounties Bounties (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `974` + // Estimated: `7875` + // Minimum execution time: 25_548 nanoseconds. + Weight::from_parts(25_919_000, 7875) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn unassign_curator() -> Weight { - // Minimum execution time: 43_385 nanoseconds. - Weight::from_ref_time(43_774_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `974` + // Estimated: `7875` + // Minimum execution time: 27_645 nanoseconds. + Weight::from_parts(27_947_000, 7875) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) fn award_child_bounty() -> Weight { - // Minimum execution time: 31_390 nanoseconds. - Weight::from_ref_time(31_802_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `839` + // Estimated: `5272` + // Minimum execution time: 20_002 nanoseconds. + Weight::from_parts(20_512_000, 5272) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn claim_child_bounty() -> Weight { - // Minimum execution time: 74_956 nanoseconds. - Weight::from_ref_time(75_850_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `744` + // Estimated: `12920` + // Minimum execution time: 63_752 nanoseconds. + Weight::from_parts(64_179_000, 12920) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_added() -> Weight { - // Minimum execution time: 57_215 nanoseconds. - Weight::from_ref_time(58_285_000 as u64) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) - } - // Storage: Bounties Bounties (r:1 w:0) - // Storage: ChildBounties ChildBounties (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) - // Storage: ChildBounties ParentChildBounties (r:1 w:1) - // Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `1106` + // Estimated: `15472` + // Minimum execution time: 47_388 nanoseconds. + Weight::from_parts(47_946_000, 15472) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Bounties Bounties (r:1 w:0) + /// Proof: Bounties Bounties (max_values: None, max_size: Some(177), added: 2652, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBounties (r:1 w:1) + /// Proof: ChildBounties ChildBounties (max_values: None, max_size: Some(145), added: 2620, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildrenCuratorFees (r:1 w:1) + /// Proof: ChildBounties ChildrenCuratorFees (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: ChildBounties ParentChildBounties (r:1 w:1) + /// Proof: ChildBounties ParentChildBounties (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: ChildBounties ChildBountyDescriptions (r:0 w:1) + /// Proof: ChildBounties ChildBountyDescriptions (max_values: None, max_size: Some(314), added: 2789, mode: MaxEncodedLen) fn close_child_bounty_active() -> Weight { - // Minimum execution time: 67_641 nanoseconds. - Weight::from_ref_time(69_184_000 as u64) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(7 as u64)) + // Proof Size summary in bytes: + // Measured: `1325` + // Estimated: `18075` + // Minimum execution time: 58_008 nanoseconds. + Weight::from_parts(58_586_000, 18075) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) } } diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs index 052550de7b..fe6a222017 100644 --- a/frame/collective/src/weights.rs +++ b/frame/collective/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -62,326 +63,492 @@ pub trait WeightInfo { /// Weights for pallet_collective using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Council Members (r:1 w:1) - // Storage: Council Proposals (r:1 w:0) - // Storage: Council Prime (r:0 w:1) - // Storage: Council Voting (r:100 w:100) + /// Storage: Council Members (r:1 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:100 w:100) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Prime (r:0 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[0, 100]`. /// The range of component `n` is `[0, 100]`. /// The range of component `p` is `[0, 100]`. fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { - // Minimum execution time: 18_895 nanoseconds. - Weight::from_ref_time(19_254_000 as u64) - // Standard Error: 63_540 - .saturating_add(Weight::from_ref_time(5_061_801 as u64).saturating_mul(m as u64)) - // Standard Error: 63_540 - .saturating_add(Weight::from_ref_time(7_588_981 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + // Proof Size summary in bytes: + // Measured: `0 + m * (3233 ±0) + p * (3223 ±0)` + // Estimated: `16586 + m * (7809 ±24) + p * (10238 ±24)` + // Minimum execution time: 17_093 nanoseconds. + Weight::from_parts(17_284_000, 16586) + // Standard Error: 64_700 + .saturating_add(Weight::from_ref_time(5_143_145).saturating_mul(m.into())) + // Standard Error: 64_700 + .saturating_add(Weight::from_ref_time(7_480_941).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_proof_size(7809).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(10238).saturating_mul(p.into())) } - // Storage: Council Members (r:1 w:0) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - // Minimum execution time: 24_469 nanoseconds. - Weight::from_ref_time(23_961_134 as u64) - // Standard Error: 43 - .saturating_add(Weight::from_ref_time(1_677 as u64).saturating_mul(b as u64)) - // Standard Error: 450 - .saturating_add(Weight::from_ref_time(18_645 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `234 + m * (32 ±0)` + // Estimated: `730 + m * (32 ±0)` + // Minimum execution time: 15_972 nanoseconds. + Weight::from_parts(14_971_445, 730) + // Standard Error: 32 + .saturating_add(Weight::from_ref_time(1_775).saturating_mul(b.into())) + // Standard Error: 334 + .saturating_add(Weight::from_ref_time(17_052).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(Weight::from_proof_size(32).saturating_mul(m.into())) } - // Storage: Council Members (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:0) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:0) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - // Minimum execution time: 26_476 nanoseconds. - Weight::from_ref_time(25_829_298 as u64) - // Standard Error: 49 - .saturating_add(Weight::from_ref_time(1_741 as u64).saturating_mul(b as u64)) - // Standard Error: 515 - .saturating_add(Weight::from_ref_time(29_436 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) + // Proof Size summary in bytes: + // Measured: `234 + m * (32 ±0)` + // Estimated: `3440 + m * (64 ±0)` + // Minimum execution time: 17_950 nanoseconds. + Weight::from_parts(17_019_558, 3440) + // Standard Error: 41 + .saturating_add(Weight::from_ref_time(1_807).saturating_mul(b.into())) + // Standard Error: 432 + .saturating_add(Weight::from_ref_time(27_986).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(64).saturating_mul(m.into())) } - // Storage: Council Members (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:1) - // Storage: Council Proposals (r:1 w:1) - // Storage: Council ProposalCount (r:1 w:1) - // Storage: Council Voting (r:0 w:1) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalCount (r:1 w:1) + /// Proof Skipped: Council ProposalCount (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:0 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 33_585 nanoseconds. - Weight::from_ref_time(33_092_289 as u64) - // Standard Error: 173 - .saturating_add(Weight::from_ref_time(4_266 as u64).saturating_mul(b as u64)) - // Standard Error: 1_812 - .saturating_add(Weight::from_ref_time(29_262 as u64).saturating_mul(m as u64)) - // Standard Error: 1_789 - .saturating_add(Weight::from_ref_time(181_285 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `556 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `6355 + m * (165 ±0) + p * (180 ±0)` + // Minimum execution time: 24_817 nanoseconds. + Weight::from_parts(24_778_955, 6355) + // Standard Error: 73 + .saturating_add(Weight::from_ref_time(2_355).saturating_mul(b.into())) + // Standard Error: 765 + .saturating_add(Weight::from_ref_time(20_518).saturating_mul(m.into())) + // Standard Error: 755 + .saturating_add(Weight::from_ref_time(85_670).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_proof_size(165).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(180).saturating_mul(p.into())) } - // Storage: Council Members (r:1 w:0) - // Storage: Council Voting (r:1 w:1) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - // Minimum execution time: 36_374 nanoseconds. - Weight::from_ref_time(38_950_243 as u64) - // Standard Error: 2_583 - .saturating_add(Weight::from_ref_time(65_345 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1006 + m * (64 ±0)` + // Estimated: `4980 + m * (128 ±0)` + // Minimum execution time: 19_790 nanoseconds. + Weight::from_parts(20_528_275, 4980) + // Standard Error: 651 + .saturating_add(Weight::from_ref_time(48_856).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(128).saturating_mul(m.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council Proposals (r:1 w:1) - // Storage: Council ProposalOf (r:0 w:1) + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:0 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 36_066 nanoseconds. - Weight::from_ref_time(38_439_655 as u64) - // Standard Error: 1_281 - .saturating_add(Weight::from_ref_time(17_045 as u64).saturating_mul(m as u64)) - // Standard Error: 1_249 - .saturating_add(Weight::from_ref_time(164_998 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `626 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `5893 + m * (260 ±0) + p * (144 ±0)` + // Minimum execution time: 25_564 nanoseconds. + Weight::from_parts(25_535_497, 5893) + // Standard Error: 610 + .saturating_add(Weight::from_ref_time(27_956).saturating_mul(m.into())) + // Standard Error: 595 + .saturating_add(Weight::from_ref_time(84_835).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(260).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(144).saturating_mul(p.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:1) - // Storage: Council Proposals (r:1 w:1) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 47_753 nanoseconds. - Weight::from_ref_time(46_507_829 as u64) - // Standard Error: 149 - .saturating_add(Weight::from_ref_time(2_159 as u64).saturating_mul(b as u64)) - // Standard Error: 1_581 - .saturating_add(Weight::from_ref_time(37_842 as u64).saturating_mul(m as u64)) - // Standard Error: 1_541 - .saturating_add(Weight::from_ref_time(173_395 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `962 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `9164 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` + // Minimum execution time: 36_515 nanoseconds. + Weight::from_parts(36_626_648, 9164) + // Standard Error: 98 + .saturating_add(Weight::from_ref_time(2_295).saturating_mul(b.into())) + // Standard Error: 1_036 + .saturating_add(Weight::from_ref_time(22_182).saturating_mul(m.into())) + // Standard Error: 1_010 + .saturating_add(Weight::from_ref_time(100_034).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(b.into())) + .saturating_add(Weight::from_proof_size(264).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(160).saturating_mul(p.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council Prime (r:1 w:0) - // Storage: Council Proposals (r:1 w:1) - // Storage: Council ProposalOf (r:0 w:1) + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:0) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:0 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 39_416 nanoseconds. - Weight::from_ref_time(39_610_161 as u64) - // Standard Error: 1_231 - .saturating_add(Weight::from_ref_time(32_991 as u64).saturating_mul(m as u64)) - // Standard Error: 1_200 - .saturating_add(Weight::from_ref_time(170_773 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `646 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `7095 + m * (325 ±0) + p * (180 ±0)` + // Minimum execution time: 28_858 nanoseconds. + Weight::from_parts(28_050_047, 7095) + // Standard Error: 614 + .saturating_add(Weight::from_ref_time(34_031).saturating_mul(m.into())) + // Standard Error: 599 + .saturating_add(Weight::from_ref_time(85_744).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(325).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(180).saturating_mul(p.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council Prime (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:1) - // Storage: Council Proposals (r:1 w:1) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:0) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 49_840 nanoseconds. - Weight::from_ref_time(48_542_914 as u64) - // Standard Error: 136 - .saturating_add(Weight::from_ref_time(2_650 as u64).saturating_mul(b as u64)) - // Standard Error: 1_442 - .saturating_add(Weight::from_ref_time(37_898 as u64).saturating_mul(m as u64)) - // Standard Error: 1_406 - .saturating_add(Weight::from_ref_time(182_176 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `982 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `10565 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` + // Minimum execution time: 38_608 nanoseconds. + Weight::from_parts(39_948_329, 10565) + // Standard Error: 84 + .saturating_add(Weight::from_ref_time(2_045).saturating_mul(b.into())) + // Standard Error: 895 + .saturating_add(Weight::from_ref_time(22_669).saturating_mul(m.into())) + // Standard Error: 872 + .saturating_add(Weight::from_ref_time(95_525).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(5).saturating_mul(b.into())) + .saturating_add(Weight::from_proof_size(330).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(200).saturating_mul(p.into())) } - // Storage: Council Proposals (r:1 w:1) - // Storage: Council Voting (r:0 w:1) - // Storage: Council ProposalOf (r:0 w:1) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:0 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:0 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - // Minimum execution time: 24_199 nanoseconds. - Weight::from_ref_time(26_869_176 as u64) - // Standard Error: 1_609 - .saturating_add(Weight::from_ref_time(163_341 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `391 + p * (32 ±0)` + // Estimated: `1668 + p * (96 ±0)` + // Minimum execution time: 14_785 nanoseconds. + Weight::from_parts(16_393_818, 1668) + // Standard Error: 612 + .saturating_add(Weight::from_ref_time(76_786).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(96).saturating_mul(p.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Council Members (r:1 w:1) - // Storage: Council Proposals (r:1 w:0) - // Storage: Council Prime (r:0 w:1) - // Storage: Council Voting (r:100 w:100) + /// Storage: Council Members (r:1 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:100 w:100) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Prime (r:0 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[0, 100]`. /// The range of component `n` is `[0, 100]`. /// The range of component `p` is `[0, 100]`. fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { - // Minimum execution time: 18_895 nanoseconds. - Weight::from_ref_time(19_254_000 as u64) - // Standard Error: 63_540 - .saturating_add(Weight::from_ref_time(5_061_801 as u64).saturating_mul(m as u64)) - // Standard Error: 63_540 - .saturating_add(Weight::from_ref_time(7_588_981 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + // Proof Size summary in bytes: + // Measured: `0 + m * (3233 ±0) + p * (3223 ±0)` + // Estimated: `16586 + m * (7809 ±24) + p * (10238 ±24)` + // Minimum execution time: 17_093 nanoseconds. + Weight::from_parts(17_284_000, 16586) + // Standard Error: 64_700 + .saturating_add(Weight::from_ref_time(5_143_145).saturating_mul(m.into())) + // Standard Error: 64_700 + .saturating_add(Weight::from_ref_time(7_480_941).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_proof_size(7809).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(10238).saturating_mul(p.into())) } - // Storage: Council Members (r:1 w:0) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn execute(b: u32, m: u32, ) -> Weight { - // Minimum execution time: 24_469 nanoseconds. - Weight::from_ref_time(23_961_134 as u64) - // Standard Error: 43 - .saturating_add(Weight::from_ref_time(1_677 as u64).saturating_mul(b as u64)) - // Standard Error: 450 - .saturating_add(Weight::from_ref_time(18_645 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `234 + m * (32 ±0)` + // Estimated: `730 + m * (32 ±0)` + // Minimum execution time: 15_972 nanoseconds. + Weight::from_parts(14_971_445, 730) + // Standard Error: 32 + .saturating_add(Weight::from_ref_time(1_775).saturating_mul(b.into())) + // Standard Error: 334 + .saturating_add(Weight::from_ref_time(17_052).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(Weight::from_proof_size(32).saturating_mul(m.into())) } - // Storage: Council Members (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:0) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:0) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[1, 100]`. fn propose_execute(b: u32, m: u32, ) -> Weight { - // Minimum execution time: 26_476 nanoseconds. - Weight::from_ref_time(25_829_298 as u64) - // Standard Error: 49 - .saturating_add(Weight::from_ref_time(1_741 as u64).saturating_mul(b as u64)) - // Standard Error: 515 - .saturating_add(Weight::from_ref_time(29_436 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) + // Proof Size summary in bytes: + // Measured: `234 + m * (32 ±0)` + // Estimated: `3440 + m * (64 ±0)` + // Minimum execution time: 17_950 nanoseconds. + Weight::from_parts(17_019_558, 3440) + // Standard Error: 41 + .saturating_add(Weight::from_ref_time(1_807).saturating_mul(b.into())) + // Standard Error: 432 + .saturating_add(Weight::from_ref_time(27_986).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(Weight::from_proof_size(64).saturating_mul(m.into())) } - // Storage: Council Members (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:1) - // Storage: Council Proposals (r:1 w:1) - // Storage: Council ProposalCount (r:1 w:1) - // Storage: Council Voting (r:0 w:1) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalCount (r:1 w:1) + /// Proof Skipped: Council ProposalCount (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:0 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[2, 100]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 33_585 nanoseconds. - Weight::from_ref_time(33_092_289 as u64) - // Standard Error: 173 - .saturating_add(Weight::from_ref_time(4_266 as u64).saturating_mul(b as u64)) - // Standard Error: 1_812 - .saturating_add(Weight::from_ref_time(29_262 as u64).saturating_mul(m as u64)) - // Standard Error: 1_789 - .saturating_add(Weight::from_ref_time(181_285 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `556 + m * (32 ±0) + p * (36 ±0)` + // Estimated: `6355 + m * (165 ±0) + p * (180 ±0)` + // Minimum execution time: 24_817 nanoseconds. + Weight::from_parts(24_778_955, 6355) + // Standard Error: 73 + .saturating_add(Weight::from_ref_time(2_355).saturating_mul(b.into())) + // Standard Error: 765 + .saturating_add(Weight::from_ref_time(20_518).saturating_mul(m.into())) + // Standard Error: 755 + .saturating_add(Weight::from_ref_time(85_670).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_proof_size(165).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(180).saturating_mul(p.into())) } - // Storage: Council Members (r:1 w:0) - // Storage: Council Voting (r:1 w:1) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[5, 100]`. fn vote(m: u32, ) -> Weight { - // Minimum execution time: 36_374 nanoseconds. - Weight::from_ref_time(38_950_243 as u64) - // Standard Error: 2_583 - .saturating_add(Weight::from_ref_time(65_345 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1006 + m * (64 ±0)` + // Estimated: `4980 + m * (128 ±0)` + // Minimum execution time: 19_790 nanoseconds. + Weight::from_parts(20_528_275, 4980) + // Standard Error: 651 + .saturating_add(Weight::from_ref_time(48_856).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(128).saturating_mul(m.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council Proposals (r:1 w:1) - // Storage: Council ProposalOf (r:0 w:1) + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:0 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 36_066 nanoseconds. - Weight::from_ref_time(38_439_655 as u64) - // Standard Error: 1_281 - .saturating_add(Weight::from_ref_time(17_045 as u64).saturating_mul(m as u64)) - // Standard Error: 1_249 - .saturating_add(Weight::from_ref_time(164_998 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `626 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `5893 + m * (260 ±0) + p * (144 ±0)` + // Minimum execution time: 25_564 nanoseconds. + Weight::from_parts(25_535_497, 5893) + // Standard Error: 610 + .saturating_add(Weight::from_ref_time(27_956).saturating_mul(m.into())) + // Standard Error: 595 + .saturating_add(Weight::from_ref_time(84_835).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(260).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(144).saturating_mul(p.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:1) - // Storage: Council Proposals (r:1 w:1) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 47_753 nanoseconds. - Weight::from_ref_time(46_507_829 as u64) - // Standard Error: 149 - .saturating_add(Weight::from_ref_time(2_159 as u64).saturating_mul(b as u64)) - // Standard Error: 1_581 - .saturating_add(Weight::from_ref_time(37_842 as u64).saturating_mul(m as u64)) - // Standard Error: 1_541 - .saturating_add(Weight::from_ref_time(173_395 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `962 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `9164 + b * (4 ±0) + m * (264 ±0) + p * (160 ±0)` + // Minimum execution time: 36_515 nanoseconds. + Weight::from_parts(36_626_648, 9164) + // Standard Error: 98 + .saturating_add(Weight::from_ref_time(2_295).saturating_mul(b.into())) + // Standard Error: 1_036 + .saturating_add(Weight::from_ref_time(22_182).saturating_mul(m.into())) + // Standard Error: 1_010 + .saturating_add(Weight::from_ref_time(100_034).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(4).saturating_mul(b.into())) + .saturating_add(Weight::from_proof_size(264).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(160).saturating_mul(p.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council Prime (r:1 w:0) - // Storage: Council Proposals (r:1 w:1) - // Storage: Council ProposalOf (r:0 w:1) + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:0) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:0 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(m: u32, p: u32, ) -> Weight { - // Minimum execution time: 39_416 nanoseconds. - Weight::from_ref_time(39_610_161 as u64) - // Standard Error: 1_231 - .saturating_add(Weight::from_ref_time(32_991 as u64).saturating_mul(m as u64)) - // Standard Error: 1_200 - .saturating_add(Weight::from_ref_time(170_773 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `646 + m * (64 ±0) + p * (36 ±0)` + // Estimated: `7095 + m * (325 ±0) + p * (180 ±0)` + // Minimum execution time: 28_858 nanoseconds. + Weight::from_parts(28_050_047, 7095) + // Standard Error: 614 + .saturating_add(Weight::from_ref_time(34_031).saturating_mul(m.into())) + // Standard Error: 599 + .saturating_add(Weight::from_ref_time(85_744).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(325).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(180).saturating_mul(p.into())) } - // Storage: Council Voting (r:1 w:1) - // Storage: Council Members (r:1 w:0) - // Storage: Council Prime (r:1 w:0) - // Storage: Council ProposalOf (r:1 w:1) - // Storage: Council Proposals (r:1 w:1) - /// The range of component `b` is `[1, 1024]`. + /// Storage: Council Voting (r:1 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Members (r:1 w:0) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:0) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:1 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// The range of component `b` is `[2, 1024]`. /// The range of component `m` is `[4, 100]`. /// The range of component `p` is `[1, 100]`. fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - // Minimum execution time: 49_840 nanoseconds. - Weight::from_ref_time(48_542_914 as u64) - // Standard Error: 136 - .saturating_add(Weight::from_ref_time(2_650 as u64).saturating_mul(b as u64)) - // Standard Error: 1_442 - .saturating_add(Weight::from_ref_time(37_898 as u64).saturating_mul(m as u64)) - // Standard Error: 1_406 - .saturating_add(Weight::from_ref_time(182_176 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `982 + b * (1 ±0) + m * (64 ±0) + p * (40 ±0)` + // Estimated: `10565 + b * (5 ±0) + m * (330 ±0) + p * (200 ±0)` + // Minimum execution time: 38_608 nanoseconds. + Weight::from_parts(39_948_329, 10565) + // Standard Error: 84 + .saturating_add(Weight::from_ref_time(2_045).saturating_mul(b.into())) + // Standard Error: 895 + .saturating_add(Weight::from_ref_time(22_669).saturating_mul(m.into())) + // Standard Error: 872 + .saturating_add(Weight::from_ref_time(95_525).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(5).saturating_mul(b.into())) + .saturating_add(Weight::from_proof_size(330).saturating_mul(m.into())) + .saturating_add(Weight::from_proof_size(200).saturating_mul(p.into())) } - // Storage: Council Proposals (r:1 w:1) - // Storage: Council Voting (r:0 w:1) - // Storage: Council ProposalOf (r:0 w:1) + /// Storage: Council Proposals (r:1 w:1) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Voting (r:0 w:1) + /// Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council ProposalOf (r:0 w:1) + /// Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) /// The range of component `p` is `[1, 100]`. fn disapprove_proposal(p: u32, ) -> Weight { - // Minimum execution time: 24_199 nanoseconds. - Weight::from_ref_time(26_869_176 as u64) - // Standard Error: 1_609 - .saturating_add(Weight::from_ref_time(163_341 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `391 + p * (32 ±0)` + // Estimated: `1668 + p * (96 ±0)` + // Minimum execution time: 14_785 nanoseconds. + Weight::from_parts(16_393_818, 1668) + // Standard Error: 612 + .saturating_add(Weight::from_ref_time(76_786).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(96).saturating_mul(p.into())) } } diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index a750a6b172..2bd807dfb7 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -205,11 +205,13 @@ benchmarks! { } // The base weight consumed on processing contracts deletion queue. + #[pov_mode = Ignored] on_process_deletion_queue_batch {}: { Storage::::process_deletion_queue_batch(Weight::MAX) } #[skip_meta] + #[pov_mode = Ignored] on_initialize_per_trie_key { let k in 0..1024; let instance = Contract::::with_storage(WasmModule::dummy(), k, T::Schedule::get().limits.payload_len)?; @@ -218,6 +220,7 @@ benchmarks! { Storage::::process_deletion_queue_batch(Weight::MAX) } + #[pov_mode = Ignored] on_initialize_per_queue_item { let q in 0..1024.min(T::DeletionQueueDepth::get()); for i in 0 .. q { @@ -232,6 +235,7 @@ benchmarks! { // This benchmarks the additional weight that is charged when a contract is executed the // first time after a new schedule was deployed: For every new schedule a contract needs // to re-run the instrumentation once. + #[pov_mode = Ignored] reinstrument { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let WasmModule { code, hash, .. } = WasmModule::::sized(c, Location::Call); @@ -248,6 +252,7 @@ benchmarks! { // is responsible. This is achieved by generating all code to the `deploy` function // which is in the wasm module but not executed on `call`. // The results are supposed to be used as `call_with_code_kb(c) - call_with_code_kb(0)`. + #[pov_mode = Ignored] call_with_code_per_byte { let c in 0 .. T::MaxCodeLen::get(); let instance = Contract::::with_caller( @@ -273,6 +278,7 @@ benchmarks! { // // We cannot let `c` grow to the maximum code size because the code is not allowed // to be larger than the maximum size **after instrumentation**. + #[pov_mode = Ignored] instantiate_with_code { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let i in 0 .. code::max_pages::() * 64 * 1024; @@ -304,6 +310,7 @@ benchmarks! { // Instantiate uses a dummy contract constructor to measure the overhead of the instantiate. // `i`: Size of the input in kilobytes. // `s`: Size of the salt in kilobytes. + #[pov_mode = Ignored] instantiate { let i in 0 .. code::max_pages::() * 64 * 1024; let s in 0 .. code::max_pages::() * 64 * 1024; @@ -335,6 +342,7 @@ benchmarks! { // part of `seal_input`. The costs for invoking a contract of a specific size are not part // of this benchmark because we cannot know the size of the contract when issuing a call // transaction. See `invoke_per_code_kb` for this. + #[pov_mode = Ignored] call { let data = vec![42u8; 1024]; let instance = Contract::::with_caller( @@ -367,6 +375,7 @@ benchmarks! { // // We cannot let `c` grow to the maximum code size because the code is not allowed // to be larger than the maximum size **after instrumentation**. + #[pov_mode = Ignored] upload_code { let c in 0 .. Perbill::from_percent(49).mul_ceil(T::MaxCodeLen::get()); let caller = whitelisted_caller(); @@ -383,6 +392,7 @@ benchmarks! { // Removing code does not depend on the size of the contract because all the information // needed to verify the removal claim (refcount, owner) is stored in a separate storage // item (`OwnerInfoOf`). + #[pov_mode = Ignored] remove_code { let caller = whitelisted_caller(); T::Currency::make_free_balance_be(&caller, caller_funding::()); @@ -399,6 +409,7 @@ benchmarks! { assert!(>::code_removed(&hash)); } + #[pov_mode = Ignored] set_code { let instance = >::with_caller( whitelisted_caller(), WasmModule::dummy(), vec![], @@ -413,6 +424,7 @@ benchmarks! { assert_eq!(instance.info()?.code_hash, hash); } + #[pov_mode = Ignored] seal_caller { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -421,6 +433,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_is_contract { let r in 0 .. API_BENCHMARK_BATCHES; let accounts = (0 .. r * API_BENCHMARK_BATCH_SIZE) @@ -458,6 +471,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_code_hash { let r in 0 .. API_BENCHMARK_BATCHES; let accounts = (0 .. r * API_BENCHMARK_BATCH_SIZE) @@ -503,6 +517,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_own_code_hash { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -511,6 +526,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_caller_is_origin { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { @@ -531,6 +547,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_address { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -539,6 +556,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_gas_left { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -547,6 +565,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_balance { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -555,6 +574,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_value_transferred { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -563,6 +583,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_minimum_balance { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -571,6 +592,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_block_number { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -579,6 +601,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_now { let r in 0 .. API_BENCHMARK_BATCHES; let instance = Contract::::new(WasmModule::getter( @@ -587,6 +610,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_weight_to_fee { let r in 0 .. API_BENCHMARK_BATCHES; let pages = code::max_pages::(); @@ -614,6 +638,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_gas { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { @@ -634,6 +659,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_input { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { @@ -661,6 +687,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_input_per_kb { let n in 0 .. code::max_pages::() * 64; let pages = code::max_pages::(); @@ -694,6 +721,7 @@ benchmarks! { // We cannot call `seal_return` multiple times. Therefore our weight determination is not // as precise as with other APIs. Because this function can only be called once per // contract it cannot be used as an attack vector. + #[pov_mode = Ignored] seal_return { let r in 0 .. 1; let code = WasmModule::::from(ModuleDefinition { @@ -716,6 +744,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_return_per_kb { let n in 0 .. code::max_pages::() * 64; let code = WasmModule::::from(ModuleDefinition { @@ -740,6 +769,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // The same argument as for `seal_return` is true here. + #[pov_mode = Ignored] seal_terminate { let r in 0 .. 1; let beneficiary = account::("beneficiary", 0, 0); @@ -782,6 +812,7 @@ benchmarks! { // We benchmark only for the maximum subject length. We assume that this is some lowish // number (< 1 KB). Therefore we are not overcharging too much in case a smaller subject is // used. + #[pov_mode = Ignored] seal_random { let r in 0 .. API_BENCHMARK_BATCHES; let pages = code::max_pages::(); @@ -816,6 +847,7 @@ benchmarks! { // Overhead of calling the function without any topic. // We benchmark for the worst case (largest event). + #[pov_mode = Ignored] seal_deposit_event { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { @@ -842,6 +874,7 @@ benchmarks! { // Benchmark the overhead that topics generate. // `t`: Number of topics // `n`: Size of event payload in kb + #[pov_mode = Ignored] seal_deposit_event_per_topic_and_kb { let t in 0 .. T::Schedule::get().limits.event_topics; let n in 0 .. T::Schedule::get().limits.payload_len / 1024; @@ -880,6 +913,7 @@ benchmarks! { // The size of the supplied message does not influence the weight because as it is never // processed during on-chain execution: It is only ever read during debugging which happens // when the contract is called as RPC where weights do not matter. + #[pov_mode = Ignored] seal_debug_message { let r in 0 .. API_BENCHMARK_BATCHES; let max_bytes = code::max_pages::() * 64 * 1024; @@ -910,6 +944,7 @@ benchmarks! { // because re-writing at an existing key is always more expensive than writing // it at a virgin key. #[skip_meta] + #[pov_mode = Ignored] seal_set_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); @@ -958,6 +993,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_set_storage_per_new_kb { let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb let max_key_len = T::MaxStorageKeyLen::get(); @@ -1006,6 +1042,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_set_storage_per_old_kb { let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb let max_key_len = T::MaxStorageKeyLen::get(); @@ -1058,6 +1095,7 @@ benchmarks! { // deleting a non existing key. We generate keys of a maximum length, and have to // reduce batch size in order to make resulting contract code size less than MaxCodeLen. #[skip_meta] + #[pov_mode = Ignored] seal_clear_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); @@ -1105,6 +1143,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_clear_storage_per_kb { let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb let max_key_len = T::MaxStorageKeyLen::get(); @@ -1152,6 +1191,7 @@ benchmarks! { // We make sure that all storage accesses are to unique keys. #[skip_meta] + #[pov_mode = Ignored] seal_get_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); @@ -1206,6 +1246,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_get_storage_per_kb { let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb let max_key_len = T::MaxStorageKeyLen::get(); @@ -1261,6 +1302,7 @@ benchmarks! { // We make sure that all storage accesses are to unique keys. #[skip_meta] + #[pov_mode = Ignored] seal_contains_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); @@ -1309,6 +1351,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_contains_storage_per_kb { let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb let max_key_len = T::MaxStorageKeyLen::get(); @@ -1356,6 +1399,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_take_storage { let r in 0 .. API_BENCHMARK_BATCHES/2; let max_key_len = T::MaxStorageKeyLen::get(); @@ -1410,6 +1454,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) #[skip_meta] + #[pov_mode = Ignored] seal_take_storage_per_kb { let n in 0 .. T::Schedule::get().limits.payload_len / 2048; // half of the max payload_len in kb let max_key_len = T::MaxStorageKeyLen::get(); @@ -1464,6 +1509,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // We transfer to unique accounts. + #[pov_mode = Ignored] seal_transfer { let r in 0 .. API_BENCHMARK_BATCHES; let accounts = (0..r * API_BENCHMARK_BATCH_SIZE) @@ -1517,6 +1563,7 @@ benchmarks! { } // We call unique accounts. + #[pov_mode = Ignored] seal_call { let r in 0 .. API_BENCHMARK_BATCHES; let dummy_code = WasmModule::::dummy_with_bytes(0); @@ -1575,6 +1622,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_delegate_call { let r in 0 .. API_BENCHMARK_BATCHES; let hashes = (0..r * API_BENCHMARK_BATCH_SIZE) @@ -1627,6 +1675,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller); }: call(origin, callee, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_call_per_transfer_clone_kb { let t in 0 .. 1; let c in 0 .. code::max_pages::() * 64; @@ -1685,6 +1734,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, bytes) // We assume that every instantiate sends at least the minimum balance. + #[pov_mode = Ignored] seal_instantiate { let r in 0 .. API_BENCHMARK_BATCHES; let hashes = (0..r * API_BENCHMARK_BATCH_SIZE) @@ -1798,6 +1848,7 @@ benchmarks! { } } + #[pov_mode = Ignored] seal_instantiate_per_transfer_input_salt_kb { let t in 0 .. 1; let i in 0 .. (code::max_pages::() - 1) * 64; @@ -1892,6 +1943,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // Only the overhead of calling the function itself with minimal arguments. + #[pov_mode = Ignored] seal_hash_sha2_256 { let r in 0 .. 1; let instance = Contract::::new(WasmModule::hasher( @@ -1901,6 +1953,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // `n`: Input to hash in kilobytes + #[pov_mode = Ignored] seal_hash_sha2_256_per_kb { let n in 0 .. code::max_pages::() * 64; let instance = Contract::::new(WasmModule::hasher( @@ -1910,6 +1963,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // Only the overhead of calling the function itself with minimal arguments. + #[pov_mode = Ignored] seal_hash_keccak_256 { let r in 0 .. 1; let instance = Contract::::new(WasmModule::hasher( @@ -1919,6 +1973,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // `n`: Input to hash in kilobytes + #[pov_mode = Ignored] seal_hash_keccak_256_per_kb { let n in 0 .. code::max_pages::() * 64; let instance = Contract::::new(WasmModule::hasher( @@ -1928,6 +1983,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // Only the overhead of calling the function itself with minimal arguments. + #[pov_mode = Ignored] seal_hash_blake2_256 { let r in 0 .. 1; let instance = Contract::::new(WasmModule::hasher( @@ -1937,6 +1993,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // `n`: Input to hash in kilobytes + #[pov_mode = Ignored] seal_hash_blake2_256_per_kb { let n in 0 .. code::max_pages::() * 64; let instance = Contract::::new(WasmModule::hasher( @@ -1946,6 +2003,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // Only the overhead of calling the function itself with minimal arguments. + #[pov_mode = Ignored] seal_hash_blake2_128 { let r in 0 .. 1; let instance = Contract::::new(WasmModule::hasher( @@ -1955,6 +2013,7 @@ benchmarks! { }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) // `n`: Input to hash in kilobytes + #[pov_mode = Ignored] seal_hash_blake2_128_per_kb { let n in 0 .. code::max_pages::() * 64; let instance = Contract::::new(WasmModule::hasher( @@ -1965,6 +2024,7 @@ benchmarks! { // Only calling the function itself with valid arguments. // It generates different private keys and signatures for the message "Hello world". + #[pov_mode = Ignored] seal_ecdsa_recover { let r in 0 .. 1; @@ -2013,6 +2073,7 @@ benchmarks! { // Only calling the function itself for the list of // generated different ECDSA keys. + #[pov_mode = Ignored] seal_ecdsa_to_eth_address { let r in 0 .. 1; let key_type = sp_core::crypto::KeyTypeId(*b"code"); @@ -2048,6 +2109,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_set_code_hash { let r in 0 .. API_BENCHMARK_BATCHES; let code_hashes = (0..r * API_BENCHMARK_BATCH_SIZE) @@ -2088,6 +2150,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_reentrance_count { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { @@ -2108,6 +2171,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_account_reentrance_count { let r in 0 .. API_BENCHMARK_BATCHES; let dummy_code = WasmModule::::dummy_with_bytes(0); @@ -2141,6 +2205,7 @@ benchmarks! { let origin = RawOrigin::Signed(instance.caller.clone()); }: call(origin, instance.addr, 0u32.into(), Weight::MAX, None, vec![]) + #[pov_mode = Ignored] seal_instantiation_nonce { let r in 0 .. API_BENCHMARK_BATCHES; let code = WasmModule::::from(ModuleDefinition { @@ -2171,6 +2236,7 @@ benchmarks! { // The weight that would result from the respective benchmark we call: `w_bench`. // // w_i{32,64}const = w_drop = w_bench / 2 + #[pov_mode = Ignored] instr_i64const { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2185,6 +2251,7 @@ benchmarks! { } // w_i{32,64}load = w_bench - 2 * w_param + #[pov_mode = Ignored] instr_i64load { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2201,6 +2268,7 @@ benchmarks! { } // w_i{32,64}store{...} = w_bench - 2 * w_param + #[pov_mode = Ignored] instr_i64store { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2217,6 +2285,7 @@ benchmarks! { } // w_select = w_bench - 4 * w_param + #[pov_mode = Ignored] instr_select { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2234,6 +2303,7 @@ benchmarks! { } // w_if = w_bench - 3 * w_param + #[pov_mode = Ignored] instr_if { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2254,6 +2324,7 @@ benchmarks! { // w_br = w_bench - 2 * w_param // Block instructions are not counted. + #[pov_mode = Ignored] instr_br { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2280,6 +2351,7 @@ benchmarks! { // w_br_if = w_bench - 3 * w_param // Block instructions are not counted. + #[pov_mode = Ignored] instr_br_if { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2307,6 +2379,7 @@ benchmarks! { // w_br_table = w_bench - 3 * w_param // Block instructions are not counted. + #[pov_mode = Ignored] instr_br_table { let r in 0 .. INSTR_BENCHMARK_BATCHES; let table = Box::new(BrTableData { @@ -2337,6 +2410,7 @@ benchmarks! { } // w_br_table_per_entry = w_bench + #[pov_mode = Ignored] instr_br_table_per_entry { let e in 1 .. T::Schedule::get().limits.br_table_size; let entry: Vec = [0, 1].iter() @@ -2371,6 +2445,7 @@ benchmarks! { } // w_call = w_bench - 2 * w_param + #[pov_mode = Ignored] instr_call { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2391,6 +2466,7 @@ benchmarks! { } // w_call_indrect = w_bench - 3 * w_param + #[pov_mode = Ignored] instr_call_indirect { let r in 0 .. INSTR_BENCHMARK_BATCHES; let num_elements = T::Schedule::get().limits.table_size; @@ -2421,6 +2497,7 @@ benchmarks! { // Calling a function indirectly causes it to go through a thunk function whose runtime // linearly depend on the amount of parameters to this function. // Please note that this is not necessary with a direct call. + #[pov_mode = Ignored] instr_call_indirect_per_param { let p in 0 .. T::Schedule::get().limits.parameters; let num_elements = T::Schedule::get().limits.table_size; @@ -2450,6 +2527,7 @@ benchmarks! { } // w_per_local = w_bench + #[pov_mode = Ignored] instr_call_per_local { let l in 0 .. T::Schedule::get().limits.locals; let mut aux_body = body::plain(vec![ @@ -2468,6 +2546,7 @@ benchmarks! { } // w_local_get = w_bench - 1 * w_param + #[pov_mode = Ignored] instr_local_get { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_locals = T::Schedule::get().limits.locals; @@ -2485,6 +2564,7 @@ benchmarks! { } // w_local_set = w_bench - 1 * w_param + #[pov_mode = Ignored] instr_local_set { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_locals = T::Schedule::get().limits.locals; @@ -2502,6 +2582,7 @@ benchmarks! { } // w_local_tee = w_bench - 2 * w_param + #[pov_mode = Ignored] instr_local_tee { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_locals = T::Schedule::get().limits.locals; @@ -2520,6 +2601,7 @@ benchmarks! { } // w_global_get = w_bench - 1 * w_param + #[pov_mode = Ignored] instr_global_get { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_globals = T::Schedule::get().limits.globals; @@ -2536,6 +2618,7 @@ benchmarks! { } // w_global_set = w_bench - 1 * w_param + #[pov_mode = Ignored] instr_global_set { let r in 0 .. INSTR_BENCHMARK_BATCHES; let max_globals = T::Schedule::get().limits.globals; @@ -2552,6 +2635,7 @@ benchmarks! { } // w_memory_get = w_bench - 1 * w_param + #[pov_mode = Ignored] instr_memory_current { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2571,6 +2655,7 @@ benchmarks! { // Therefore the repeat count is limited by the maximum memory any contract can have. // Using a contract with more memory will skew the benchmark because the runtime of grow // depends on how much memory is already allocated. + #[pov_mode = Ignored] instr_memory_grow { let r in 0 .. 1; let max_pages = ImportedMemory::max::().max_pages; @@ -2593,6 +2678,7 @@ benchmarks! { // Unary numeric instructions. // All use w = w_bench - 2 * w_param. + #[pov_mode = Ignored] instr_i64clz { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( @@ -2603,6 +2689,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64ctz { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( @@ -2613,6 +2700,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64popcnt { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( @@ -2623,6 +2711,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64eqz { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( @@ -2633,6 +2722,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64extendsi32 { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2647,6 +2737,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64extendui32 { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::from(ModuleDefinition { @@ -2661,6 +2752,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i32wrapi64 { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::unary_instr( @@ -2674,6 +2766,7 @@ benchmarks! { // Binary numeric instructions. // All use w = w_bench - 3 * w_param. + #[pov_mode = Ignored] instr_i64eq { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2684,6 +2777,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64ne { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2694,6 +2788,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64lts { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2704,6 +2799,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64ltu { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2714,6 +2810,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64gts { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2724,6 +2821,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64gtu { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2734,6 +2832,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64les { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2744,6 +2843,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64leu { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2754,6 +2854,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64ges { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2764,6 +2865,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64geu { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2774,6 +2876,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64add { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2784,6 +2887,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64sub { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2794,6 +2898,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64mul { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2804,6 +2909,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64divs { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2814,6 +2920,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64divu { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2824,6 +2931,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64rems { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2834,6 +2942,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64remu { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2844,6 +2953,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64and { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2854,6 +2964,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64or { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2864,6 +2975,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64xor { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2874,6 +2986,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64shl { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2884,6 +2997,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64shrs { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2894,6 +3008,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64shru { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2904,6 +3019,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64rotl { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2914,6 +3030,7 @@ benchmarks! { sbox.invoke(); } + #[pov_mode = Ignored] instr_i64rotr { let r in 0 .. INSTR_BENCHMARK_BATCHES; let mut sbox = Sandbox::from(&WasmModule::::binary_instr( @@ -2931,6 +3048,7 @@ benchmarks! { // --features runtime-benchmarks -- benchmark pallet --extra --dev --execution=native \ // -p pallet_contracts -e print_schedule --no-median-slopes --no-min-squares #[extra] + #[pov_mode = Ignored] print_schedule { #[cfg(feature = "std")] { @@ -2956,6 +3074,7 @@ benchmarks! { // `g` is used to enable gas instrumentation to compare the performance impact of // that instrumentation at runtime. #[extra] + #[pov_mode = Ignored] ink_erc20_transfer { let g in 0 .. 1; let gas_metering = g != 0; @@ -2994,6 +3113,7 @@ benchmarks! { // `g` is used to enable gas instrumentation to compare the performance impact of // that instrumentation at runtime. #[extra] + #[pov_mode = Ignored] solang_erc20_transfer { let g in 0 .. 1; let gas_metering = g != 0; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index f97b4b790c..c067b26447 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -81,7 +81,7 @@ //! WebAssembly based smart contracts in the Rust programming language. #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] +#![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "1024")] #[macro_use] mod gas; diff --git a/frame/contracts/src/weights.rs b/frame/contracts/src/weights.rs index 7ae1a9c594..d9ec1b10b2 100644 --- a/frame/contracts/src/weights.rs +++ b/frame/contracts/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_contracts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_contracts // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_contracts -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/contracts/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -170,2554 +170,3810 @@ pub trait WeightInfo { /// Weights for pallet_contracts using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Contracts DeletionQueue (r:1 w:0) + /// Storage: Contracts DeletionQueue (r:1 w:0) + /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Ignored) fn on_process_deletion_queue_batch() -> Weight { - // Minimum execution time: 3_326 nanoseconds. - Weight::from_ref_time(3_433_000) - .saturating_add(T::DbWeight::get().reads(1)) - } - // Storage: Skipped Metadata (r:0 w:0) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `0` + // Minimum execution time: 2_305 nanoseconds. + Weight::from_ref_time(2_560_000) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - // Minimum execution time: 15_703 nanoseconds. - Weight::from_ref_time(15_288_927) - // Standard Error: 951 - .saturating_add(Weight::from_ref_time(940_816).saturating_mul(k.into())) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `481 + k * (69 ±0)` + // Estimated: `0` + // Minimum execution time: 9_311 nanoseconds. + Weight::from_ref_time(5_419_288) + // Standard Error: 562 + .saturating_add(Weight::from_ref_time(911_962).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) } - // Storage: Contracts DeletionQueue (r:1 w:0) + /// Storage: Contracts DeletionQueue (r:1 w:1) + /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Ignored) /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - // Minimum execution time: 3_548 nanoseconds. - Weight::from_ref_time(15_764_121) - // Standard Error: 3_339 - .saturating_add(Weight::from_ref_time(1_214_890).saturating_mul(q.into())) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Contracts PristineCode (r:1 w:0) - // Storage: Contracts CodeStorage (r:0 w:1) - /// The range of component `c` is `[0, 64226]`. + // Proof Size summary in bytes: + // Measured: `281 + q * (33 ±0)` + // Estimated: `0` + // Minimum execution time: 2_288 nanoseconds. + Weight::from_ref_time(9_442_437) + // Standard Error: 2_720 + .saturating_add(Weight::from_ref_time(1_076_950).saturating_mul(q.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Contracts PristineCode (r:1 w:0) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) + /// Storage: Contracts CodeStorage (r:0 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { - // Minimum execution time: 29_801 nanoseconds. - Weight::from_ref_time(27_932_706) - // Standard Error: 49 - .saturating_add(Weight::from_ref_time(50_532).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: System EventTopics (r:2 w:2) - /// The range of component `c` is `[0, 131072]`. + // Proof Size summary in bytes: + // Measured: `270 + c * (1 ±0)` + // Estimated: `0` + // Minimum execution time: 27_539 nanoseconds. + Weight::from_ref_time(23_554_889) + // Standard Error: 56 + .saturating_add(Weight::from_ref_time(46_766).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - // Minimum execution time: 307_894 nanoseconds. - Weight::from_ref_time(322_346_319) - // Standard Error: 25 - .saturating_add(Weight::from_ref_time(30_678).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Contracts CodeStorage (r:1 w:1) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: System EventTopics (r:3 w:3) - // Storage: Contracts PristineCode (r:0 w:1) - // Storage: Contracts OwnerInfoOf (r:0 w:1) - /// The range of component `c` is `[0, 64226]`. + // Proof Size summary in bytes: + // Measured: `771` + // Estimated: `0` + // Minimum execution time: 297_710 nanoseconds. + Weight::from_ref_time(307_327_529) + // Standard Error: 18 + .saturating_add(Weight::from_ref_time(29_849).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Contracts CodeStorage (r:1 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: System EventTopics (r:3 w:3) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// Storage: Contracts PristineCode (r:0 w:1) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:0 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// The range of component `c` is `[0, 61717]`. /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 3_610_424 nanoseconds. - Weight::from_ref_time(583_426_386) - // Standard Error: 277 - .saturating_add(Weight::from_ref_time(90_224).saturating_mul(c.into())) + // Proof Size summary in bytes: + // Measured: `257` + // Estimated: `0` + // Minimum execution time: 3_586_223 nanoseconds. + Weight::from_ref_time(561_614_281) + // Standard Error: 274 + .saturating_add(Weight::from_ref_time(87_557).saturating_mul(c.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_325).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_307).saturating_mul(i.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_727).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(9)) - } - // Storage: Contracts CodeStorage (r:1 w:1) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(Weight::from_ref_time(1_721).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(9_u64)) + } + /// Storage: Contracts CodeStorage (r:1 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { - // Minimum execution time: 1_892_996 nanoseconds. - Weight::from_ref_time(202_958_196) + // Proof Size summary in bytes: + // Measured: `533` + // Estimated: `0` + // Minimum execution time: 1_885_437 nanoseconds. + Weight::from_ref_time(199_943_867) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_627).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_611).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_755).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(7)) - } - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(Weight::from_ref_time(1_737).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + } + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) fn call() -> Weight { - // Minimum execution time: 157_347 nanoseconds. - Weight::from_ref_time(159_084_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Contracts CodeStorage (r:1 w:1) - // Storage: System EventTopics (r:1 w:1) - // Storage: Contracts PristineCode (r:0 w:1) - // Storage: Contracts OwnerInfoOf (r:0 w:1) - /// The range of component `c` is `[0, 64226]`. + // Proof Size summary in bytes: + // Measured: `823` + // Estimated: `0` + // Minimum execution time: 150_604 nanoseconds. + Weight::from_ref_time(151_777_000) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Contracts CodeStorage (r:1 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: System EventTopics (r:1 w:1) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// Storage: Contracts PristineCode (r:0 w:1) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:0 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// The range of component `c` is `[0, 61717]`. fn upload_code(c: u32, ) -> Weight { - // Minimum execution time: 299_987 nanoseconds. - Weight::from_ref_time(305_274_879) - // Standard Error: 72 - .saturating_add(Weight::from_ref_time(91_916).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Storage: System EventTopics (r:1 w:1) - // Storage: Contracts CodeStorage (r:0 w:1) - // Storage: Contracts PristineCode (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `0` + // Minimum execution time: 295_505 nanoseconds. + Weight::from_ref_time(305_609_098) + // Standard Error: 58 + .saturating_add(Weight::from_ref_time(88_676).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:1 w:1) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// Storage: Contracts CodeStorage (r:0 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Contracts PristineCode (r:0 w:1) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) fn remove_code() -> Weight { - // Minimum execution time: 40_795 nanoseconds. - Weight::from_ref_time(41_297_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:2 w:2) - // Storage: System EventTopics (r:3 w:3) + // Proof Size summary in bytes: + // Measured: `287` + // Estimated: `0` + // Minimum execution time: 25_949 nanoseconds. + Weight::from_ref_time(26_316_000) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:2 w:2) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:3 w:3) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) fn set_code() -> Weight { - // Minimum execution time: 41_957 nanoseconds. - Weight::from_ref_time(42_536_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(6)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `634` + // Estimated: `0` + // Minimum execution time: 29_005 nanoseconds. + Weight::from_ref_time(29_370_000) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - // Minimum execution time: 293_544 nanoseconds. - Weight::from_ref_time(298_981_222) - // Standard Error: 39_139 - .saturating_add(Weight::from_ref_time(17_278_436).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `845 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 281_880 nanoseconds. + Weight::from_ref_time(289_637_700) + // Standard Error: 22_662 + .saturating_add(Weight::from_ref_time(16_866_274).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - // Minimum execution time: 293_500 nanoseconds. - Weight::from_ref_time(237_825_284) - // Standard Error: 450_234 - .saturating_add(Weight::from_ref_time(198_995_806).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `882 + r * (19218 ±0)` + // Estimated: `0` + // Minimum execution time: 285_590 nanoseconds. + Weight::from_ref_time(231_277_523) + // Standard Error: 425_084 + .saturating_add(Weight::from_ref_time(192_985_377).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 295_851 nanoseconds. - Weight::from_ref_time(258_113_447) - // Standard Error: 408_747 - .saturating_add(Weight::from_ref_time(237_490_216).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `889 + r * (19539 ±0)` + // Estimated: `0` + // Minimum execution time: 282_966 nanoseconds. + Weight::from_ref_time(236_127_328) + // Standard Error: 405_193 + .saturating_add(Weight::from_ref_time(235_541_377).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 294_614 nanoseconds. - Weight::from_ref_time(301_528_998) - // Standard Error: 40_613 - .saturating_add(Weight::from_ref_time(20_815_088).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `852 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 286_021 nanoseconds. + Weight::from_ref_time(290_200_599) + // Standard Error: 19_224 + .saturating_add(Weight::from_ref_time(20_692_099).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - // Minimum execution time: 293_088 nanoseconds. - Weight::from_ref_time(299_120_595) - // Standard Error: 23_277 - .saturating_add(Weight::from_ref_time(11_130_334).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `842 + r * (240 ±0)` + // Estimated: `0` + // Minimum execution time: 284_175 nanoseconds. + Weight::from_ref_time(286_665_694) + // Standard Error: 14_104 + .saturating_add(Weight::from_ref_time(11_196_944).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - // Minimum execution time: 295_110 nanoseconds. - Weight::from_ref_time(305_295_787) - // Standard Error: 48_521 - .saturating_add(Weight::from_ref_time(16_610_806).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `846 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_315 nanoseconds. + Weight::from_ref_time(289_734_189) + // Standard Error: 15_980 + .saturating_add(Weight::from_ref_time(16_940_657).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - // Minimum execution time: 293_414 nanoseconds. - Weight::from_ref_time(299_960_283) - // Standard Error: 32_003 - .saturating_add(Weight::from_ref_time(16_652_433).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `847 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_708 nanoseconds. + Weight::from_ref_time(289_872_393) + // Standard Error: 16_551 + .saturating_add(Weight::from_ref_time(16_672_944).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:2 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - // Minimum execution time: 292_429 nanoseconds. - Weight::from_ref_time(301_025_128) - // Standard Error: 92_155 - .saturating_add(Weight::from_ref_time(92_731_719).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1017 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_698 nanoseconds. + Weight::from_ref_time(295_636_093) + // Standard Error: 97_582 + .saturating_add(Weight::from_ref_time(92_891_252).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - // Minimum execution time: 293_516 nanoseconds. - Weight::from_ref_time(300_071_428) - // Standard Error: 25_871 - .saturating_add(Weight::from_ref_time(16_599_369).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `856 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 282_057 nanoseconds. + Weight::from_ref_time(289_304_621) + // Standard Error: 17_818 + .saturating_add(Weight::from_ref_time(16_725_632).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - // Minimum execution time: 293_666 nanoseconds. - Weight::from_ref_time(299_803_599) - // Standard Error: 24_508 - .saturating_add(Weight::from_ref_time(16_500_973).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `854 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 282_478 nanoseconds. + Weight::from_ref_time(289_682_366) + // Standard Error: 20_379 + .saturating_add(Weight::from_ref_time(16_517_079).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - // Minimum execution time: 289_193 nanoseconds. - Weight::from_ref_time(297_946_784) - // Standard Error: 43_719 - .saturating_add(Weight::from_ref_time(16_442_254).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `851 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 283_826 nanoseconds. + Weight::from_ref_time(289_935_300) + // Standard Error: 15_180 + .saturating_add(Weight::from_ref_time(16_268_515).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - // Minimum execution time: 288_897 nanoseconds. - Weight::from_ref_time(298_856_658) - // Standard Error: 31_003 - .saturating_add(Weight::from_ref_time(16_490_508).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `842 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_455 nanoseconds. + Weight::from_ref_time(289_682_526) + // Standard Error: 18_667 + .saturating_add(Weight::from_ref_time(16_502_025).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - // Minimum execution time: 289_850 nanoseconds. - Weight::from_ref_time(302_898_449) - // Standard Error: 92_822 - .saturating_add(Weight::from_ref_time(86_376_874).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `919 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 286_106 nanoseconds. + Weight::from_ref_time(294_493_680) + // Standard Error: 76_469 + .saturating_add(Weight::from_ref_time(87_055_837).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - // Minimum execution time: 145_105 nanoseconds. - Weight::from_ref_time(152_388_934) - // Standard Error: 29_988 - .saturating_add(Weight::from_ref_time(7_761_947).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `809 + r * (320 ±0)` + // Estimated: `0` + // Minimum execution time: 137_877 nanoseconds. + Weight::from_ref_time(141_863_027) + // Standard Error: 10_200 + .saturating_add(Weight::from_ref_time(7_925_232).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - // Minimum execution time: 289_319 nanoseconds. - Weight::from_ref_time(298_390_911) - // Standard Error: 27_329 - .saturating_add(Weight::from_ref_time(14_225_527).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `844 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 282_034 nanoseconds. + Weight::from_ref_time(289_388_799) + // Standard Error: 21_999 + .saturating_add(Weight::from_ref_time(15_039_420).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 305_538 nanoseconds. - Weight::from_ref_time(339_734_596) - // Standard Error: 4_636 - .saturating_add(Weight::from_ref_time(9_592_149).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1324` + // Estimated: `0` + // Minimum execution time: 303_229 nanoseconds. + Weight::from_ref_time(321_863_704) + // Standard Error: 2_754 + .saturating_add(Weight::from_ref_time(9_545_103).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { - // Minimum execution time: 287_189 nanoseconds. - Weight::from_ref_time(295_472_383) - // Standard Error: 314_142 - .saturating_add(Weight::from_ref_time(214_016).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `832 + r * (45 ±0)` + // Estimated: `0` + // Minimum execution time: 278_824 nanoseconds. + Weight::from_ref_time(285_019_861) + // Standard Error: 101_646 + .saturating_add(Weight::from_ref_time(1_757_938).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 289_380 nanoseconds. - Weight::from_ref_time(296_302_404) - // Standard Error: 889 - .saturating_add(Weight::from_ref_time(190_017).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts DeletionQueue (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `842` + // Estimated: `0` + // Minimum execution time: 286_316 nanoseconds. + Weight::from_ref_time(287_206_936) + // Standard Error: 589 + .saturating_add(Weight::from_ref_time(186_684).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts DeletionQueue (r:1 w:1) + /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:3 w:3) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - // Minimum execution time: 292_383 nanoseconds. - Weight::from_ref_time(297_557_691) - // Standard Error: 251_228 - .saturating_add(Weight::from_ref_time(56_688_008).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `874 + r * (280 ±0)` + // Estimated: `0` + // Minimum execution time: 282_428 nanoseconds. + Weight::from_ref_time(287_101_148) + // Standard Error: 145_605 + .saturating_add(Weight::from_ref_time(58_079_551).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - // Minimum execution time: 293_019 nanoseconds. - Weight::from_ref_time(301_747_439) - // Standard Error: 92_043 - .saturating_add(Weight::from_ref_time(109_861_144).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `889 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 281_516 nanoseconds. + Weight::from_ref_time(292_759_183) + // Standard Error: 152_698 + .saturating_add(Weight::from_ref_time(112_729_555).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - // Minimum execution time: 287_586 nanoseconds. - Weight::from_ref_time(304_751_302) - // Standard Error: 127_698 - .saturating_add(Weight::from_ref_time(221_525_053).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `842 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 280_100 nanoseconds. + Weight::from_ref_time(299_862_082) + // Standard Error: 95_658 + .saturating_add(Weight::from_ref_time(234_211_246).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:322 w:322) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - // Minimum execution time: 1_182_204 nanoseconds. - Weight::from_ref_time(508_607_957) - // Standard Error: 503_533 - .saturating_add(Weight::from_ref_time(173_998_655).saturating_mul(t.into())) - // Standard Error: 138_294 - .saturating_add(Weight::from_ref_time(67_991_373).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `1778 + t * (2608 ±0) + n * (8 ±0)` + // Estimated: `0` + // Minimum execution time: 1_197_721 nanoseconds. + Weight::from_ref_time(508_692_255) + // Standard Error: 538_596 + .saturating_add(Weight::from_ref_time(174_792_656).saturating_mul(t.into())) + // Standard Error: 147_924 + .saturating_add(Weight::from_ref_time(67_443_118).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(t.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - // Minimum execution time: 157_706 nanoseconds. - Weight::from_ref_time(161_895_583) - // Standard Error: 14_952 - .saturating_add(Weight::from_ref_time(12_990_237).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Skipped Metadata (r:0 w:0) + // Proof Size summary in bytes: + // Measured: `841 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 149_687 nanoseconds. + Weight::from_ref_time(153_589_818) + // Standard Error: 13_361 + .saturating_add(Weight::from_ref_time(13_379_131).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - // Minimum execution time: 290_063 nanoseconds. - Weight::from_ref_time(256_404_853) - // Standard Error: 436_195 - .saturating_add(Weight::from_ref_time(406_569_743).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `883 + r * (23417 ±0)` + // Estimated: `0` + // Minimum execution time: 281_920 nanoseconds. + Weight::from_ref_time(242_057_723) + // Standard Error: 464_911 + .saturating_add(Weight::from_ref_time(404_673_309).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - // Minimum execution time: 426_295 nanoseconds. - Weight::from_ref_time(582_989_911) - // Standard Error: 1_404_141 - .saturating_add(Weight::from_ref_time(89_545_963).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(52)) + // Proof Size summary in bytes: + // Measured: `12583 + n * (11969 ±0)` + // Estimated: `0` + // Minimum execution time: 423_923 nanoseconds. + Weight::from_ref_time(573_806_626) + // Standard Error: 1_371_107 + .saturating_add(Weight::from_ref_time(85_963_445).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(52_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(50)) + .saturating_add(T::DbWeight::get().writes(50_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - // Minimum execution time: 425_062 nanoseconds. - Weight::from_ref_time(552_380_900) - // Standard Error: 1_140_169 - .saturating_add(Weight::from_ref_time(64_085_108).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `15138 + n * (175775 ±0)` + // Estimated: `0` + // Minimum execution time: 424_048 nanoseconds. + Weight::from_ref_time(542_298_050) + // Standard Error: 1_092_010 + .saturating_add(Weight::from_ref_time(60_111_206).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(49)) + .saturating_add(T::DbWeight::get().writes(49_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - // Minimum execution time: 294_421 nanoseconds. - Weight::from_ref_time(260_897_072) - // Standard Error: 474_135 - .saturating_add(Weight::from_ref_time(403_191_862).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `876 + r * (23098 ±0)` + // Estimated: `0` + // Minimum execution time: 285_714 nanoseconds. + Weight::from_ref_time(245_068_941) + // Standard Error: 417_796 + .saturating_add(Weight::from_ref_time(394_288_572).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 391_743 nanoseconds. - Weight::from_ref_time(535_327_545) - // Standard Error: 1_297_157 - .saturating_add(Weight::from_ref_time(67_222_981).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `14863 + n * (175768 ±0)` + // Estimated: `0` + // Minimum execution time: 385_278 nanoseconds. + Weight::from_ref_time(522_656_525) + // Standard Error: 1_259_587 + .saturating_add(Weight::from_ref_time(62_799_142).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(48)) + .saturating_add(T::DbWeight::get().writes(48_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - // Minimum execution time: 294_947 nanoseconds. - Weight::from_ref_time(266_280_887) - // Standard Error: 382_477 - .saturating_add(Weight::from_ref_time(323_306_898).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `878 + r * (23740 ±0)` + // Estimated: `0` + // Minimum execution time: 282_513 nanoseconds. + Weight::from_ref_time(256_242_753) + // Standard Error: 362_571 + .saturating_add(Weight::from_ref_time(317_951_687).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 375_487 nanoseconds. - Weight::from_ref_time(497_019_365) - // Standard Error: 1_141_672 - .saturating_add(Weight::from_ref_time(152_354_482).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `15469 + n * (175775 ±0)` + // Estimated: `0` + // Minimum execution time: 370_576 nanoseconds. + Weight::from_ref_time(487_764_999) + // Standard Error: 1_073_165 + .saturating_add(Weight::from_ref_time(147_588_190).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - // Minimum execution time: 294_716 nanoseconds. - Weight::from_ref_time(266_187_186) - // Standard Error: 395_323 - .saturating_add(Weight::from_ref_time(309_907_221).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `871 + r * (23100 ±0)` + // Estimated: `0` + // Minimum execution time: 285_917 nanoseconds. + Weight::from_ref_time(259_066_807) + // Standard Error: 340_183 + .saturating_add(Weight::from_ref_time(306_291_698).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 371_667 nanoseconds. - Weight::from_ref_time(478_075_482) - // Standard Error: 979_116 - .saturating_add(Weight::from_ref_time(62_075_707).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `14814 + n * (175782 ±0)` + // Estimated: `0` + // Minimum execution time: 366_225 nanoseconds. + Weight::from_ref_time(470_470_223) + // Standard Error: 953_976 + .saturating_add(Weight::from_ref_time(57_748_742).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - // Minimum execution time: 292_147 nanoseconds. - Weight::from_ref_time(254_374_598) - // Standard Error: 442_367 - .saturating_add(Weight::from_ref_time(413_674_705).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `879 + r * (23740 ±0)` + // Estimated: `0` + // Minimum execution time: 286_867 nanoseconds. + Weight::from_ref_time(244_403_664) + // Standard Error: 435_431 + .saturating_add(Weight::from_ref_time(409_282_991).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 398_554 nanoseconds. - Weight::from_ref_time(553_715_911) - // Standard Error: 1_415_272 - .saturating_add(Weight::from_ref_time(158_254_544).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `15470 + n * (175775 ±0)` + // Estimated: `0` + // Minimum execution time: 393_392 nanoseconds. + Weight::from_ref_time(540_938_487) + // Standard Error: 1_361_411 + .saturating_add(Weight::from_ref_time(153_456_560).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(51_u64)) .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(48)) + .saturating_add(T::DbWeight::get().writes(48_u64)) .saturating_add(T::DbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1602 w:1601) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - // Minimum execution time: 295_081 nanoseconds. - Weight::from_ref_time(253_461_581) - // Standard Error: 740_198 - .saturating_add(Weight::from_ref_time(1_369_153_623).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7)) + // Proof Size summary in bytes: + // Measured: `1393 + r * (3602 ±0)` + // Estimated: `0` + // Minimum execution time: 286_766 nanoseconds. + Weight::from_ref_time(221_458_774) + // Standard Error: 714_182 + .saturating_add(Weight::from_ref_time(1_402_610_222).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:2 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:1602 w:1602) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { - // Minimum execution time: 296_089 nanoseconds. - Weight::from_ref_time(297_193_000) - // Standard Error: 6_571_547 - .saturating_add(Weight::from_ref_time(21_080_280_397).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7)) + // Proof Size summary in bytes: + // Measured: `1551 + r * (20511 ±0)` + // Estimated: `0` + // Minimum execution time: 287_158 nanoseconds. + Weight::from_ref_time(288_377_000) + // Standard Error: 6_108_706 + .saturating_add(Weight::from_ref_time(21_691_098_517).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().reads((160_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((160_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1536 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:1537 w:1537) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { - // Minimum execution time: 296_828 nanoseconds. - Weight::from_ref_time(297_685_000) - // Standard Error: 6_864_880 - .saturating_add(Weight::from_ref_time(20_770_321_946).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `0 + r * (71670 ±0)` + // Estimated: `0` + // Minimum execution time: 287_380 nanoseconds. + Weight::from_ref_time(288_241_000) + // Standard Error: 7_007_658 + .saturating_add(Weight::from_ref_time(21_428_850_764).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((150_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((75_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:81 w:81) - // Storage: Contracts CodeStorage (r:2 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:82 w:82) + /// Storage: System Account (r:82 w:81) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:2 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:82 w:82) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - // Minimum execution time: 9_824_671 nanoseconds. - Weight::from_ref_time(8_713_861_450) - // Standard Error: 7_388_925 - .saturating_add(Weight::from_ref_time(1_327_819_806).saturating_mul(t.into())) - // Standard Error: 11_079 - .saturating_add(Weight::from_ref_time(9_789_514).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(167)) + // Proof Size summary in bytes: + // Measured: `21611 + t * (15369 ±0)` + // Estimated: `0` + // Minimum execution time: 10_644_986 nanoseconds. + Weight::from_ref_time(9_596_635_640) + // Standard Error: 6_393_384 + .saturating_add(Weight::from_ref_time(1_304_764_528).saturating_mul(t.into())) + // Standard Error: 9_586 + .saturating_add(Weight::from_ref_time(9_663_819).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(167_u64)) .saturating_add(T::DbWeight::get().reads((81_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(163)) + .saturating_add(T::DbWeight::get().writes(163_u64)) .saturating_add(T::DbWeight::get().writes((81_u64).saturating_mul(t.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:80 w:80) + /// Storage: System Account (r:1602 w:1602) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1601 w:1600) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1600 w:1600) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:1602 w:1602) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { - // Minimum execution time: 293_374 nanoseconds. - Weight::from_ref_time(302_067_000) - // Standard Error: 20_137_097 - .saturating_add(Weight::from_ref_time(26_444_812_817).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(8)) + // Proof Size summary in bytes: + // Measured: `1613 + r * (25576 ±0)` + // Estimated: `0` + // Minimum execution time: 284_948 nanoseconds. + Weight::from_ref_time(289_276_000) + // Standard Error: 18_674_951 + .saturating_add(Weight::from_ref_time(27_090_355_673).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().reads((400_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(T::DbWeight::get().writes((400_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:81 w:81) - // Storage: Contracts ContractInfoOf (r:81 w:81) - // Storage: Contracts CodeStorage (r:2 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Storage: System EventTopics (r:82 w:82) + /// Storage: System Account (r:82 w:82) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:2 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:82 w:82) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 960]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 126_456_770 nanoseconds. - Weight::from_ref_time(9_223_715_752) - // Standard Error: 96_040_318 - .saturating_add(Weight::from_ref_time(19_550_519).saturating_mul(t.into())) - // Standard Error: 156_614 - .saturating_add(Weight::from_ref_time(122_958_298).saturating_mul(i.into())) - // Standard Error: 156_614 - .saturating_add(Weight::from_ref_time(123_316_079).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(249)) + // Proof Size summary in bytes: + // Measured: `5666 + t * (17 ±0)` + // Estimated: `0` + // Minimum execution time: 127_857_642 nanoseconds. + Weight::from_ref_time(11_399_054_049) + // Standard Error: 95_033_651 + .saturating_add(Weight::from_ref_time(434_246_236).saturating_mul(t.into())) + // Standard Error: 154_973 + .saturating_add(Weight::from_ref_time(121_130_672).saturating_mul(i.into())) + // Standard Error: 154_973 + .saturating_add(Weight::from_ref_time(121_554_853).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(249_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(T::DbWeight::get().writes(247)) + .saturating_add(T::DbWeight::get().writes(247_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(t.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - // Minimum execution time: 289_275 nanoseconds. - Weight::from_ref_time(297_803_961) - // Standard Error: 303_405 - .saturating_add(Weight::from_ref_time(40_800_138).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `839 + r * (642 ±0)` + // Estimated: `0` + // Minimum execution time: 280_949 nanoseconds. + Weight::from_ref_time(286_538_475) + // Standard Error: 124_866 + .saturating_add(Weight::from_ref_time(42_531_824).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 336_077 nanoseconds. - Weight::from_ref_time(336_846_000) - // Standard Error: 51_610 - .saturating_add(Weight::from_ref_time(322_208_787).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `0` + // Minimum execution time: 328_414 nanoseconds. + Weight::from_ref_time(329_293_000) + // Standard Error: 50_816 + .saturating_add(Weight::from_ref_time(318_312_506).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - // Minimum execution time: 290_189 nanoseconds. - Weight::from_ref_time(298_454_259) - // Standard Error: 252_946 - .saturating_add(Weight::from_ref_time(55_034_240).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `841 + r * (642 ±0)` + // Estimated: `0` + // Minimum execution time: 282_208 nanoseconds. + Weight::from_ref_time(286_848_187) + // Standard Error: 106_214 + .saturating_add(Weight::from_ref_time(56_342_512).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 350_030 nanoseconds. - Weight::from_ref_time(351_356_000) - // Standard Error: 57_422 - .saturating_add(Weight::from_ref_time(256_912_844).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1643` + // Estimated: `0` + // Minimum execution time: 342_478 nanoseconds. + Weight::from_ref_time(342_947_000) + // Standard Error: 60_809 + .saturating_add(Weight::from_ref_time(255_492_149).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - // Minimum execution time: 288_480 nanoseconds. - Weight::from_ref_time(297_613_263) - // Standard Error: 456_736 - .saturating_add(Weight::from_ref_time(38_100_936).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `841 + r * (642 ±0)` + // Estimated: `0` + // Minimum execution time: 279_059 nanoseconds. + Weight::from_ref_time(285_413_659) + // Standard Error: 123_081 + .saturating_add(Weight::from_ref_time(33_154_840).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 321_195 nanoseconds. - Weight::from_ref_time(325_561_000) - // Standard Error: 46_289 - .saturating_add(Weight::from_ref_time(99_536_902).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1643` + // Estimated: `0` + // Minimum execution time: 317_518 nanoseconds. + Weight::from_ref_time(318_178_000) + // Standard Error: 60_074 + .saturating_add(Weight::from_ref_time(99_403_819).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - // Minimum execution time: 287_659 nanoseconds. - Weight::from_ref_time(295_963_340) - // Standard Error: 433_889 - .saturating_add(Weight::from_ref_time(30_251_859).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `841 + r * (679 ±0)` + // Estimated: `0` + // Minimum execution time: 280_145 nanoseconds. + Weight::from_ref_time(285_483_032) + // Standard Error: 106_113 + .saturating_add(Weight::from_ref_time(33_475_067).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 324_298 nanoseconds. - Weight::from_ref_time(325_738_000) - // Standard Error: 48_563 - .saturating_add(Weight::from_ref_time(99_479_838).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1643` + // Estimated: `0` + // Minimum execution time: 318_141 nanoseconds. + Weight::from_ref_time(318_699_000) + // Standard Error: 55_136 + .saturating_add(Weight::from_ref_time(99_275_434).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - // Minimum execution time: 294_257 nanoseconds. - Weight::from_ref_time(299_467_620) - // Standard Error: 589_749 - .saturating_add(Weight::from_ref_time(3_015_389_579).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `885 + r * (6083 ±0)` + // Estimated: `0` + // Minimum execution time: 282_474 nanoseconds. + Weight::from_ref_time(288_078_802) + // Standard Error: 302_968 + .saturating_add(Weight::from_ref_time(2_944_967_597).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - // Minimum execution time: 289_480 nanoseconds. - Weight::from_ref_time(298_762_412) - // Standard Error: 397_004 - .saturating_add(Weight::from_ref_time(743_937_087).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts OwnerInfoOf (r:16 w:16) + // Proof Size summary in bytes: + // Measured: `854 + r * (3362 ±0)` + // Estimated: `0` + // Minimum execution time: 281_514 nanoseconds. + Weight::from_ref_time(287_458_651) + // Standard Error: 146_715 + .saturating_add(Weight::from_ref_time(731_367_948).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1536 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1536 w:1536) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:1538 w:1538) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 293_494 nanoseconds. - Weight::from_ref_time(297_756_000) - // Standard Error: 2_731_227 - .saturating_add(Weight::from_ref_time(1_387_380_436).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `0 + r * (79300 ±0)` + // Estimated: `0` + // Minimum execution time: 282_591 nanoseconds. + Weight::from_ref_time(286_842_000) + // Standard Error: 2_645_254 + .saturating_add(Weight::from_ref_time(1_394_535_676).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((225_u64).saturating_mul(r.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((150_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 295_339 nanoseconds. - Weight::from_ref_time(301_577_907) - // Standard Error: 23_836 - .saturating_add(Weight::from_ref_time(10_876_508).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `837 + r * (240 ±0)` + // Estimated: `0` + // Minimum execution time: 286_631 nanoseconds. + Weight::from_ref_time(288_787_650) + // Standard Error: 29_802 + .saturating_add(Weight::from_ref_time(11_115_811).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 297_096 nanoseconds. - Weight::from_ref_time(336_319_823) - // Standard Error: 128_941 - .saturating_add(Weight::from_ref_time(25_211_374).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts Nonce (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `2056 + r * (3153 ±0)` + // Estimated: `0` + // Minimum execution time: 287_775 nanoseconds. + Weight::from_ref_time(319_806_123) + // Standard Error: 111_808 + .saturating_add(Weight::from_ref_time(17_641_181).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { - // Minimum execution time: 293_819 nanoseconds. - Weight::from_ref_time(302_765_659) - // Standard Error: 28_518 - .saturating_add(Weight::from_ref_time(9_325_552).saturating_mul(r.into())) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `840 + r * (240 ±0)` + // Estimated: `0` + // Minimum execution time: 285_077 nanoseconds. + Weight::from_ref_time(289_980_475) + // Standard Error: 14_535 + .saturating_add(Weight::from_ref_time(9_295_346).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - // Minimum execution time: 805 nanoseconds. - Weight::from_ref_time(1_002_066) - // Standard Error: 609 - .saturating_add(Weight::from_ref_time(346_608).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 777 nanoseconds. + Weight::from_ref_time(1_014_498) + // Standard Error: 154 + .saturating_add(Weight::from_ref_time(405_551).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - // Minimum execution time: 917 nanoseconds. - Weight::from_ref_time(1_247_710) - // Standard Error: 1_069 - .saturating_add(Weight::from_ref_time(984_608).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 862 nanoseconds. + Weight::from_ref_time(1_345_826) + // Standard Error: 457 + .saturating_add(Weight::from_ref_time(1_033_909).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - // Minimum execution time: 917 nanoseconds. - Weight::from_ref_time(1_244_315) - // Standard Error: 524 - .saturating_add(Weight::from_ref_time(882_167).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 892 nanoseconds. + Weight::from_ref_time(1_233_601) + // Standard Error: 341 + .saturating_add(Weight::from_ref_time(885_275).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - // Minimum execution time: 791 nanoseconds. - Weight::from_ref_time(1_119_053) - // Standard Error: 379 - .saturating_add(Weight::from_ref_time(956_169).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 771 nanoseconds. + Weight::from_ref_time(1_099_906) + // Standard Error: 261 + .saturating_add(Weight::from_ref_time(1_092_031).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - // Minimum execution time: 782 nanoseconds. - Weight::from_ref_time(773_373) - // Standard Error: 463 - .saturating_add(Weight::from_ref_time(1_299_306).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 785 nanoseconds. + Weight::from_ref_time(929_328) + // Standard Error: 333 + .saturating_add(Weight::from_ref_time(1_374_749).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - // Minimum execution time: 743 nanoseconds. - Weight::from_ref_time(1_273_896) - // Standard Error: 925 - .saturating_add(Weight::from_ref_time(527_015).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 772 nanoseconds. + Weight::from_ref_time(979_702) + // Standard Error: 351 + .saturating_add(Weight::from_ref_time(621_385).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - // Minimum execution time: 761 nanoseconds. - Weight::from_ref_time(929_565) - // Standard Error: 1_275 - .saturating_add(Weight::from_ref_time(805_592).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_303_783) + // Standard Error: 1_556 + .saturating_add(Weight::from_ref_time(841_842).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - // Minimum execution time: 813 nanoseconds. - Weight::from_ref_time(703_802) - // Standard Error: 1_665 - .saturating_add(Weight::from_ref_time(1_074_321).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 792 nanoseconds. + Weight::from_ref_time(1_093_901) + // Standard Error: 1_383 + .saturating_add(Weight::from_ref_time(1_145_435).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - // Minimum execution time: 2_347 nanoseconds. - Weight::from_ref_time(2_752_638) - // Standard Error: 69 - .saturating_add(Weight::from_ref_time(4_771).saturating_mul(e.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_526 nanoseconds. + Weight::from_ref_time(2_872_561) + // Standard Error: 60 + .saturating_add(Weight::from_ref_time(4_365).saturating_mul(e.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - // Minimum execution time: 826 nanoseconds. - Weight::from_ref_time(1_784_596) - // Standard Error: 1_646 - .saturating_add(Weight::from_ref_time(2_189_993).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 834 nanoseconds. + Weight::from_ref_time(1_431_876) + // Standard Error: 1_448 + .saturating_add(Weight::from_ref_time(2_268_715).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - // Minimum execution time: 926 nanoseconds. - Weight::from_ref_time(1_898_358) - // Standard Error: 2_678 - .saturating_add(Weight::from_ref_time(2_811_379).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 920 nanoseconds. + Weight::from_ref_time(2_167_004) + // Standard Error: 2_060 + .saturating_add(Weight::from_ref_time(2_921_443).saturating_mul(r.into())) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - // Minimum execution time: 4_428 nanoseconds. - Weight::from_ref_time(5_257_445) - // Standard Error: 306 - .saturating_add(Weight::from_ref_time(178_882).saturating_mul(p.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_624 nanoseconds. + Weight::from_ref_time(5_534_325) + // Standard Error: 326 + .saturating_add(Weight::from_ref_time(184_307).saturating_mul(p.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { - // Minimum execution time: 2_945 nanoseconds. - Weight::from_ref_time(4_240_619) - // Standard Error: 39 - .saturating_add(Weight::from_ref_time(46_640).saturating_mul(l.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_062 nanoseconds. + Weight::from_ref_time(4_432_879) + // Standard Error: 64 + .saturating_add(Weight::from_ref_time(46_196).saturating_mul(l.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - // Minimum execution time: 2_204 nanoseconds. - Weight::from_ref_time(2_430_272) - // Standard Error: 270 - .saturating_add(Weight::from_ref_time(365_718).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_036 nanoseconds. + Weight::from_ref_time(2_318_877) + // Standard Error: 172 + .saturating_add(Weight::from_ref_time(500_498).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - // Minimum execution time: 2_117 nanoseconds. - Weight::from_ref_time(2_429_354) - // Standard Error: 240 - .saturating_add(Weight::from_ref_time(381_830).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_027 nanoseconds. + Weight::from_ref_time(2_355_900) + // Standard Error: 220 + .saturating_add(Weight::from_ref_time(461_393).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - // Minimum execution time: 2_123 nanoseconds. - Weight::from_ref_time(2_460_016) - // Standard Error: 262 - .saturating_add(Weight::from_ref_time(526_554).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_038 nanoseconds. + Weight::from_ref_time(2_350_330) + // Standard Error: 224 + .saturating_add(Weight::from_ref_time(586_808).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - // Minimum execution time: 892 nanoseconds. - Weight::from_ref_time(1_234_618) - // Standard Error: 485 - .saturating_add(Weight::from_ref_time(813_721).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 897 nanoseconds. + Weight::from_ref_time(1_267_115) + // Standard Error: 189 + .saturating_add(Weight::from_ref_time(884_926).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - // Minimum execution time: 901 nanoseconds. - Weight::from_ref_time(1_182_838) - // Standard Error: 482 - .saturating_add(Weight::from_ref_time(831_308).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 892 nanoseconds. + Weight::from_ref_time(1_202_122) + // Standard Error: 286 + .saturating_add(Weight::from_ref_time(885_157).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - // Minimum execution time: 929 nanoseconds. - Weight::from_ref_time(1_221_388) - // Standard Error: 434 - .saturating_add(Weight::from_ref_time(693_301).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 852 nanoseconds. + Weight::from_ref_time(1_132_479) + // Standard Error: 224 + .saturating_add(Weight::from_ref_time(719_603).saturating_mul(r.into())) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - // Minimum execution time: 808 nanoseconds. - Weight::from_ref_time(906_944) - // Standard Error: 6_164 - .saturating_add(Weight::from_ref_time(187_445_255).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 786 nanoseconds. + Weight::from_ref_time(874_044) + // Standard Error: 91_309 + .saturating_add(Weight::from_ref_time(181_849_955).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - // Minimum execution time: 807 nanoseconds. - Weight::from_ref_time(1_064_776) - // Standard Error: 287 - .saturating_add(Weight::from_ref_time(507_278).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 763 nanoseconds. + Weight::from_ref_time(1_055_236) + // Standard Error: 207 + .saturating_add(Weight::from_ref_time(554_985).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - // Minimum execution time: 776 nanoseconds. - Weight::from_ref_time(1_033_205) - // Standard Error: 443 - .saturating_add(Weight::from_ref_time(512_445).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 756 nanoseconds. + Weight::from_ref_time(1_053_050) + // Standard Error: 165 + .saturating_add(Weight::from_ref_time(555_401).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - // Minimum execution time: 909 nanoseconds. - Weight::from_ref_time(1_089_083) - // Standard Error: 335 - .saturating_add(Weight::from_ref_time(510_392).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 791 nanoseconds. + Weight::from_ref_time(1_080_240) + // Standard Error: 164 + .saturating_add(Weight::from_ref_time(554_698).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - // Minimum execution time: 791 nanoseconds. - Weight::from_ref_time(1_063_118) - // Standard Error: 210 - .saturating_add(Weight::from_ref_time(522_817).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_074_739) + // Standard Error: 178 + .saturating_add(Weight::from_ref_time(565_891).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - // Minimum execution time: 789 nanoseconds. - Weight::from_ref_time(1_056_006) - // Standard Error: 240 - .saturating_add(Weight::from_ref_time(505_198).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 781 nanoseconds. + Weight::from_ref_time(1_077_122) + // Standard Error: 177 + .saturating_add(Weight::from_ref_time(548_846).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - // Minimum execution time: 804 nanoseconds. - Weight::from_ref_time(1_087_882) - // Standard Error: 234 - .saturating_add(Weight::from_ref_time(503_830).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 793 nanoseconds. + Weight::from_ref_time(1_086_278) + // Standard Error: 163 + .saturating_add(Weight::from_ref_time(548_765).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - // Minimum execution time: 756 nanoseconds. - Weight::from_ref_time(1_050_994) - // Standard Error: 172 - .saturating_add(Weight::from_ref_time(503_343).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 769 nanoseconds. + Weight::from_ref_time(1_096_044) + // Standard Error: 134 + .saturating_add(Weight::from_ref_time(547_353).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - // Minimum execution time: 775 nanoseconds. - Weight::from_ref_time(1_061_228) - // Standard Error: 232 - .saturating_add(Weight::from_ref_time(730_751).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_072_610) + // Standard Error: 161 + .saturating_add(Weight::from_ref_time(774_895).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - // Minimum execution time: 809 nanoseconds. - Weight::from_ref_time(1_080_957) - // Standard Error: 320 - .saturating_add(Weight::from_ref_time(732_246).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 751 nanoseconds. + Weight::from_ref_time(1_038_676) + // Standard Error: 158 + .saturating_add(Weight::from_ref_time(775_194).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - // Minimum execution time: 808 nanoseconds. - Weight::from_ref_time(1_055_752) - // Standard Error: 496 - .saturating_add(Weight::from_ref_time(740_084).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_089_712) + // Standard Error: 144 + .saturating_add(Weight::from_ref_time(774_377).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - // Minimum execution time: 792 nanoseconds. - Weight::from_ref_time(1_111_972) - // Standard Error: 270 - .saturating_add(Weight::from_ref_time(741_581).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 758 nanoseconds. + Weight::from_ref_time(1_078_460) + // Standard Error: 180 + .saturating_add(Weight::from_ref_time(779_861).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - // Minimum execution time: 862 nanoseconds. - Weight::from_ref_time(1_111_246) - // Standard Error: 263 - .saturating_add(Weight::from_ref_time(746_026).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 758 nanoseconds. + Weight::from_ref_time(1_089_007) + // Standard Error: 164 + .saturating_add(Weight::from_ref_time(779_372).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - // Minimum execution time: 810 nanoseconds. - Weight::from_ref_time(1_094_933) - // Standard Error: 271 - .saturating_add(Weight::from_ref_time(743_645).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 772 nanoseconds. + Weight::from_ref_time(1_077_512) + // Standard Error: 165 + .saturating_add(Weight::from_ref_time(779_513).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - // Minimum execution time: 769 nanoseconds. - Weight::from_ref_time(819_933) - // Standard Error: 4_528 - .saturating_add(Weight::from_ref_time(751_599).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 760 nanoseconds. + Weight::from_ref_time(1_078_546) + // Standard Error: 168 + .saturating_add(Weight::from_ref_time(779_138).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - // Minimum execution time: 797 nanoseconds. - Weight::from_ref_time(1_107_352) - // Standard Error: 344 - .saturating_add(Weight::from_ref_time(738_684).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 757 nanoseconds. + Weight::from_ref_time(1_080_251) + // Standard Error: 168 + .saturating_add(Weight::from_ref_time(779_391).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - // Minimum execution time: 784 nanoseconds. - Weight::from_ref_time(1_068_487) - // Standard Error: 3_796 - .saturating_add(Weight::from_ref_time(741_207).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 786 nanoseconds. + Weight::from_ref_time(1_072_690) + // Standard Error: 219 + .saturating_add(Weight::from_ref_time(780_381).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - // Minimum execution time: 813 nanoseconds. - Weight::from_ref_time(1_067_278) - // Standard Error: 459 - .saturating_add(Weight::from_ref_time(737_841).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 771 nanoseconds. + Weight::from_ref_time(1_063_735) + // Standard Error: 162 + .saturating_add(Weight::from_ref_time(779_906).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - // Minimum execution time: 798 nanoseconds. - Weight::from_ref_time(1_100_254) - // Standard Error: 297 - .saturating_add(Weight::from_ref_time(717_622).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 785 nanoseconds. + Weight::from_ref_time(1_059_585) + // Standard Error: 155 + .saturating_add(Weight::from_ref_time(756_828).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - // Minimum execution time: 778 nanoseconds. - Weight::from_ref_time(1_063_748) - // Standard Error: 378 - .saturating_add(Weight::from_ref_time(713_577).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 800 nanoseconds. + Weight::from_ref_time(1_066_659) + // Standard Error: 154 + .saturating_add(Weight::from_ref_time(754_318).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - // Minimum execution time: 780 nanoseconds. - Weight::from_ref_time(1_088_755) - // Standard Error: 316 - .saturating_add(Weight::from_ref_time(714_127).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 769 nanoseconds. + Weight::from_ref_time(1_078_854) + // Standard Error: 172 + .saturating_add(Weight::from_ref_time(754_183).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - // Minimum execution time: 776 nanoseconds. - Weight::from_ref_time(1_062_591) - // Standard Error: 610 - .saturating_add(Weight::from_ref_time(1_355_430).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 770 nanoseconds. + Weight::from_ref_time(1_057_476) + // Standard Error: 191 + .saturating_add(Weight::from_ref_time(1_443_902).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - // Minimum execution time: 801 nanoseconds. - Weight::from_ref_time(1_092_395) - // Standard Error: 423 - .saturating_add(Weight::from_ref_time(1_282_356).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 764 nanoseconds. + Weight::from_ref_time(1_063_821) + // Standard Error: 193 + .saturating_add(Weight::from_ref_time(1_324_496).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - // Minimum execution time: 822 nanoseconds. - Weight::from_ref_time(1_083_079) - // Standard Error: 562 - .saturating_add(Weight::from_ref_time(1_398_522).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 747 nanoseconds. + Weight::from_ref_time(1_093_209) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(1_447_180).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - // Minimum execution time: 798 nanoseconds. - Weight::from_ref_time(1_088_997) - // Standard Error: 401 - .saturating_add(Weight::from_ref_time(1_283_442).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 805 nanoseconds. + Weight::from_ref_time(1_033_953) + // Standard Error: 152 + .saturating_add(Weight::from_ref_time(1_336_911).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - // Minimum execution time: 815 nanoseconds. - Weight::from_ref_time(1_081_903) - // Standard Error: 264 - .saturating_add(Weight::from_ref_time(718_069).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_059_430) + // Standard Error: 160 + .saturating_add(Weight::from_ref_time(757_265).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - // Minimum execution time: 813 nanoseconds. - Weight::from_ref_time(1_091_426) - // Standard Error: 296 - .saturating_add(Weight::from_ref_time(717_894).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 760 nanoseconds. + Weight::from_ref_time(1_077_376) + // Standard Error: 160 + .saturating_add(Weight::from_ref_time(755_800).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - // Minimum execution time: 794 nanoseconds. - Weight::from_ref_time(1_040_144) - // Standard Error: 400 - .saturating_add(Weight::from_ref_time(719_886).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_070_570) + // Standard Error: 157 + .saturating_add(Weight::from_ref_time(756_839).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - // Minimum execution time: 774 nanoseconds. - Weight::from_ref_time(1_092_466) - // Standard Error: 4_173 - .saturating_add(Weight::from_ref_time(739_873).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 761 nanoseconds. + Weight::from_ref_time(1_074_645) + // Standard Error: 169 + .saturating_add(Weight::from_ref_time(771_486).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - // Minimum execution time: 793 nanoseconds. - Weight::from_ref_time(1_105_611) - // Standard Error: 394 - .saturating_add(Weight::from_ref_time(735_358).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 779 nanoseconds. + Weight::from_ref_time(1_107_671) + // Standard Error: 185 + .saturating_add(Weight::from_ref_time(769_168).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - // Minimum execution time: 805 nanoseconds. - Weight::from_ref_time(1_130_462) - // Standard Error: 327 - .saturating_add(Weight::from_ref_time(734_198).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 755 nanoseconds. + Weight::from_ref_time(1_075_769) + // Standard Error: 164 + .saturating_add(Weight::from_ref_time(770_334).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - // Minimum execution time: 831 nanoseconds. - Weight::from_ref_time(1_118_894) - // Standard Error: 389 - .saturating_add(Weight::from_ref_time(733_834).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 767 nanoseconds. + Weight::from_ref_time(608_749) + // Standard Error: 2_059 + .saturating_add(Weight::from_ref_time(804_228).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - // Minimum execution time: 772 nanoseconds. - Weight::from_ref_time(1_123_733) - // Standard Error: 337 - .saturating_add(Weight::from_ref_time(733_923).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 779 nanoseconds. + Weight::from_ref_time(1_054_998) + // Standard Error: 191 + .saturating_add(Weight::from_ref_time(770_225).saturating_mul(r.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Contracts DeletionQueue (r:1 w:0) + /// Storage: Contracts DeletionQueue (r:1 w:0) + /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Ignored) fn on_process_deletion_queue_batch() -> Weight { - // Minimum execution time: 3_326 nanoseconds. - Weight::from_ref_time(3_433_000) - .saturating_add(RocksDbWeight::get().reads(1)) - } - // Storage: Skipped Metadata (r:0 w:0) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `0` + // Minimum execution time: 2_305 nanoseconds. + Weight::from_ref_time(2_560_000) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `k` is `[0, 1024]`. fn on_initialize_per_trie_key(k: u32, ) -> Weight { - // Minimum execution time: 15_703 nanoseconds. - Weight::from_ref_time(15_288_927) - // Standard Error: 951 - .saturating_add(Weight::from_ref_time(940_816).saturating_mul(k.into())) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `481 + k * (69 ±0)` + // Estimated: `0` + // Minimum execution time: 9_311 nanoseconds. + Weight::from_ref_time(5_419_288) + // Standard Error: 562 + .saturating_add(Weight::from_ref_time(911_962).saturating_mul(k.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) } - // Storage: Contracts DeletionQueue (r:1 w:0) + /// Storage: Contracts DeletionQueue (r:1 w:1) + /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Ignored) /// The range of component `q` is `[0, 128]`. fn on_initialize_per_queue_item(q: u32, ) -> Weight { - // Minimum execution time: 3_548 nanoseconds. - Weight::from_ref_time(15_764_121) - // Standard Error: 3_339 - .saturating_add(Weight::from_ref_time(1_214_890).saturating_mul(q.into())) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Contracts PristineCode (r:1 w:0) - // Storage: Contracts CodeStorage (r:0 w:1) - /// The range of component `c` is `[0, 64226]`. + // Proof Size summary in bytes: + // Measured: `281 + q * (33 ±0)` + // Estimated: `0` + // Minimum execution time: 2_288 nanoseconds. + Weight::from_ref_time(9_442_437) + // Standard Error: 2_720 + .saturating_add(Weight::from_ref_time(1_076_950).saturating_mul(q.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Contracts PristineCode (r:1 w:0) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) + /// Storage: Contracts CodeStorage (r:0 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// The range of component `c` is `[0, 61717]`. fn reinstrument(c: u32, ) -> Weight { - // Minimum execution time: 29_801 nanoseconds. - Weight::from_ref_time(27_932_706) - // Standard Error: 49 - .saturating_add(Weight::from_ref_time(50_532).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: System EventTopics (r:2 w:2) - /// The range of component `c` is `[0, 131072]`. + // Proof Size summary in bytes: + // Measured: `270 + c * (1 ±0)` + // Estimated: `0` + // Minimum execution time: 27_539 nanoseconds. + Weight::from_ref_time(23_554_889) + // Standard Error: 56 + .saturating_add(Weight::from_ref_time(46_766).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// The range of component `c` is `[0, 125952]`. fn call_with_code_per_byte(c: u32, ) -> Weight { - // Minimum execution time: 307_894 nanoseconds. - Weight::from_ref_time(322_346_319) - // Standard Error: 25 - .saturating_add(Weight::from_ref_time(30_678).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Contracts CodeStorage (r:1 w:1) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: System EventTopics (r:3 w:3) - // Storage: Contracts PristineCode (r:0 w:1) - // Storage: Contracts OwnerInfoOf (r:0 w:1) - /// The range of component `c` is `[0, 64226]`. + // Proof Size summary in bytes: + // Measured: `771` + // Estimated: `0` + // Minimum execution time: 297_710 nanoseconds. + Weight::from_ref_time(307_327_529) + // Standard Error: 18 + .saturating_add(Weight::from_ref_time(29_849).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Contracts CodeStorage (r:1 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: System EventTopics (r:3 w:3) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// Storage: Contracts PristineCode (r:0 w:1) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:0 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// The range of component `c` is `[0, 61717]`. /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate_with_code(c: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 3_610_424 nanoseconds. - Weight::from_ref_time(583_426_386) - // Standard Error: 277 - .saturating_add(Weight::from_ref_time(90_224).saturating_mul(c.into())) + // Proof Size summary in bytes: + // Measured: `257` + // Estimated: `0` + // Minimum execution time: 3_586_223 nanoseconds. + Weight::from_ref_time(561_614_281) + // Standard Error: 274 + .saturating_add(Weight::from_ref_time(87_557).saturating_mul(c.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_325).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_307).saturating_mul(i.into())) // Standard Error: 16 - .saturating_add(Weight::from_ref_time(1_727).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(9)) - } - // Storage: Contracts CodeStorage (r:1 w:1) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(Weight::from_ref_time(1_721).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(9_u64)) + } + /// Storage: Contracts CodeStorage (r:1 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `i` is `[0, 1048576]`. /// The range of component `s` is `[0, 1048576]`. fn instantiate(i: u32, s: u32, ) -> Weight { - // Minimum execution time: 1_892_996 nanoseconds. - Weight::from_ref_time(202_958_196) + // Proof Size summary in bytes: + // Measured: `533` + // Estimated: `0` + // Minimum execution time: 1_885_437 nanoseconds. + Weight::from_ref_time(199_943_867) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_627).saturating_mul(i.into())) + .saturating_add(Weight::from_ref_time(1_611).saturating_mul(i.into())) // Standard Error: 8 - .saturating_add(Weight::from_ref_time(1_755).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(7)) - } - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(Weight::from_ref_time(1_737).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) fn call() -> Weight { - // Minimum execution time: 157_347 nanoseconds. - Weight::from_ref_time(159_084_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Contracts CodeStorage (r:1 w:1) - // Storage: System EventTopics (r:1 w:1) - // Storage: Contracts PristineCode (r:0 w:1) - // Storage: Contracts OwnerInfoOf (r:0 w:1) - /// The range of component `c` is `[0, 64226]`. + // Proof Size summary in bytes: + // Measured: `823` + // Estimated: `0` + // Minimum execution time: 150_604 nanoseconds. + Weight::from_ref_time(151_777_000) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Contracts CodeStorage (r:1 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: System EventTopics (r:1 w:1) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// Storage: Contracts PristineCode (r:0 w:1) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:0 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// The range of component `c` is `[0, 61717]`. fn upload_code(c: u32, ) -> Weight { - // Minimum execution time: 299_987 nanoseconds. - Weight::from_ref_time(305_274_879) - // Standard Error: 72 - .saturating_add(Weight::from_ref_time(91_916).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Storage: System EventTopics (r:1 w:1) - // Storage: Contracts CodeStorage (r:0 w:1) - // Storage: Contracts PristineCode (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `0` + // Minimum execution time: 295_505 nanoseconds. + Weight::from_ref_time(305_609_098) + // Standard Error: 58 + .saturating_add(Weight::from_ref_time(88_676).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:1 w:1) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) + /// Storage: Contracts CodeStorage (r:0 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Contracts PristineCode (r:0 w:1) + /// Proof: Contracts PristineCode (max_values: None, max_size: Some(125988), added: 128463, mode: Ignored) fn remove_code() -> Weight { - // Minimum execution time: 40_795 nanoseconds. - Weight::from_ref_time(41_297_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:2 w:2) - // Storage: System EventTopics (r:3 w:3) + // Proof Size summary in bytes: + // Measured: `287` + // Estimated: `0` + // Minimum execution time: 25_949 nanoseconds. + Weight::from_ref_time(26_316_000) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:2 w:2) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:3 w:3) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) fn set_code() -> Weight { - // Minimum execution time: 41_957 nanoseconds. - Weight::from_ref_time(42_536_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(6)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `634` + // Estimated: `0` + // Minimum execution time: 29_005 nanoseconds. + Weight::from_ref_time(29_370_000) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_caller(r: u32, ) -> Weight { - // Minimum execution time: 293_544 nanoseconds. - Weight::from_ref_time(298_981_222) - // Standard Error: 39_139 - .saturating_add(Weight::from_ref_time(17_278_436).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `845 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 281_880 nanoseconds. + Weight::from_ref_time(289_637_700) + // Standard Error: 22_662 + .saturating_add(Weight::from_ref_time(16_866_274).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_is_contract(r: u32, ) -> Weight { - // Minimum execution time: 293_500 nanoseconds. - Weight::from_ref_time(237_825_284) - // Standard Error: 450_234 - .saturating_add(Weight::from_ref_time(198_995_806).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `882 + r * (19218 ±0)` + // Estimated: `0` + // Minimum execution time: 285_590 nanoseconds. + Weight::from_ref_time(231_277_523) + // Standard Error: 425_084 + .saturating_add(Weight::from_ref_time(192_985_377).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 295_851 nanoseconds. - Weight::from_ref_time(258_113_447) - // Standard Error: 408_747 - .saturating_add(Weight::from_ref_time(237_490_216).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `889 + r * (19539 ±0)` + // Estimated: `0` + // Minimum execution time: 282_966 nanoseconds. + Weight::from_ref_time(236_127_328) + // Standard Error: 405_193 + .saturating_add(Weight::from_ref_time(235_541_377).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_own_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 294_614 nanoseconds. - Weight::from_ref_time(301_528_998) - // Standard Error: 40_613 - .saturating_add(Weight::from_ref_time(20_815_088).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `852 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 286_021 nanoseconds. + Weight::from_ref_time(290_200_599) + // Standard Error: 19_224 + .saturating_add(Weight::from_ref_time(20_692_099).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_caller_is_origin(r: u32, ) -> Weight { - // Minimum execution time: 293_088 nanoseconds. - Weight::from_ref_time(299_120_595) - // Standard Error: 23_277 - .saturating_add(Weight::from_ref_time(11_130_334).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `842 + r * (240 ±0)` + // Estimated: `0` + // Minimum execution time: 284_175 nanoseconds. + Weight::from_ref_time(286_665_694) + // Standard Error: 14_104 + .saturating_add(Weight::from_ref_time(11_196_944).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_address(r: u32, ) -> Weight { - // Minimum execution time: 295_110 nanoseconds. - Weight::from_ref_time(305_295_787) - // Standard Error: 48_521 - .saturating_add(Weight::from_ref_time(16_610_806).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `846 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_315 nanoseconds. + Weight::from_ref_time(289_734_189) + // Standard Error: 15_980 + .saturating_add(Weight::from_ref_time(16_940_657).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_gas_left(r: u32, ) -> Weight { - // Minimum execution time: 293_414 nanoseconds. - Weight::from_ref_time(299_960_283) - // Standard Error: 32_003 - .saturating_add(Weight::from_ref_time(16_652_433).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `847 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_708 nanoseconds. + Weight::from_ref_time(289_872_393) + // Standard Error: 16_551 + .saturating_add(Weight::from_ref_time(16_672_944).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:2 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_balance(r: u32, ) -> Weight { - // Minimum execution time: 292_429 nanoseconds. - Weight::from_ref_time(301_025_128) - // Standard Error: 92_155 - .saturating_add(Weight::from_ref_time(92_731_719).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1017 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_698 nanoseconds. + Weight::from_ref_time(295_636_093) + // Standard Error: 97_582 + .saturating_add(Weight::from_ref_time(92_891_252).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_value_transferred(r: u32, ) -> Weight { - // Minimum execution time: 293_516 nanoseconds. - Weight::from_ref_time(300_071_428) - // Standard Error: 25_871 - .saturating_add(Weight::from_ref_time(16_599_369).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `856 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 282_057 nanoseconds. + Weight::from_ref_time(289_304_621) + // Standard Error: 17_818 + .saturating_add(Weight::from_ref_time(16_725_632).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_minimum_balance(r: u32, ) -> Weight { - // Minimum execution time: 293_666 nanoseconds. - Weight::from_ref_time(299_803_599) - // Standard Error: 24_508 - .saturating_add(Weight::from_ref_time(16_500_973).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `854 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 282_478 nanoseconds. + Weight::from_ref_time(289_682_366) + // Standard Error: 20_379 + .saturating_add(Weight::from_ref_time(16_517_079).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_block_number(r: u32, ) -> Weight { - // Minimum execution time: 289_193 nanoseconds. - Weight::from_ref_time(297_946_784) - // Standard Error: 43_719 - .saturating_add(Weight::from_ref_time(16_442_254).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `851 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 283_826 nanoseconds. + Weight::from_ref_time(289_935_300) + // Standard Error: 15_180 + .saturating_add(Weight::from_ref_time(16_268_515).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_now(r: u32, ) -> Weight { - // Minimum execution time: 288_897 nanoseconds. - Weight::from_ref_time(298_856_658) - // Standard Error: 31_003 - .saturating_add(Weight::from_ref_time(16_490_508).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `842 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 285_455 nanoseconds. + Weight::from_ref_time(289_682_526) + // Standard Error: 18_667 + .saturating_add(Weight::from_ref_time(16_502_025).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_weight_to_fee(r: u32, ) -> Weight { - // Minimum execution time: 289_850 nanoseconds. - Weight::from_ref_time(302_898_449) - // Standard Error: 92_822 - .saturating_add(Weight::from_ref_time(86_376_874).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `919 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 286_106 nanoseconds. + Weight::from_ref_time(294_493_680) + // Standard Error: 76_469 + .saturating_add(Weight::from_ref_time(87_055_837).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_gas(r: u32, ) -> Weight { - // Minimum execution time: 145_105 nanoseconds. - Weight::from_ref_time(152_388_934) - // Standard Error: 29_988 - .saturating_add(Weight::from_ref_time(7_761_947).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `809 + r * (320 ±0)` + // Estimated: `0` + // Minimum execution time: 137_877 nanoseconds. + Weight::from_ref_time(141_863_027) + // Standard Error: 10_200 + .saturating_add(Weight::from_ref_time(7_925_232).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_input(r: u32, ) -> Weight { - // Minimum execution time: 289_319 nanoseconds. - Weight::from_ref_time(298_390_911) - // Standard Error: 27_329 - .saturating_add(Weight::from_ref_time(14_225_527).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `844 + r * (480 ±0)` + // Estimated: `0` + // Minimum execution time: 282_034 nanoseconds. + Weight::from_ref_time(289_388_799) + // Standard Error: 21_999 + .saturating_add(Weight::from_ref_time(15_039_420).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_input_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 305_538 nanoseconds. - Weight::from_ref_time(339_734_596) - // Standard Error: 4_636 - .saturating_add(Weight::from_ref_time(9_592_149).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1324` + // Estimated: `0` + // Minimum execution time: 303_229 nanoseconds. + Weight::from_ref_time(321_863_704) + // Standard Error: 2_754 + .saturating_add(Weight::from_ref_time(9_545_103).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_return(r: u32, ) -> Weight { - // Minimum execution time: 287_189 nanoseconds. - Weight::from_ref_time(295_472_383) - // Standard Error: 314_142 - .saturating_add(Weight::from_ref_time(214_016).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `832 + r * (45 ±0)` + // Estimated: `0` + // Minimum execution time: 278_824 nanoseconds. + Weight::from_ref_time(285_019_861) + // Standard Error: 101_646 + .saturating_add(Weight::from_ref_time(1_757_938).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_return_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 289_380 nanoseconds. - Weight::from_ref_time(296_302_404) - // Standard Error: 889 - .saturating_add(Weight::from_ref_time(190_017).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts DeletionQueue (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `842` + // Estimated: `0` + // Minimum execution time: 286_316 nanoseconds. + Weight::from_ref_time(287_206_936) + // Standard Error: 589 + .saturating_add(Weight::from_ref_time(186_684).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts DeletionQueue (r:1 w:1) + /// Proof: Contracts DeletionQueue (max_values: Some(1), max_size: Some(16642), added: 17137, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:3 w:3) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_terminate(r: u32, ) -> Weight { - // Minimum execution time: 292_383 nanoseconds. - Weight::from_ref_time(297_557_691) - // Standard Error: 251_228 - .saturating_add(Weight::from_ref_time(56_688_008).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `874 + r * (280 ±0)` + // Estimated: `0` + // Minimum execution time: 282_428 nanoseconds. + Weight::from_ref_time(287_101_148) + // Standard Error: 145_605 + .saturating_add(Weight::from_ref_time(58_079_551).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((6_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_random(r: u32, ) -> Weight { - // Minimum execution time: 293_019 nanoseconds. - Weight::from_ref_time(301_747_439) - // Standard Error: 92_043 - .saturating_add(Weight::from_ref_time(109_861_144).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `889 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 281_516 nanoseconds. + Weight::from_ref_time(292_759_183) + // Standard Error: 152_698 + .saturating_add(Weight::from_ref_time(112_729_555).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_deposit_event(r: u32, ) -> Weight { - // Minimum execution time: 287_586 nanoseconds. - Weight::from_ref_time(304_751_302) - // Standard Error: 127_698 - .saturating_add(Weight::from_ref_time(221_525_053).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `842 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 280_100 nanoseconds. + Weight::from_ref_time(299_862_082) + // Standard Error: 95_658 + .saturating_add(Weight::from_ref_time(234_211_246).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:322 w:322) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `t` is `[0, 4]`. /// The range of component `n` is `[0, 16]`. fn seal_deposit_event_per_topic_and_kb(t: u32, n: u32, ) -> Weight { - // Minimum execution time: 1_182_204 nanoseconds. - Weight::from_ref_time(508_607_957) - // Standard Error: 503_533 - .saturating_add(Weight::from_ref_time(173_998_655).saturating_mul(t.into())) - // Standard Error: 138_294 - .saturating_add(Weight::from_ref_time(67_991_373).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `1778 + t * (2608 ±0) + n * (8 ±0)` + // Estimated: `0` + // Minimum execution time: 1_197_721 nanoseconds. + Weight::from_ref_time(508_692_255) + // Standard Error: 538_596 + .saturating_add(Weight::from_ref_time(174_792_656).saturating_mul(t.into())) + // Standard Error: 147_924 + .saturating_add(Weight::from_ref_time(67_443_118).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(t.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(t.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_debug_message(r: u32, ) -> Weight { - // Minimum execution time: 157_706 nanoseconds. - Weight::from_ref_time(161_895_583) - // Standard Error: 14_952 - .saturating_add(Weight::from_ref_time(12_990_237).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Skipped Metadata (r:0 w:0) + // Proof Size summary in bytes: + // Measured: `841 + r * (800 ±0)` + // Estimated: `0` + // Minimum execution time: 149_687 nanoseconds. + Weight::from_ref_time(153_589_818) + // Standard Error: 13_361 + .saturating_add(Weight::from_ref_time(13_379_131).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_set_storage(r: u32, ) -> Weight { - // Minimum execution time: 290_063 nanoseconds. - Weight::from_ref_time(256_404_853) - // Standard Error: 436_195 - .saturating_add(Weight::from_ref_time(406_569_743).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `883 + r * (23417 ±0)` + // Estimated: `0` + // Minimum execution time: 281_920 nanoseconds. + Weight::from_ref_time(242_057_723) + // Standard Error: 464_911 + .saturating_add(Weight::from_ref_time(404_673_309).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_new_kb(n: u32, ) -> Weight { - // Minimum execution time: 426_295 nanoseconds. - Weight::from_ref_time(582_989_911) - // Standard Error: 1_404_141 - .saturating_add(Weight::from_ref_time(89_545_963).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(52)) + // Proof Size summary in bytes: + // Measured: `12583 + n * (11969 ±0)` + // Estimated: `0` + // Minimum execution time: 423_923 nanoseconds. + Weight::from_ref_time(573_806_626) + // Standard Error: 1_371_107 + .saturating_add(Weight::from_ref_time(85_963_445).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(52_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(50)) + .saturating_add(RocksDbWeight::get().writes(50_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_set_storage_per_old_kb(n: u32, ) -> Weight { - // Minimum execution time: 425_062 nanoseconds. - Weight::from_ref_time(552_380_900) - // Standard Error: 1_140_169 - .saturating_add(Weight::from_ref_time(64_085_108).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `15138 + n * (175775 ±0)` + // Estimated: `0` + // Minimum execution time: 424_048 nanoseconds. + Weight::from_ref_time(542_298_050) + // Standard Error: 1_092_010 + .saturating_add(Weight::from_ref_time(60_111_206).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(49)) + .saturating_add(RocksDbWeight::get().writes(49_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_clear_storage(r: u32, ) -> Weight { - // Minimum execution time: 294_421 nanoseconds. - Weight::from_ref_time(260_897_072) - // Standard Error: 474_135 - .saturating_add(Weight::from_ref_time(403_191_862).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `876 + r * (23098 ±0)` + // Estimated: `0` + // Minimum execution time: 285_714 nanoseconds. + Weight::from_ref_time(245_068_941) + // Standard Error: 417_796 + .saturating_add(Weight::from_ref_time(394_288_572).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_clear_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 391_743 nanoseconds. - Weight::from_ref_time(535_327_545) - // Standard Error: 1_297_157 - .saturating_add(Weight::from_ref_time(67_222_981).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `14863 + n * (175768 ±0)` + // Estimated: `0` + // Minimum execution time: 385_278 nanoseconds. + Weight::from_ref_time(522_656_525) + // Standard Error: 1_259_587 + .saturating_add(Weight::from_ref_time(62_799_142).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(48)) + .saturating_add(RocksDbWeight::get().writes(48_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_get_storage(r: u32, ) -> Weight { - // Minimum execution time: 294_947 nanoseconds. - Weight::from_ref_time(266_280_887) - // Standard Error: 382_477 - .saturating_add(Weight::from_ref_time(323_306_898).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `878 + r * (23740 ±0)` + // Estimated: `0` + // Minimum execution time: 282_513 nanoseconds. + Weight::from_ref_time(256_242_753) + // Standard Error: 362_571 + .saturating_add(Weight::from_ref_time(317_951_687).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_get_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 375_487 nanoseconds. - Weight::from_ref_time(497_019_365) - // Standard Error: 1_141_672 - .saturating_add(Weight::from_ref_time(152_354_482).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `15469 + n * (175775 ±0)` + // Estimated: `0` + // Minimum execution time: 370_576 nanoseconds. + Weight::from_ref_time(487_764_999) + // Standard Error: 1_073_165 + .saturating_add(Weight::from_ref_time(147_588_190).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_contains_storage(r: u32, ) -> Weight { - // Minimum execution time: 294_716 nanoseconds. - Weight::from_ref_time(266_187_186) - // Standard Error: 395_323 - .saturating_add(Weight::from_ref_time(309_907_221).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `871 + r * (23100 ±0)` + // Estimated: `0` + // Minimum execution time: 285_917 nanoseconds. + Weight::from_ref_time(259_066_807) + // Standard Error: 340_183 + .saturating_add(Weight::from_ref_time(306_291_698).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_contains_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 371_667 nanoseconds. - Weight::from_ref_time(478_075_482) - // Standard Error: 979_116 - .saturating_add(Weight::from_ref_time(62_075_707).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `14814 + n * (175782 ±0)` + // Estimated: `0` + // Minimum execution time: 366_225 nanoseconds. + Weight::from_ref_time(470_470_223) + // Standard Error: 953_976 + .saturating_add(Weight::from_ref_time(57_748_742).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 10]`. fn seal_take_storage(r: u32, ) -> Weight { - // Minimum execution time: 292_147 nanoseconds. - Weight::from_ref_time(254_374_598) - // Standard Error: 442_367 - .saturating_add(Weight::from_ref_time(413_674_705).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `879 + r * (23740 ±0)` + // Estimated: `0` + // Minimum execution time: 286_867 nanoseconds. + Weight::from_ref_time(244_403_664) + // Standard Error: 435_431 + .saturating_add(Weight::from_ref_time(409_282_991).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 8]`. fn seal_take_storage_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 398_554 nanoseconds. - Weight::from_ref_time(553_715_911) - // Standard Error: 1_415_272 - .saturating_add(Weight::from_ref_time(158_254_544).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(51)) + // Proof Size summary in bytes: + // Measured: `15470 + n * (175775 ±0)` + // Estimated: `0` + // Minimum execution time: 393_392 nanoseconds. + Weight::from_ref_time(540_938_487) + // Standard Error: 1_361_411 + .saturating_add(Weight::from_ref_time(153_456_560).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(51_u64)) .saturating_add(RocksDbWeight::get().reads((7_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(48)) + .saturating_add(RocksDbWeight::get().writes(48_u64)) .saturating_add(RocksDbWeight::get().writes((7_u64).saturating_mul(n.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1602 w:1601) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_transfer(r: u32, ) -> Weight { - // Minimum execution time: 295_081 nanoseconds. - Weight::from_ref_time(253_461_581) - // Standard Error: 740_198 - .saturating_add(Weight::from_ref_time(1_369_153_623).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(7)) + // Proof Size summary in bytes: + // Measured: `1393 + r * (3602 ±0)` + // Estimated: `0` + // Minimum execution time: 286_766 nanoseconds. + Weight::from_ref_time(221_458_774) + // Standard Error: 714_182 + .saturating_add(Weight::from_ref_time(1_402_610_222).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((80_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((80_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:2 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:1602 w:1602) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_call(r: u32, ) -> Weight { - // Minimum execution time: 296_089 nanoseconds. - Weight::from_ref_time(297_193_000) - // Standard Error: 6_571_547 - .saturating_add(Weight::from_ref_time(21_080_280_397).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(7)) + // Proof Size summary in bytes: + // Measured: `1551 + r * (20511 ±0)` + // Estimated: `0` + // Minimum execution time: 287_158 nanoseconds. + Weight::from_ref_time(288_377_000) + // Standard Error: 6_108_706 + .saturating_add(Weight::from_ref_time(21_691_098_517).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) .saturating_add(RocksDbWeight::get().reads((160_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((160_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1536 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:1537 w:1537) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_delegate_call(r: u32, ) -> Weight { - // Minimum execution time: 296_828 nanoseconds. - Weight::from_ref_time(297_685_000) - // Standard Error: 6_864_880 - .saturating_add(Weight::from_ref_time(20_770_321_946).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `0 + r * (71670 ±0)` + // Estimated: `0` + // Minimum execution time: 287_380 nanoseconds. + Weight::from_ref_time(288_241_000) + // Standard Error: 7_007_658 + .saturating_add(Weight::from_ref_time(21_428_850_764).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((150_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((75_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:81 w:81) - // Storage: Contracts CodeStorage (r:2 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:82 w:82) + /// Storage: System Account (r:82 w:81) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:2 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:82 w:82) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `t` is `[0, 1]`. /// The range of component `c` is `[0, 1024]`. fn seal_call_per_transfer_clone_kb(t: u32, c: u32, ) -> Weight { - // Minimum execution time: 9_824_671 nanoseconds. - Weight::from_ref_time(8_713_861_450) - // Standard Error: 7_388_925 - .saturating_add(Weight::from_ref_time(1_327_819_806).saturating_mul(t.into())) - // Standard Error: 11_079 - .saturating_add(Weight::from_ref_time(9_789_514).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(167)) + // Proof Size summary in bytes: + // Measured: `21611 + t * (15369 ±0)` + // Estimated: `0` + // Minimum execution time: 10_644_986 nanoseconds. + Weight::from_ref_time(9_596_635_640) + // Standard Error: 6_393_384 + .saturating_add(Weight::from_ref_time(1_304_764_528).saturating_mul(t.into())) + // Standard Error: 9_586 + .saturating_add(Weight::from_ref_time(9_663_819).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(167_u64)) .saturating_add(RocksDbWeight::get().reads((81_u64).saturating_mul(t.into()))) - .saturating_add(RocksDbWeight::get().writes(163)) + .saturating_add(RocksDbWeight::get().writes(163_u64)) .saturating_add(RocksDbWeight::get().writes((81_u64).saturating_mul(t.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:80 w:80) + /// Storage: System Account (r:1602 w:1602) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1601 w:1601) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1601 w:1600) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1600 w:1600) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:1602 w:1602) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_instantiate(r: u32, ) -> Weight { - // Minimum execution time: 293_374 nanoseconds. - Weight::from_ref_time(302_067_000) - // Standard Error: 20_137_097 - .saturating_add(Weight::from_ref_time(26_444_812_817).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(8)) + // Proof Size summary in bytes: + // Measured: `1613 + r * (25576 ±0)` + // Estimated: `0` + // Minimum execution time: 284_948 nanoseconds. + Weight::from_ref_time(289_276_000) + // Standard Error: 18_674_951 + .saturating_add(Weight::from_ref_time(27_090_355_673).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().reads((400_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(5)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(RocksDbWeight::get().writes((400_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:81 w:81) - // Storage: Contracts ContractInfoOf (r:81 w:81) - // Storage: Contracts CodeStorage (r:2 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: Contracts Nonce (r:1 w:1) - // Storage: Contracts OwnerInfoOf (r:1 w:1) - // Storage: System EventTopics (r:82 w:82) + /// Storage: System Account (r:82 w:82) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:81 w:81) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:2 w:1) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1 w:1) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:82 w:82) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `t` is `[0, 1]`. /// The range of component `i` is `[0, 960]`. /// The range of component `s` is `[0, 960]`. fn seal_instantiate_per_transfer_input_salt_kb(t: u32, i: u32, s: u32, ) -> Weight { - // Minimum execution time: 126_456_770 nanoseconds. - Weight::from_ref_time(9_223_715_752) - // Standard Error: 96_040_318 - .saturating_add(Weight::from_ref_time(19_550_519).saturating_mul(t.into())) - // Standard Error: 156_614 - .saturating_add(Weight::from_ref_time(122_958_298).saturating_mul(i.into())) - // Standard Error: 156_614 - .saturating_add(Weight::from_ref_time(123_316_079).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(249)) + // Proof Size summary in bytes: + // Measured: `5666 + t * (17 ±0)` + // Estimated: `0` + // Minimum execution time: 127_857_642 nanoseconds. + Weight::from_ref_time(11_399_054_049) + // Standard Error: 95_033_651 + .saturating_add(Weight::from_ref_time(434_246_236).saturating_mul(t.into())) + // Standard Error: 154_973 + .saturating_add(Weight::from_ref_time(121_130_672).saturating_mul(i.into())) + // Standard Error: 154_973 + .saturating_add(Weight::from_ref_time(121_554_853).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(249_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(t.into()))) - .saturating_add(RocksDbWeight::get().writes(247)) + .saturating_add(RocksDbWeight::get().writes(247_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(t.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_sha2_256(r: u32, ) -> Weight { - // Minimum execution time: 289_275 nanoseconds. - Weight::from_ref_time(297_803_961) - // Standard Error: 303_405 - .saturating_add(Weight::from_ref_time(40_800_138).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `839 + r * (642 ±0)` + // Estimated: `0` + // Minimum execution time: 280_949 nanoseconds. + Weight::from_ref_time(286_538_475) + // Standard Error: 124_866 + .saturating_add(Weight::from_ref_time(42_531_824).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_sha2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 336_077 nanoseconds. - Weight::from_ref_time(336_846_000) - // Standard Error: 51_610 - .saturating_add(Weight::from_ref_time(322_208_787).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1641` + // Estimated: `0` + // Minimum execution time: 328_414 nanoseconds. + Weight::from_ref_time(329_293_000) + // Standard Error: 50_816 + .saturating_add(Weight::from_ref_time(318_312_506).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_keccak_256(r: u32, ) -> Weight { - // Minimum execution time: 290_189 nanoseconds. - Weight::from_ref_time(298_454_259) - // Standard Error: 252_946 - .saturating_add(Weight::from_ref_time(55_034_240).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `841 + r * (642 ±0)` + // Estimated: `0` + // Minimum execution time: 282_208 nanoseconds. + Weight::from_ref_time(286_848_187) + // Standard Error: 106_214 + .saturating_add(Weight::from_ref_time(56_342_512).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_keccak_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 350_030 nanoseconds. - Weight::from_ref_time(351_356_000) - // Standard Error: 57_422 - .saturating_add(Weight::from_ref_time(256_912_844).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1643` + // Estimated: `0` + // Minimum execution time: 342_478 nanoseconds. + Weight::from_ref_time(342_947_000) + // Standard Error: 60_809 + .saturating_add(Weight::from_ref_time(255_492_149).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_256(r: u32, ) -> Weight { - // Minimum execution time: 288_480 nanoseconds. - Weight::from_ref_time(297_613_263) - // Standard Error: 456_736 - .saturating_add(Weight::from_ref_time(38_100_936).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `841 + r * (642 ±0)` + // Estimated: `0` + // Minimum execution time: 279_059 nanoseconds. + Weight::from_ref_time(285_413_659) + // Standard Error: 123_081 + .saturating_add(Weight::from_ref_time(33_154_840).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_256_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 321_195 nanoseconds. - Weight::from_ref_time(325_561_000) - // Standard Error: 46_289 - .saturating_add(Weight::from_ref_time(99_536_902).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1643` + // Estimated: `0` + // Minimum execution time: 317_518 nanoseconds. + Weight::from_ref_time(318_178_000) + // Standard Error: 60_074 + .saturating_add(Weight::from_ref_time(99_403_819).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_hash_blake2_128(r: u32, ) -> Weight { - // Minimum execution time: 287_659 nanoseconds. - Weight::from_ref_time(295_963_340) - // Standard Error: 433_889 - .saturating_add(Weight::from_ref_time(30_251_859).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `841 + r * (679 ±0)` + // Estimated: `0` + // Minimum execution time: 280_145 nanoseconds. + Weight::from_ref_time(285_483_032) + // Standard Error: 106_113 + .saturating_add(Weight::from_ref_time(33_475_067).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `n` is `[0, 1024]`. fn seal_hash_blake2_128_per_kb(n: u32, ) -> Weight { - // Minimum execution time: 324_298 nanoseconds. - Weight::from_ref_time(325_738_000) - // Standard Error: 48_563 - .saturating_add(Weight::from_ref_time(99_479_838).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1643` + // Estimated: `0` + // Minimum execution time: 318_141 nanoseconds. + Weight::from_ref_time(318_699_000) + // Standard Error: 55_136 + .saturating_add(Weight::from_ref_time(99_275_434).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_recover(r: u32, ) -> Weight { - // Minimum execution time: 294_257 nanoseconds. - Weight::from_ref_time(299_467_620) - // Standard Error: 589_749 - .saturating_add(Weight::from_ref_time(3_015_389_579).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `885 + r * (6083 ±0)` + // Estimated: `0` + // Minimum execution time: 282_474 nanoseconds. + Weight::from_ref_time(288_078_802) + // Standard Error: 302_968 + .saturating_add(Weight::from_ref_time(2_944_967_597).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 1]`. fn seal_ecdsa_to_eth_address(r: u32, ) -> Weight { - // Minimum execution time: 289_480 nanoseconds. - Weight::from_ref_time(298_762_412) - // Standard Error: 397_004 - .saturating_add(Weight::from_ref_time(743_937_087).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts OwnerInfoOf (r:16 w:16) + // Proof Size summary in bytes: + // Measured: `854 + r * (3362 ±0)` + // Estimated: `0` + // Minimum execution time: 281_514 nanoseconds. + Weight::from_ref_time(287_458_651) + // Standard Error: 146_715 + .saturating_add(Weight::from_ref_time(731_367_948).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1536 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts OwnerInfoOf (r:1536 w:1536) + /// Proof: Contracts OwnerInfoOf (max_values: None, max_size: Some(88), added: 2563, mode: Ignored) + /// Storage: System EventTopics (r:1538 w:1538) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_set_code_hash(r: u32, ) -> Weight { - // Minimum execution time: 293_494 nanoseconds. - Weight::from_ref_time(297_756_000) - // Standard Error: 2_731_227 - .saturating_add(Weight::from_ref_time(1_387_380_436).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Proof Size summary in bytes: + // Measured: `0 + r * (79300 ±0)` + // Estimated: `0` + // Minimum execution time: 282_591 nanoseconds. + Weight::from_ref_time(286_842_000) + // Standard Error: 2_645_254 + .saturating_add(Weight::from_ref_time(1_394_535_676).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((225_u64).saturating_mul(r.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((150_u64).saturating_mul(r.into()))) } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 295_339 nanoseconds. - Weight::from_ref_time(301_577_907) - // Standard Error: 23_836 - .saturating_add(Weight::from_ref_time(10_876_508).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `837 + r * (240 ±0)` + // Estimated: `0` + // Minimum execution time: 286_631 nanoseconds. + Weight::from_ref_time(288_787_650) + // Standard Error: 29_802 + .saturating_add(Weight::from_ref_time(11_115_811).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_account_reentrance_count(r: u32, ) -> Weight { - // Minimum execution time: 297_096 nanoseconds. - Weight::from_ref_time(336_319_823) - // Standard Error: 128_941 - .saturating_add(Weight::from_ref_time(25_211_374).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: System Account (r:1 w:0) - // Storage: Contracts ContractInfoOf (r:1 w:1) - // Storage: Contracts CodeStorage (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) - // Storage: System EventTopics (r:2 w:2) - // Storage: Contracts Nonce (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `2056 + r * (3153 ±0)` + // Estimated: `0` + // Minimum execution time: 287_775 nanoseconds. + Weight::from_ref_time(319_806_123) + // Standard Error: 111_808 + .saturating_add(Weight::from_ref_time(17_641_181).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: Ignored) + /// Storage: Contracts ContractInfoOf (r:1 w:1) + /// Proof: Contracts ContractInfoOf (max_values: None, max_size: Some(258), added: 2733, mode: Ignored) + /// Storage: Contracts CodeStorage (r:1 w:0) + /// Proof: Contracts CodeStorage (max_values: None, max_size: Some(126001), added: 128476, mode: Ignored) + /// Storage: Timestamp Now (r:1 w:0) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: Contracts Nonce (r:1 w:1) + /// Proof: Contracts Nonce (max_values: Some(1), max_size: Some(8), added: 503, mode: Ignored) + /// Storage: System EventTopics (r:2 w:2) + /// Proof Skipped: System EventTopics (max_values: None, max_size: None, mode: Ignored) /// The range of component `r` is `[0, 20]`. fn seal_instantiation_nonce(r: u32, ) -> Weight { - // Minimum execution time: 293_819 nanoseconds. - Weight::from_ref_time(302_765_659) - // Standard Error: 28_518 - .saturating_add(Weight::from_ref_time(9_325_552).saturating_mul(r.into())) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `840 + r * (240 ±0)` + // Estimated: `0` + // Minimum execution time: 285_077 nanoseconds. + Weight::from_ref_time(289_980_475) + // Standard Error: 14_535 + .saturating_add(Weight::from_ref_time(9_295_346).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } /// The range of component `r` is `[0, 50]`. fn instr_i64const(r: u32, ) -> Weight { - // Minimum execution time: 805 nanoseconds. - Weight::from_ref_time(1_002_066) - // Standard Error: 609 - .saturating_add(Weight::from_ref_time(346_608).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 777 nanoseconds. + Weight::from_ref_time(1_014_498) + // Standard Error: 154 + .saturating_add(Weight::from_ref_time(405_551).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64load(r: u32, ) -> Weight { - // Minimum execution time: 917 nanoseconds. - Weight::from_ref_time(1_247_710) - // Standard Error: 1_069 - .saturating_add(Weight::from_ref_time(984_608).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 862 nanoseconds. + Weight::from_ref_time(1_345_826) + // Standard Error: 457 + .saturating_add(Weight::from_ref_time(1_033_909).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64store(r: u32, ) -> Weight { - // Minimum execution time: 917 nanoseconds. - Weight::from_ref_time(1_244_315) - // Standard Error: 524 - .saturating_add(Weight::from_ref_time(882_167).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 892 nanoseconds. + Weight::from_ref_time(1_233_601) + // Standard Error: 341 + .saturating_add(Weight::from_ref_time(885_275).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_select(r: u32, ) -> Weight { - // Minimum execution time: 791 nanoseconds. - Weight::from_ref_time(1_119_053) - // Standard Error: 379 - .saturating_add(Weight::from_ref_time(956_169).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 771 nanoseconds. + Weight::from_ref_time(1_099_906) + // Standard Error: 261 + .saturating_add(Weight::from_ref_time(1_092_031).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_if(r: u32, ) -> Weight { - // Minimum execution time: 782 nanoseconds. - Weight::from_ref_time(773_373) - // Standard Error: 463 - .saturating_add(Weight::from_ref_time(1_299_306).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 785 nanoseconds. + Weight::from_ref_time(929_328) + // Standard Error: 333 + .saturating_add(Weight::from_ref_time(1_374_749).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br(r: u32, ) -> Weight { - // Minimum execution time: 743 nanoseconds. - Weight::from_ref_time(1_273_896) - // Standard Error: 925 - .saturating_add(Weight::from_ref_time(527_015).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 772 nanoseconds. + Weight::from_ref_time(979_702) + // Standard Error: 351 + .saturating_add(Weight::from_ref_time(621_385).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_if(r: u32, ) -> Weight { - // Minimum execution time: 761 nanoseconds. - Weight::from_ref_time(929_565) - // Standard Error: 1_275 - .saturating_add(Weight::from_ref_time(805_592).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_303_783) + // Standard Error: 1_556 + .saturating_add(Weight::from_ref_time(841_842).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_br_table(r: u32, ) -> Weight { - // Minimum execution time: 813 nanoseconds. - Weight::from_ref_time(703_802) - // Standard Error: 1_665 - .saturating_add(Weight::from_ref_time(1_074_321).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 792 nanoseconds. + Weight::from_ref_time(1_093_901) + // Standard Error: 1_383 + .saturating_add(Weight::from_ref_time(1_145_435).saturating_mul(r.into())) } /// The range of component `e` is `[1, 256]`. fn instr_br_table_per_entry(e: u32, ) -> Weight { - // Minimum execution time: 2_347 nanoseconds. - Weight::from_ref_time(2_752_638) - // Standard Error: 69 - .saturating_add(Weight::from_ref_time(4_771).saturating_mul(e.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_526 nanoseconds. + Weight::from_ref_time(2_872_561) + // Standard Error: 60 + .saturating_add(Weight::from_ref_time(4_365).saturating_mul(e.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call(r: u32, ) -> Weight { - // Minimum execution time: 826 nanoseconds. - Weight::from_ref_time(1_784_596) - // Standard Error: 1_646 - .saturating_add(Weight::from_ref_time(2_189_993).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 834 nanoseconds. + Weight::from_ref_time(1_431_876) + // Standard Error: 1_448 + .saturating_add(Weight::from_ref_time(2_268_715).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_call_indirect(r: u32, ) -> Weight { - // Minimum execution time: 926 nanoseconds. - Weight::from_ref_time(1_898_358) - // Standard Error: 2_678 - .saturating_add(Weight::from_ref_time(2_811_379).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 920 nanoseconds. + Weight::from_ref_time(2_167_004) + // Standard Error: 2_060 + .saturating_add(Weight::from_ref_time(2_921_443).saturating_mul(r.into())) } /// The range of component `p` is `[0, 128]`. fn instr_call_indirect_per_param(p: u32, ) -> Weight { - // Minimum execution time: 4_428 nanoseconds. - Weight::from_ref_time(5_257_445) - // Standard Error: 306 - .saturating_add(Weight::from_ref_time(178_882).saturating_mul(p.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_624 nanoseconds. + Weight::from_ref_time(5_534_325) + // Standard Error: 326 + .saturating_add(Weight::from_ref_time(184_307).saturating_mul(p.into())) } /// The range of component `l` is `[0, 1024]`. fn instr_call_per_local(l: u32, ) -> Weight { - // Minimum execution time: 2_945 nanoseconds. - Weight::from_ref_time(4_240_619) - // Standard Error: 39 - .saturating_add(Weight::from_ref_time(46_640).saturating_mul(l.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_062 nanoseconds. + Weight::from_ref_time(4_432_879) + // Standard Error: 64 + .saturating_add(Weight::from_ref_time(46_196).saturating_mul(l.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_get(r: u32, ) -> Weight { - // Minimum execution time: 2_204 nanoseconds. - Weight::from_ref_time(2_430_272) - // Standard Error: 270 - .saturating_add(Weight::from_ref_time(365_718).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_036 nanoseconds. + Weight::from_ref_time(2_318_877) + // Standard Error: 172 + .saturating_add(Weight::from_ref_time(500_498).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_set(r: u32, ) -> Weight { - // Minimum execution time: 2_117 nanoseconds. - Weight::from_ref_time(2_429_354) - // Standard Error: 240 - .saturating_add(Weight::from_ref_time(381_830).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_027 nanoseconds. + Weight::from_ref_time(2_355_900) + // Standard Error: 220 + .saturating_add(Weight::from_ref_time(461_393).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_local_tee(r: u32, ) -> Weight { - // Minimum execution time: 2_123 nanoseconds. - Weight::from_ref_time(2_460_016) - // Standard Error: 262 - .saturating_add(Weight::from_ref_time(526_554).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_038 nanoseconds. + Weight::from_ref_time(2_350_330) + // Standard Error: 224 + .saturating_add(Weight::from_ref_time(586_808).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_get(r: u32, ) -> Weight { - // Minimum execution time: 892 nanoseconds. - Weight::from_ref_time(1_234_618) - // Standard Error: 485 - .saturating_add(Weight::from_ref_time(813_721).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 897 nanoseconds. + Weight::from_ref_time(1_267_115) + // Standard Error: 189 + .saturating_add(Weight::from_ref_time(884_926).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_global_set(r: u32, ) -> Weight { - // Minimum execution time: 901 nanoseconds. - Weight::from_ref_time(1_182_838) - // Standard Error: 482 - .saturating_add(Weight::from_ref_time(831_308).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 892 nanoseconds. + Weight::from_ref_time(1_202_122) + // Standard Error: 286 + .saturating_add(Weight::from_ref_time(885_157).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_memory_current(r: u32, ) -> Weight { - // Minimum execution time: 929 nanoseconds. - Weight::from_ref_time(1_221_388) - // Standard Error: 434 - .saturating_add(Weight::from_ref_time(693_301).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 852 nanoseconds. + Weight::from_ref_time(1_132_479) + // Standard Error: 224 + .saturating_add(Weight::from_ref_time(719_603).saturating_mul(r.into())) } /// The range of component `r` is `[0, 1]`. fn instr_memory_grow(r: u32, ) -> Weight { - // Minimum execution time: 808 nanoseconds. - Weight::from_ref_time(906_944) - // Standard Error: 6_164 - .saturating_add(Weight::from_ref_time(187_445_255).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 786 nanoseconds. + Weight::from_ref_time(874_044) + // Standard Error: 91_309 + .saturating_add(Weight::from_ref_time(181_849_955).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64clz(r: u32, ) -> Weight { - // Minimum execution time: 807 nanoseconds. - Weight::from_ref_time(1_064_776) - // Standard Error: 287 - .saturating_add(Weight::from_ref_time(507_278).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 763 nanoseconds. + Weight::from_ref_time(1_055_236) + // Standard Error: 207 + .saturating_add(Weight::from_ref_time(554_985).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ctz(r: u32, ) -> Weight { - // Minimum execution time: 776 nanoseconds. - Weight::from_ref_time(1_033_205) - // Standard Error: 443 - .saturating_add(Weight::from_ref_time(512_445).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 756 nanoseconds. + Weight::from_ref_time(1_053_050) + // Standard Error: 165 + .saturating_add(Weight::from_ref_time(555_401).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64popcnt(r: u32, ) -> Weight { - // Minimum execution time: 909 nanoseconds. - Weight::from_ref_time(1_089_083) - // Standard Error: 335 - .saturating_add(Weight::from_ref_time(510_392).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 791 nanoseconds. + Weight::from_ref_time(1_080_240) + // Standard Error: 164 + .saturating_add(Weight::from_ref_time(554_698).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eqz(r: u32, ) -> Weight { - // Minimum execution time: 791 nanoseconds. - Weight::from_ref_time(1_063_118) - // Standard Error: 210 - .saturating_add(Weight::from_ref_time(522_817).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_074_739) + // Standard Error: 178 + .saturating_add(Weight::from_ref_time(565_891).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendsi32(r: u32, ) -> Weight { - // Minimum execution time: 789 nanoseconds. - Weight::from_ref_time(1_056_006) - // Standard Error: 240 - .saturating_add(Weight::from_ref_time(505_198).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 781 nanoseconds. + Weight::from_ref_time(1_077_122) + // Standard Error: 177 + .saturating_add(Weight::from_ref_time(548_846).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64extendui32(r: u32, ) -> Weight { - // Minimum execution time: 804 nanoseconds. - Weight::from_ref_time(1_087_882) - // Standard Error: 234 - .saturating_add(Weight::from_ref_time(503_830).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 793 nanoseconds. + Weight::from_ref_time(1_086_278) + // Standard Error: 163 + .saturating_add(Weight::from_ref_time(548_765).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i32wrapi64(r: u32, ) -> Weight { - // Minimum execution time: 756 nanoseconds. - Weight::from_ref_time(1_050_994) - // Standard Error: 172 - .saturating_add(Weight::from_ref_time(503_343).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 769 nanoseconds. + Weight::from_ref_time(1_096_044) + // Standard Error: 134 + .saturating_add(Weight::from_ref_time(547_353).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64eq(r: u32, ) -> Weight { - // Minimum execution time: 775 nanoseconds. - Weight::from_ref_time(1_061_228) - // Standard Error: 232 - .saturating_add(Weight::from_ref_time(730_751).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_072_610) + // Standard Error: 161 + .saturating_add(Weight::from_ref_time(774_895).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ne(r: u32, ) -> Weight { - // Minimum execution time: 809 nanoseconds. - Weight::from_ref_time(1_080_957) - // Standard Error: 320 - .saturating_add(Weight::from_ref_time(732_246).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 751 nanoseconds. + Weight::from_ref_time(1_038_676) + // Standard Error: 158 + .saturating_add(Weight::from_ref_time(775_194).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64lts(r: u32, ) -> Weight { - // Minimum execution time: 808 nanoseconds. - Weight::from_ref_time(1_055_752) - // Standard Error: 496 - .saturating_add(Weight::from_ref_time(740_084).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_089_712) + // Standard Error: 144 + .saturating_add(Weight::from_ref_time(774_377).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ltu(r: u32, ) -> Weight { - // Minimum execution time: 792 nanoseconds. - Weight::from_ref_time(1_111_972) - // Standard Error: 270 - .saturating_add(Weight::from_ref_time(741_581).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 758 nanoseconds. + Weight::from_ref_time(1_078_460) + // Standard Error: 180 + .saturating_add(Weight::from_ref_time(779_861).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gts(r: u32, ) -> Weight { - // Minimum execution time: 862 nanoseconds. - Weight::from_ref_time(1_111_246) - // Standard Error: 263 - .saturating_add(Weight::from_ref_time(746_026).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 758 nanoseconds. + Weight::from_ref_time(1_089_007) + // Standard Error: 164 + .saturating_add(Weight::from_ref_time(779_372).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64gtu(r: u32, ) -> Weight { - // Minimum execution time: 810 nanoseconds. - Weight::from_ref_time(1_094_933) - // Standard Error: 271 - .saturating_add(Weight::from_ref_time(743_645).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 772 nanoseconds. + Weight::from_ref_time(1_077_512) + // Standard Error: 165 + .saturating_add(Weight::from_ref_time(779_513).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64les(r: u32, ) -> Weight { - // Minimum execution time: 769 nanoseconds. - Weight::from_ref_time(819_933) - // Standard Error: 4_528 - .saturating_add(Weight::from_ref_time(751_599).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 760 nanoseconds. + Weight::from_ref_time(1_078_546) + // Standard Error: 168 + .saturating_add(Weight::from_ref_time(779_138).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64leu(r: u32, ) -> Weight { - // Minimum execution time: 797 nanoseconds. - Weight::from_ref_time(1_107_352) - // Standard Error: 344 - .saturating_add(Weight::from_ref_time(738_684).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 757 nanoseconds. + Weight::from_ref_time(1_080_251) + // Standard Error: 168 + .saturating_add(Weight::from_ref_time(779_391).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64ges(r: u32, ) -> Weight { - // Minimum execution time: 784 nanoseconds. - Weight::from_ref_time(1_068_487) - // Standard Error: 3_796 - .saturating_add(Weight::from_ref_time(741_207).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 786 nanoseconds. + Weight::from_ref_time(1_072_690) + // Standard Error: 219 + .saturating_add(Weight::from_ref_time(780_381).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64geu(r: u32, ) -> Weight { - // Minimum execution time: 813 nanoseconds. - Weight::from_ref_time(1_067_278) - // Standard Error: 459 - .saturating_add(Weight::from_ref_time(737_841).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 771 nanoseconds. + Weight::from_ref_time(1_063_735) + // Standard Error: 162 + .saturating_add(Weight::from_ref_time(779_906).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64add(r: u32, ) -> Weight { - // Minimum execution time: 798 nanoseconds. - Weight::from_ref_time(1_100_254) - // Standard Error: 297 - .saturating_add(Weight::from_ref_time(717_622).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 785 nanoseconds. + Weight::from_ref_time(1_059_585) + // Standard Error: 155 + .saturating_add(Weight::from_ref_time(756_828).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64sub(r: u32, ) -> Weight { - // Minimum execution time: 778 nanoseconds. - Weight::from_ref_time(1_063_748) - // Standard Error: 378 - .saturating_add(Weight::from_ref_time(713_577).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 800 nanoseconds. + Weight::from_ref_time(1_066_659) + // Standard Error: 154 + .saturating_add(Weight::from_ref_time(754_318).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64mul(r: u32, ) -> Weight { - // Minimum execution time: 780 nanoseconds. - Weight::from_ref_time(1_088_755) - // Standard Error: 316 - .saturating_add(Weight::from_ref_time(714_127).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 769 nanoseconds. + Weight::from_ref_time(1_078_854) + // Standard Error: 172 + .saturating_add(Weight::from_ref_time(754_183).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divs(r: u32, ) -> Weight { - // Minimum execution time: 776 nanoseconds. - Weight::from_ref_time(1_062_591) - // Standard Error: 610 - .saturating_add(Weight::from_ref_time(1_355_430).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 770 nanoseconds. + Weight::from_ref_time(1_057_476) + // Standard Error: 191 + .saturating_add(Weight::from_ref_time(1_443_902).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64divu(r: u32, ) -> Weight { - // Minimum execution time: 801 nanoseconds. - Weight::from_ref_time(1_092_395) - // Standard Error: 423 - .saturating_add(Weight::from_ref_time(1_282_356).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 764 nanoseconds. + Weight::from_ref_time(1_063_821) + // Standard Error: 193 + .saturating_add(Weight::from_ref_time(1_324_496).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rems(r: u32, ) -> Weight { - // Minimum execution time: 822 nanoseconds. - Weight::from_ref_time(1_083_079) - // Standard Error: 562 - .saturating_add(Weight::from_ref_time(1_398_522).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 747 nanoseconds. + Weight::from_ref_time(1_093_209) + // Standard Error: 270 + .saturating_add(Weight::from_ref_time(1_447_180).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64remu(r: u32, ) -> Weight { - // Minimum execution time: 798 nanoseconds. - Weight::from_ref_time(1_088_997) - // Standard Error: 401 - .saturating_add(Weight::from_ref_time(1_283_442).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 805 nanoseconds. + Weight::from_ref_time(1_033_953) + // Standard Error: 152 + .saturating_add(Weight::from_ref_time(1_336_911).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64and(r: u32, ) -> Weight { - // Minimum execution time: 815 nanoseconds. - Weight::from_ref_time(1_081_903) - // Standard Error: 264 - .saturating_add(Weight::from_ref_time(718_069).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 766 nanoseconds. + Weight::from_ref_time(1_059_430) + // Standard Error: 160 + .saturating_add(Weight::from_ref_time(757_265).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64or(r: u32, ) -> Weight { - // Minimum execution time: 813 nanoseconds. - Weight::from_ref_time(1_091_426) - // Standard Error: 296 - .saturating_add(Weight::from_ref_time(717_894).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 760 nanoseconds. + Weight::from_ref_time(1_077_376) + // Standard Error: 160 + .saturating_add(Weight::from_ref_time(755_800).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64xor(r: u32, ) -> Weight { - // Minimum execution time: 794 nanoseconds. - Weight::from_ref_time(1_040_144) - // Standard Error: 400 - .saturating_add(Weight::from_ref_time(719_886).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 798 nanoseconds. + Weight::from_ref_time(1_070_570) + // Standard Error: 157 + .saturating_add(Weight::from_ref_time(756_839).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shl(r: u32, ) -> Weight { - // Minimum execution time: 774 nanoseconds. - Weight::from_ref_time(1_092_466) - // Standard Error: 4_173 - .saturating_add(Weight::from_ref_time(739_873).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 761 nanoseconds. + Weight::from_ref_time(1_074_645) + // Standard Error: 169 + .saturating_add(Weight::from_ref_time(771_486).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shrs(r: u32, ) -> Weight { - // Minimum execution time: 793 nanoseconds. - Weight::from_ref_time(1_105_611) - // Standard Error: 394 - .saturating_add(Weight::from_ref_time(735_358).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 779 nanoseconds. + Weight::from_ref_time(1_107_671) + // Standard Error: 185 + .saturating_add(Weight::from_ref_time(769_168).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64shru(r: u32, ) -> Weight { - // Minimum execution time: 805 nanoseconds. - Weight::from_ref_time(1_130_462) - // Standard Error: 327 - .saturating_add(Weight::from_ref_time(734_198).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 755 nanoseconds. + Weight::from_ref_time(1_075_769) + // Standard Error: 164 + .saturating_add(Weight::from_ref_time(770_334).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotl(r: u32, ) -> Weight { - // Minimum execution time: 831 nanoseconds. - Weight::from_ref_time(1_118_894) - // Standard Error: 389 - .saturating_add(Weight::from_ref_time(733_834).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 767 nanoseconds. + Weight::from_ref_time(608_749) + // Standard Error: 2_059 + .saturating_add(Weight::from_ref_time(804_228).saturating_mul(r.into())) } /// The range of component `r` is `[0, 50]`. fn instr_i64rotr(r: u32, ) -> Weight { - // Minimum execution time: 772 nanoseconds. - Weight::from_ref_time(1_123_733) - // Standard Error: 337 - .saturating_add(Weight::from_ref_time(733_923).saturating_mul(r.into())) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 779 nanoseconds. + Weight::from_ref_time(1_054_998) + // Standard Error: 191 + .saturating_add(Weight::from_ref_time(770_225).saturating_mul(r.into())) } } diff --git a/frame/conviction-voting/src/weights.rs b/frame/conviction-voting/src/weights.rs index e50842449f..c5c7123837 100644 --- a/frame/conviction-voting/src/weights.rs +++ b/frame/conviction-voting/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_conviction_voting //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -59,164 +60,262 @@ pub trait WeightInfo { /// Weights for pallet_conviction_voting using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_new() -> Weight { - // Minimum execution time: 131_633 nanoseconds. - Weight::from_ref_time(132_742_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Proof Size summary in bytes: + // Measured: `13168` + // Estimated: `257859` + // Minimum execution time: 85_569 nanoseconds. + Weight::from_parts(86_492_000, 257859) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_existing() -> Weight { - // Minimum execution time: 176_240 nanoseconds. - Weight::from_ref_time(183_274_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) + // Proof Size summary in bytes: + // Measured: `20342` + // Estimated: `257859` + // Minimum execution time: 212_727 nanoseconds. + Weight::from_parts(213_741_000, 257859) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn remove_vote() -> Weight { - // Minimum execution time: 158_880 nanoseconds. - Weight::from_ref_time(164_648_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `20062` + // Estimated: `251551` + // Minimum execution time: 200_513 nanoseconds. + Weight::from_parts(201_589_000, 251551) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn remove_other_vote() -> Weight { - // Minimum execution time: 60_330 nanoseconds. - Weight::from_ref_time(61_588_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `12738` + // Estimated: `32557` + // Minimum execution time: 43_083 nanoseconds. + Weight::from_parts(43_763_000, 32557) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: ConvictionVoting VotingFor (r:2 w:2) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: ConvictionVoting VotingFor (r:2 w:2) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `r` is `[0, 1]`. fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 63_088 nanoseconds. - Weight::from_ref_time(67_803_536 as u64) - // Standard Error: 197_102 - .saturating_add(Weight::from_ref_time(31_557_563 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + // Proof Size summary in bytes: + // Measured: `272 + r * (1689 ±0)` + // Estimated: `176657 + r * (110917 ±0)` + // Minimum execution time: 33_246 nanoseconds. + Weight::from_parts(34_560_391, 176657) + // Standard Error: 63_925 + .saturating_add(Weight::from_ref_time(34_500_408).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(110917).saturating_mul(r.into())) } - // Storage: ConvictionVoting VotingFor (r:2 w:2) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: ConvictionVoting VotingFor (r:2 w:2) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `r` is `[0, 1]`. fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 45_150 nanoseconds. - Weight::from_ref_time(51_547_530 as u64) - // Standard Error: 771_127 - .saturating_add(Weight::from_ref_time(26_927_969 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + // Proof Size summary in bytes: + // Measured: `470 + r * (1407 ±0)` + // Estimated: `170349 + r * (110917 ±0)` + // Minimum execution time: 20_508 nanoseconds. + Weight::from_parts(21_240_024, 170349) + // Standard Error: 37_314 + .saturating_add(Weight::from_ref_time(30_890_875).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(110917).saturating_mul(r.into())) } - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unlock() -> Weight { - // Minimum execution time: 75_067 nanoseconds. - Weight::from_ref_time(76_888_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `11797` + // Estimated: `36024` + // Minimum execution time: 50_305 nanoseconds. + Weight::from_parts(51_226_000, 36024) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_new() -> Weight { - // Minimum execution time: 131_633 nanoseconds. - Weight::from_ref_time(132_742_000 as u64) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) + // Proof Size summary in bytes: + // Measured: `13168` + // Estimated: `257859` + // Minimum execution time: 85_569 nanoseconds. + Weight::from_parts(86_492_000, 257859) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote_existing() -> Weight { - // Minimum execution time: 176_240 nanoseconds. - Weight::from_ref_time(183_274_000 as u64) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) + // Proof Size summary in bytes: + // Measured: `20342` + // Estimated: `257859` + // Minimum execution time: 212_727 nanoseconds. + Weight::from_parts(213_741_000, 257859) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn remove_vote() -> Weight { - // Minimum execution time: 158_880 nanoseconds. - Weight::from_ref_time(164_648_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `20062` + // Estimated: `251551` + // Minimum execution time: 200_513 nanoseconds. + Weight::from_parts(201_589_000, 251551) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:0) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn remove_other_vote() -> Weight { - // Minimum execution time: 60_330 nanoseconds. - Weight::from_ref_time(61_588_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `12738` + // Estimated: `32557` + // Minimum execution time: 43_083 nanoseconds. + Weight::from_parts(43_763_000, 32557) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: ConvictionVoting VotingFor (r:2 w:2) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: ConvictionVoting VotingFor (r:2 w:2) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `r` is `[0, 1]`. fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 63_088 nanoseconds. - Weight::from_ref_time(67_803_536 as u64) - // Standard Error: 197_102 - .saturating_add(Weight::from_ref_time(31_557_563 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + // Proof Size summary in bytes: + // Measured: `272 + r * (1689 ±0)` + // Estimated: `176657 + r * (110917 ±0)` + // Minimum execution time: 33_246 nanoseconds. + Weight::from_parts(34_560_391, 176657) + // Standard Error: 63_925 + .saturating_add(Weight::from_ref_time(34_500_408).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(110917).saturating_mul(r.into())) } - // Storage: ConvictionVoting VotingFor (r:2 w:2) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: ConvictionVoting VotingFor (r:2 w:2) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `r` is `[0, 1]`. fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 45_150 nanoseconds. - Weight::from_ref_time(51_547_530 as u64) - // Standard Error: 771_127 - .saturating_add(Weight::from_ref_time(26_927_969 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + // Proof Size summary in bytes: + // Measured: `470 + r * (1407 ±0)` + // Estimated: `170349 + r * (110917 ±0)` + // Minimum execution time: 20_508 nanoseconds. + Weight::from_parts(21_240_024, 170349) + // Standard Error: 37_314 + .saturating_add(Weight::from_ref_time(30_890_875).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(110917).saturating_mul(r.into())) } - // Storage: ConvictionVoting VotingFor (r:1 w:1) - // Storage: ConvictionVoting ClassLocksFor (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: ConvictionVoting VotingFor (r:1 w:1) + /// Proof: ConvictionVoting VotingFor (max_values: None, max_size: Some(27241), added: 29716, mode: MaxEncodedLen) + /// Storage: ConvictionVoting ClassLocksFor (r:1 w:1) + /// Proof: ConvictionVoting ClassLocksFor (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn unlock() -> Weight { - // Minimum execution time: 75_067 nanoseconds. - Weight::from_ref_time(76_888_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `11797` + // Estimated: `36024` + // Minimum execution time: 50_305 nanoseconds. + Weight::from_parts(51_226_000, 36024) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } } diff --git a/frame/democracy/src/weights.rs b/frame/democracy/src/weights.rs index db3969d400..985fe8fbde 100644 --- a/frame/democracy/src/weights.rs +++ b/frame/democracy/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_democracy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -74,438 +75,692 @@ pub trait WeightInfo { /// Weights for pallet_democracy using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Democracy PublicPropCount (r:1 w:1) - // Storage: Democracy PublicProps (r:1 w:1) - // Storage: Democracy Blacklist (r:1 w:0) - // Storage: Democracy DepositOf (r:0 w:1) + /// Storage: Democracy PublicPropCount (r:1 w:1) + /// Proof: Democracy PublicPropCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy PublicProps (r:1 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:1 w:0) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) + /// Storage: Democracy DepositOf (r:0 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn propose() -> Weight { - // Minimum execution time: 56_868 nanoseconds. - Weight::from_ref_time(57_788_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy DepositOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4864` + // Estimated: `23409` + // Minimum execution time: 34_509 nanoseconds. + Weight::from_parts(34_781_000, 23409) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy DepositOf (r:1 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn second() -> Weight { - // Minimum execution time: 49_328 nanoseconds. - Weight::from_ref_time(49_764_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3620` + // Estimated: `5705` + // Minimum execution time: 31_151 nanoseconds. + Weight::from_parts(31_566_000, 5705) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_new() -> Weight { - // Minimum execution time: 60_323 nanoseconds. - Weight::from_ref_time(61_389_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3555` + // Estimated: `12720` + // Minimum execution time: 42_618 nanoseconds. + Weight::from_parts(43_231_000, 12720) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_existing() -> Weight { - // Minimum execution time: 60_612 nanoseconds. - Weight::from_ref_time(61_282_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy Cancellations (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3577` + // Estimated: `12720` + // Minimum execution time: 42_875 nanoseconds. + Weight::from_parts(43_338_000, 12720) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy Cancellations (r:1 w:1) + /// Proof: Democracy Cancellations (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) fn emergency_cancel() -> Weight { - // Minimum execution time: 24_780 nanoseconds. - Weight::from_ref_time(25_194_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Democracy PublicProps (r:1 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy Blacklist (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `320` + // Estimated: `5184` + // Minimum execution time: 16_543 nanoseconds. + Weight::from_parts(16_762_000, 5184) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy DepositOf (r:1 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:0 w:1) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn blacklist() -> Weight { - // Minimum execution time: 85_177 nanoseconds. - Weight::from_ref_time(91_733_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) - } - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy Blacklist (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `5958` + // Estimated: `28808` + // Minimum execution time: 70_135 nanoseconds. + Weight::from_parts(70_616_000, 28808) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:1 w:0) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn external_propose() -> Weight { - // Minimum execution time: 19_483 nanoseconds. - Weight::from_ref_time(19_914_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy NextExternal (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `3448` + // Estimated: `6340` + // Minimum execution time: 12_580 nanoseconds. + Weight::from_parts(12_987_000, 6340) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:0 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) fn external_propose_majority() -> Weight { - // Minimum execution time: 4_963 nanoseconds. - Weight::from_ref_time(5_250_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy NextExternal (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_320 nanoseconds. + Weight::from_ref_time(3_513_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:0 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) fn external_propose_default() -> Weight { - // Minimum execution time: 5_075 nanoseconds. - Weight::from_ref_time(5_187_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy ReferendumCount (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_407 nanoseconds. + Weight::from_ref_time(3_565_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumCount (r:1 w:1) + /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:0 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn fast_track() -> Weight { - // Minimum execution time: 23_956 nanoseconds. - Weight::from_ref_time(24_814_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy Blacklist (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `1126` + // Minimum execution time: 16_831 nanoseconds. + Weight::from_parts(17_155_000, 1126) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:1 w:1) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn veto_external() -> Weight { - // Minimum execution time: 31_472 nanoseconds. - Weight::from_ref_time(31_770_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Democracy PublicProps (r:1 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3477` + // Estimated: `6340` + // Minimum execution time: 22_072 nanoseconds. + Weight::from_parts(22_517_000, 6340) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy DepositOf (r:1 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn cancel_proposal() -> Weight { - // Minimum execution time: 73_811 nanoseconds. - Weight::from_ref_time(78_943_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `5837` + // Estimated: `25505` + // Minimum execution time: 56_925 nanoseconds. + Weight::from_parts(57_253_000, 25505) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:0 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn cancel_referendum() -> Weight { - // Minimum execution time: 16_074 nanoseconds. - Weight::from_ref_time(16_409_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy LowestUnbaked (r:1 w:1) - // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_582 nanoseconds. + Weight::from_ref_time(8_754_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy LowestUnbaked (r:1 w:1) + /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumCount (r:1 w:0) + /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:0) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - // Minimum execution time: 7_430 nanoseconds. - Weight::from_ref_time(12_086_064 as u64) - // Standard Error: 3_474 - .saturating_add(Weight::from_ref_time(2_283_457 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy LowestUnbaked (r:1 w:1) - // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy LastTabledWasExternal (r:1 w:0) - // Storage: Democracy NextExternal (r:1 w:0) - // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Proof Size summary in bytes: + // Measured: `207 + r * (117 ±0)` + // Estimated: `998 + r * (2676 ±0)` + // Minimum execution time: 6_665 nanoseconds. + Weight::from_parts(9_219_932, 998) + // Standard Error: 4_236 + .saturating_add(Weight::from_ref_time(2_194_623).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy LowestUnbaked (r:1 w:1) + /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumCount (r:1 w:0) + /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy LastTabledWasExternal (r:1 w:0) + /// Proof: Democracy LastTabledWasExternal (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Democracy NextExternal (r:1 w:0) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy PublicProps (r:1 w:0) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:0) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - // Minimum execution time: 9_882 nanoseconds. - Weight::from_ref_time(14_566_711 as u64) - // Standard Error: 3_354 - .saturating_add(Weight::from_ref_time(2_282_038 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy VotingOf (r:3 w:3) - // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `207 + r * (117 ±0)` + // Estimated: `19318 + r * (2676 ±0)` + // Minimum execution time: 9_842 nanoseconds. + Weight::from_parts(11_932_535, 19318) + // Standard Error: 4_413 + .saturating_add(Weight::from_ref_time(2_199_644).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy VotingOf (r:3 w:3) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:99) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 48_840 nanoseconds. - Weight::from_ref_time(56_403_092 as u64) - // Standard Error: 6_093 - .saturating_add(Weight::from_ref_time(3_344_243 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) - } - // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `948 + r * (139 ±0)` + // Estimated: `22584 + r * (2676 ±0)` + // Minimum execution time: 34_740 nanoseconds. + Weight::from_parts(38_366_374, 22584) + // Standard Error: 4_868 + .saturating_add(Weight::from_ref_time(3_286_516).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy VotingOf (r:2 w:2) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:99) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 30_483 nanoseconds. - Weight::from_ref_time(32_035_405 as u64) - // Standard Error: 4_383 - .saturating_add(Weight::from_ref_time(3_347_667 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(r as u64))) - } - // Storage: Democracy PublicProps (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `547 + r * (139 ±0)` + // Estimated: `12540 + r * (2676 ±0)` + // Minimum execution time: 19_516 nanoseconds. + Weight::from_parts(21_629_605, 12540) + // Standard Error: 4_401 + .saturating_add(Weight::from_ref_time(3_238_187).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy PublicProps (r:0 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) fn clear_public_proposals() -> Weight { - // Minimum execution time: 6_421 nanoseconds. - Weight::from_ref_time(6_638_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_291 nanoseconds. + Weight::from_ref_time(3_485_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - // Minimum execution time: 30_291 nanoseconds. - Weight::from_ref_time(37_071_950 as u64) - // Standard Error: 1_619 - .saturating_add(Weight::from_ref_time(59_302 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `617` + // Estimated: `12647` + // Minimum execution time: 19_357 nanoseconds. + Weight::from_parts(24_014_517, 12647) + // Standard Error: 994 + .saturating_add(Weight::from_ref_time(17_096).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - // Minimum execution time: 34_888 nanoseconds. - Weight::from_ref_time(36_418_789 as u64) - // Standard Error: 906 - .saturating_add(Weight::from_ref_time(109_602 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `618 + r * (22 ±0)` + // Estimated: `12647` + // Minimum execution time: 22_340 nanoseconds. + Weight::from_parts(23_355_734, 12647) + // Standard Error: 548 + .saturating_add(Weight::from_ref_time(64_308).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_739 nanoseconds. - Weight::from_ref_time(21_004_077 as u64) - // Standard Error: 1_075 - .saturating_add(Weight::from_ref_time(116_457 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `781 + r * (26 ±0)` + // Estimated: `8946` + // Minimum execution time: 14_542 nanoseconds. + Weight::from_parts(16_411_916, 8946) + // Standard Error: 839 + .saturating_add(Weight::from_ref_time(73_268).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_514 nanoseconds. - Weight::from_ref_time(21_030_667 as u64) - // Standard Error: 1_102 - .saturating_add(Weight::from_ref_time(118_039 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `781 + r * (26 ±0)` + // Estimated: `8946` + // Minimum execution time: 14_463 nanoseconds. + Weight::from_parts(16_302_901, 8946) + // Standard Error: 809 + .saturating_add(Weight::from_ref_time(73_692).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Democracy PublicPropCount (r:1 w:1) - // Storage: Democracy PublicProps (r:1 w:1) - // Storage: Democracy Blacklist (r:1 w:0) - // Storage: Democracy DepositOf (r:0 w:1) + /// Storage: Democracy PublicPropCount (r:1 w:1) + /// Proof: Democracy PublicPropCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy PublicProps (r:1 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:1 w:0) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) + /// Storage: Democracy DepositOf (r:0 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn propose() -> Weight { - // Minimum execution time: 56_868 nanoseconds. - Weight::from_ref_time(57_788_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy DepositOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4864` + // Estimated: `23409` + // Minimum execution time: 34_509 nanoseconds. + Weight::from_parts(34_781_000, 23409) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy DepositOf (r:1 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) fn second() -> Weight { - // Minimum execution time: 49_328 nanoseconds. - Weight::from_ref_time(49_764_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3620` + // Estimated: `5705` + // Minimum execution time: 31_151 nanoseconds. + Weight::from_parts(31_566_000, 5705) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_new() -> Weight { - // Minimum execution time: 60_323 nanoseconds. - Weight::from_ref_time(61_389_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3555` + // Estimated: `12720` + // Minimum execution time: 42_618 nanoseconds. + Weight::from_parts(43_231_000, 12720) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn vote_existing() -> Weight { - // Minimum execution time: 60_612 nanoseconds. - Weight::from_ref_time(61_282_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy Cancellations (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3577` + // Estimated: `12720` + // Minimum execution time: 42_875 nanoseconds. + Weight::from_parts(43_338_000, 12720) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy Cancellations (r:1 w:1) + /// Proof: Democracy Cancellations (max_values: None, max_size: Some(33), added: 2508, mode: MaxEncodedLen) fn emergency_cancel() -> Weight { - // Minimum execution time: 24_780 nanoseconds. - Weight::from_ref_time(25_194_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Democracy PublicProps (r:1 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy Blacklist (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `320` + // Estimated: `5184` + // Minimum execution time: 16_543 nanoseconds. + Weight::from_parts(16_762_000, 5184) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy DepositOf (r:1 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:0 w:1) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn blacklist() -> Weight { - // Minimum execution time: 85_177 nanoseconds. - Weight::from_ref_time(91_733_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) - } - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy Blacklist (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `5958` + // Estimated: `28808` + // Minimum execution time: 70_135 nanoseconds. + Weight::from_parts(70_616_000, 28808) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:1 w:0) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn external_propose() -> Weight { - // Minimum execution time: 19_483 nanoseconds. - Weight::from_ref_time(19_914_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy NextExternal (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `3448` + // Estimated: `6340` + // Minimum execution time: 12_580 nanoseconds. + Weight::from_parts(12_987_000, 6340) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:0 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) fn external_propose_majority() -> Weight { - // Minimum execution time: 4_963 nanoseconds. - Weight::from_ref_time(5_250_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy NextExternal (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_320 nanoseconds. + Weight::from_ref_time(3_513_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:0 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) fn external_propose_default() -> Weight { - // Minimum execution time: 5_075 nanoseconds. - Weight::from_ref_time(5_187_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy ReferendumCount (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_407 nanoseconds. + Weight::from_ref_time(3_565_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumCount (r:1 w:1) + /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:0 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn fast_track() -> Weight { - // Minimum execution time: 23_956 nanoseconds. - Weight::from_ref_time(24_814_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy NextExternal (r:1 w:1) - // Storage: Democracy Blacklist (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `1126` + // Minimum execution time: 16_831 nanoseconds. + Weight::from_parts(17_155_000, 1126) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy NextExternal (r:1 w:1) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy Blacklist (r:1 w:1) + /// Proof: Democracy Blacklist (max_values: None, max_size: Some(3238), added: 5713, mode: MaxEncodedLen) fn veto_external() -> Weight { - // Minimum execution time: 31_472 nanoseconds. - Weight::from_ref_time(31_770_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Democracy PublicProps (r:1 w:1) - // Storage: Democracy DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3477` + // Estimated: `6340` + // Minimum execution time: 22_072 nanoseconds. + Weight::from_parts(22_517_000, 6340) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Democracy PublicProps (r:1 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy DepositOf (r:1 w:1) + /// Proof: Democracy DepositOf (max_values: None, max_size: Some(3230), added: 5705, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn cancel_proposal() -> Weight { - // Minimum execution time: 73_811 nanoseconds. - Weight::from_ref_time(78_943_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `5837` + // Estimated: `25505` + // Minimum execution time: 56_925 nanoseconds. + Weight::from_parts(57_253_000, 25505) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:0 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) fn cancel_referendum() -> Weight { - // Minimum execution time: 16_074 nanoseconds. - Weight::from_ref_time(16_409_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy LowestUnbaked (r:1 w:1) - // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_582 nanoseconds. + Weight::from_ref_time(8_754_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy LowestUnbaked (r:1 w:1) + /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumCount (r:1 w:0) + /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:0) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn on_initialize_base(r: u32, ) -> Weight { - // Minimum execution time: 7_430 nanoseconds. - Weight::from_ref_time(12_086_064 as u64) - // Standard Error: 3_474 - .saturating_add(Weight::from_ref_time(2_283_457 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy LowestUnbaked (r:1 w:1) - // Storage: Democracy ReferendumCount (r:1 w:0) - // Storage: Democracy LastTabledWasExternal (r:1 w:0) - // Storage: Democracy NextExternal (r:1 w:0) - // Storage: Democracy PublicProps (r:1 w:0) - // Storage: Democracy ReferendumInfoOf (r:2 w:0) + // Proof Size summary in bytes: + // Measured: `207 + r * (117 ±0)` + // Estimated: `998 + r * (2676 ±0)` + // Minimum execution time: 6_665 nanoseconds. + Weight::from_parts(9_219_932, 998) + // Standard Error: 4_236 + .saturating_add(Weight::from_ref_time(2_194_623).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy LowestUnbaked (r:1 w:1) + /// Proof: Democracy LowestUnbaked (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumCount (r:1 w:0) + /// Proof: Democracy ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Democracy LastTabledWasExternal (r:1 w:0) + /// Proof: Democracy LastTabledWasExternal (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Democracy NextExternal (r:1 w:0) + /// Proof: Democracy NextExternal (max_values: Some(1), max_size: Some(132), added: 627, mode: MaxEncodedLen) + /// Storage: Democracy PublicProps (r:1 w:0) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:0) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn on_initialize_base_with_launch_period(r: u32, ) -> Weight { - // Minimum execution time: 9_882 nanoseconds. - Weight::from_ref_time(14_566_711 as u64) - // Standard Error: 3_354 - .saturating_add(Weight::from_ref_time(2_282_038 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy VotingOf (r:3 w:3) - // Storage: Balances Locks (r:1 w:1) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `207 + r * (117 ±0)` + // Estimated: `19318 + r * (2676 ±0)` + // Minimum execution time: 9_842 nanoseconds. + Weight::from_parts(11_932_535, 19318) + // Standard Error: 4_413 + .saturating_add(Weight::from_ref_time(2_199_644).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy VotingOf (r:3 w:3) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:99) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn delegate(r: u32, ) -> Weight { - // Minimum execution time: 48_840 nanoseconds. - Weight::from_ref_time(56_403_092 as u64) - // Standard Error: 6_093 - .saturating_add(Weight::from_ref_time(3_344_243 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(r as u64))) - } - // Storage: Democracy VotingOf (r:2 w:2) - // Storage: Democracy ReferendumInfoOf (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `948 + r * (139 ±0)` + // Estimated: `22584 + r * (2676 ±0)` + // Minimum execution time: 34_740 nanoseconds. + Weight::from_parts(38_366_374, 22584) + // Standard Error: 4_868 + .saturating_add(Weight::from_ref_time(3_286_516).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy VotingOf (r:2 w:2) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Democracy ReferendumInfoOf (r:99 w:99) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn undelegate(r: u32, ) -> Weight { - // Minimum execution time: 30_483 nanoseconds. - Weight::from_ref_time(32_035_405 as u64) - // Standard Error: 4_383 - .saturating_add(Weight::from_ref_time(3_347_667 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(r as u64))) - } - // Storage: Democracy PublicProps (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `547 + r * (139 ±0)` + // Estimated: `12540 + r * (2676 ±0)` + // Minimum execution time: 19_516 nanoseconds. + Weight::from_parts(21_629_605, 12540) + // Standard Error: 4_401 + .saturating_add(Weight::from_ref_time(3_238_187).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(2676).saturating_mul(r.into())) + } + /// Storage: Democracy PublicProps (r:0 w:1) + /// Proof: Democracy PublicProps (max_values: Some(1), max_size: Some(16702), added: 17197, mode: MaxEncodedLen) fn clear_public_proposals() -> Weight { - // Minimum execution time: 6_421 nanoseconds. - Weight::from_ref_time(6_638_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_291 nanoseconds. + Weight::from_ref_time(3_485_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn unlock_remove(r: u32, ) -> Weight { - // Minimum execution time: 30_291 nanoseconds. - Weight::from_ref_time(37_071_950 as u64) - // Standard Error: 1_619 - .saturating_add(Weight::from_ref_time(59_302 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy VotingOf (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `617` + // Estimated: `12647` + // Minimum execution time: 19_357 nanoseconds. + Weight::from_parts(24_014_517, 12647) + // Standard Error: 994 + .saturating_add(Weight::from_ref_time(17_096).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `r` is `[0, 99]`. fn unlock_set(r: u32, ) -> Weight { - // Minimum execution time: 34_888 nanoseconds. - Weight::from_ref_time(36_418_789 as u64) - // Standard Error: 906 - .saturating_add(Weight::from_ref_time(109_602 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `618 + r * (22 ±0)` + // Estimated: `12647` + // Minimum execution time: 22_340 nanoseconds. + Weight::from_parts(23_355_734, 12647) + // Standard Error: 548 + .saturating_add(Weight::from_ref_time(64_308).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) /// The range of component `r` is `[1, 100]`. fn remove_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_739 nanoseconds. - Weight::from_ref_time(21_004_077 as u64) - // Standard Error: 1_075 - .saturating_add(Weight::from_ref_time(116_457 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Democracy ReferendumInfoOf (r:1 w:1) - // Storage: Democracy VotingOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `781 + r * (26 ±0)` + // Estimated: `8946` + // Minimum execution time: 14_542 nanoseconds. + Weight::from_parts(16_411_916, 8946) + // Standard Error: 839 + .saturating_add(Weight::from_ref_time(73_268).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Democracy ReferendumInfoOf (r:1 w:1) + /// Proof: Democracy ReferendumInfoOf (max_values: None, max_size: Some(201), added: 2676, mode: MaxEncodedLen) + /// Storage: Democracy VotingOf (r:1 w:1) + /// Proof: Democracy VotingOf (max_values: None, max_size: Some(3795), added: 6270, mode: MaxEncodedLen) /// The range of component `r` is `[1, 100]`. fn remove_other_vote(r: u32, ) -> Weight { - // Minimum execution time: 18_514 nanoseconds. - Weight::from_ref_time(21_030_667 as u64) - // Standard Error: 1_102 - .saturating_add(Weight::from_ref_time(118_039 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `781 + r * (26 ±0)` + // Estimated: `8946` + // Minimum execution time: 14_463 nanoseconds. + Weight::from_parts(16_302_901, 8946) + // Standard Error: 809 + .saturating_add(Weight::from_ref_time(73_692).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/election-provider-multi-phase/src/weights.rs b/frame/election-provider-multi-phase/src/weights.rs index 221fd5837f..51bb7b0f10 100644 --- a/frame/election-provider-multi-phase/src/weights.rs +++ b/frame/election-provider-multi-phase/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_election_provider_multi_phase //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -62,262 +63,422 @@ pub trait WeightInfo { /// Weights for pallet_election_provider_multi_phase using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking CurrentPlannedSession (r:1 w:0) - // Storage: Staking ErasStartSessionIndex (r:1 w:0) - // Storage: Babe EpochIndex (r:1 w:0) - // Storage: Babe GenesisSlot (r:1 w:0) - // Storage: Babe CurrentSlot (r:1 w:0) - // Storage: Staking ForceEra (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CurrentPlannedSession (r:1 w:0) + /// Proof: Staking CurrentPlannedSession (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasStartSessionIndex (r:1 w:0) + /// Proof: Staking ErasStartSessionIndex (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: Babe EpochIndex (r:1 w:0) + /// Proof: Babe EpochIndex (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Babe GenesisSlot (r:1 w:0) + /// Proof: Babe GenesisSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Babe CurrentSlot (r:1 w:0) + /// Proof: Babe CurrentSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Staking ForceEra (r:1 w:0) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) fn on_initialize_nothing() -> Weight { - // Minimum execution time: 17_309 nanoseconds. - Weight::from_ref_time(17_646_000 as u64) - .saturating_add(T::DbWeight::get().reads(8 as u64)) + // Proof Size summary in bytes: + // Measured: `994` + // Estimated: `6983` + // Minimum execution time: 17_801 nanoseconds. + Weight::from_parts(18_364_000, 6983) + .saturating_add(T::DbWeight::get().reads(8_u64)) } - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) fn on_initialize_open_signed() -> Weight { - // Minimum execution time: 17_992 nanoseconds. - Weight::from_ref_time(18_426_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `114` + // Estimated: `1218` + // Minimum execution time: 12_814 nanoseconds. + Weight::from_parts(13_154_000, 1218) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) fn on_initialize_open_unsigned() -> Weight { - // Minimum execution time: 17_340 nanoseconds. - Weight::from_ref_time(17_881_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `114` + // Estimated: `1218` + // Minimum execution time: 14_565 nanoseconds. + Weight::from_parts(15_097_000, 1218) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) - // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) fn finalize_signed_phase_accept_solution() -> Weight { - // Minimum execution time: 35_571 nanoseconds. - Weight::from_ref_time(35_989_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `206` + // Estimated: `2809` + // Minimum execution time: 23_341 nanoseconds. + Weight::from_parts(23_770_000, 2809) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn finalize_signed_phase_reject_solution() -> Weight { - // Minimum execution time: 27_403 nanoseconds. - Weight::from_ref_time(27_879_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `206` + // Estimated: `2603` + // Minimum execution time: 16_662 nanoseconds. + Weight::from_parts(16_898_000, 2603) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) - // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. fn create_snapshot_internal(v: u32, _t: u32, ) -> Weight { - // Minimum execution time: 571_900 nanoseconds. - Weight::from_ref_time(589_170_000 as u64) - // Standard Error: 7_123 - .saturating_add(Weight::from_ref_time(384_767 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 215_168 nanoseconds. + Weight::from_ref_time(219_887_000) + // Standard Error: 1_444 + .saturating_add(Weight::from_ref_time(146_388).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:1 w:0) - // Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) - // Storage: ElectionProviderMultiPhase Round (r:1 w:1) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) - // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) + /// Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionIndices (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionNextIndex (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionsMap (max_values: None, max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn elect_queued(a: u32, d: u32, ) -> Weight { - // Minimum execution time: 1_296_481 nanoseconds. - Weight::from_ref_time(1_076_121_575 as u64) - // Standard Error: 5_708 - .saturating_add(Weight::from_ref_time(474_995 as u64).saturating_mul(a as u64)) - // Standard Error: 8_556 - .saturating_add(Weight::from_ref_time(39_224 as u64).saturating_mul(d as u64)) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(8 as u64)) + // Proof Size summary in bytes: + // Measured: `368 + a * (768 ±0) + d * (48 ±0)` + // Estimated: `9540 + a * (6912 ±0) + d * (441 ±0)` + // Minimum execution time: 268_021 nanoseconds. + Weight::from_parts(72_491_937, 9540) + // Standard Error: 2_910 + .saturating_add(Weight::from_ref_time(303_955).saturating_mul(a.into())) + // Standard Error: 4_363 + .saturating_add(Weight::from_ref_time(167_369).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_proof_size(6912).saturating_mul(a.into())) + .saturating_add(Weight::from_proof_size(441).saturating_mul(d.into())) } - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) - // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) - // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionIndices (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionNextIndex (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionsMap (max_values: None, max_size: None, mode: Measured) fn submit() -> Weight { - // Minimum execution time: 58_716 nanoseconds. - Weight::from_ref_time(59_480_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `924` + // Estimated: `7111` + // Minimum execution time: 44_177 nanoseconds. + Weight::from_parts(44_663_000, 7111) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) - // Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) - // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn submit_unsigned(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { - // Minimum execution time: 5_540_737 nanoseconds. - Weight::from_ref_time(5_567_381_000 as u64) - // Standard Error: 18_563 - .saturating_add(Weight::from_ref_time(603_280 as u64).saturating_mul(v as u64)) - // Standard Error: 55_009 - .saturating_add(Weight::from_ref_time(3_164_053 as u64).saturating_mul(a as u64)) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + fn submit_unsigned(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `251 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `5222 + v * (3871 ±0) + t * (224 ±0)` + // Minimum execution time: 4_425_457 nanoseconds. + Weight::from_parts(4_445_889_000, 5222) + // Standard Error: 13_250 + .saturating_add(Weight::from_ref_time(48_844).saturating_mul(v.into())) + // Standard Error: 39_266 + .saturating_add(Weight::from_ref_time(4_144_034).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(3871).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(224).saturating_mul(t.into())) } - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) - // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn feasibility_check(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { - // Minimum execution time: 5_021_808 nanoseconds. - Weight::from_ref_time(5_051_856_000 as u64) - // Standard Error: 16_650 - .saturating_add(Weight::from_ref_time(683_344 as u64).saturating_mul(v as u64)) - // Standard Error: 49_342 - .saturating_add(Weight::from_ref_time(2_190_098 as u64).saturating_mul(a as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) + fn feasibility_check(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `226 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `2884 + v * (2212 ±0) + t * (128 ±0)` + // Minimum execution time: 3_812_071 nanoseconds. + Weight::from_parts(3_826_375_000, 2884) + // Standard Error: 11_601 + .saturating_add(Weight::from_ref_time(145_309).saturating_mul(v.into())) + // Standard Error: 34_378 + .saturating_add(Weight::from_ref_time(3_223_977).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(Weight::from_proof_size(2212).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(128).saturating_mul(t.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking CurrentPlannedSession (r:1 w:0) - // Storage: Staking ErasStartSessionIndex (r:1 w:0) - // Storage: Babe EpochIndex (r:1 w:0) - // Storage: Babe GenesisSlot (r:1 w:0) - // Storage: Babe CurrentSlot (r:1 w:0) - // Storage: Staking ForceEra (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CurrentPlannedSession (r:1 w:0) + /// Proof: Staking CurrentPlannedSession (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasStartSessionIndex (r:1 w:0) + /// Proof: Staking ErasStartSessionIndex (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: Babe EpochIndex (r:1 w:0) + /// Proof: Babe EpochIndex (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Babe GenesisSlot (r:1 w:0) + /// Proof: Babe GenesisSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Babe CurrentSlot (r:1 w:0) + /// Proof: Babe CurrentSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Staking ForceEra (r:1 w:0) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) fn on_initialize_nothing() -> Weight { - // Minimum execution time: 17_309 nanoseconds. - Weight::from_ref_time(17_646_000 as u64) - .saturating_add(RocksDbWeight::get().reads(8 as u64)) + // Proof Size summary in bytes: + // Measured: `994` + // Estimated: `6983` + // Minimum execution time: 17_801 nanoseconds. + Weight::from_parts(18_364_000, 6983) + .saturating_add(RocksDbWeight::get().reads(8_u64)) } - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) fn on_initialize_open_signed() -> Weight { - // Minimum execution time: 17_992 nanoseconds. - Weight::from_ref_time(18_426_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `114` + // Estimated: `1218` + // Minimum execution time: 12_814 nanoseconds. + Weight::from_parts(13_154_000, 1218) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) fn on_initialize_open_unsigned() -> Weight { - // Minimum execution time: 17_340 nanoseconds. - Weight::from_ref_time(17_881_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `114` + // Estimated: `1218` + // Minimum execution time: 14_565 nanoseconds. + Weight::from_parts(15_097_000, 1218) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Account (r:1 w:1) - // Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase QueuedSolution (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) fn finalize_signed_phase_accept_solution() -> Weight { - // Minimum execution time: 35_571 nanoseconds. - Weight::from_ref_time(35_989_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `206` + // Estimated: `2809` + // Minimum execution time: 23_341 nanoseconds. + Weight::from_parts(23_770_000, 2809) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: System Account (r:1 w:1) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn finalize_signed_phase_reject_solution() -> Weight { - // Minimum execution time: 27_403 nanoseconds. - Weight::from_ref_time(27_879_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `206` + // Estimated: `2603` + // Minimum execution time: 16_662 nanoseconds. + Weight::from_parts(16_898_000, 2603) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) - // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. fn create_snapshot_internal(v: u32, _t: u32, ) -> Weight { - // Minimum execution time: 571_900 nanoseconds. - Weight::from_ref_time(589_170_000 as u64) - // Standard Error: 7_123 - .saturating_add(Weight::from_ref_time(384_767 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 215_168 nanoseconds. + Weight::from_ref_time(219_887_000) + // Standard Error: 1_444 + .saturating_add(Weight::from_ref_time(146_388).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:1 w:0) - // Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) - // Storage: ElectionProviderMultiPhase Round (r:1 w:1) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) - // Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) - // Storage: ElectionProviderMultiPhase CurrentPhase (r:0 w:1) + /// Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionIndices (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionNextIndex (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionsMap (max_values: None, max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. fn elect_queued(a: u32, d: u32, ) -> Weight { - // Minimum execution time: 1_296_481 nanoseconds. - Weight::from_ref_time(1_076_121_575 as u64) - // Standard Error: 5_708 - .saturating_add(Weight::from_ref_time(474_995 as u64).saturating_mul(a as u64)) - // Standard Error: 8_556 - .saturating_add(Weight::from_ref_time(39_224 as u64).saturating_mul(d as u64)) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(8 as u64)) + // Proof Size summary in bytes: + // Measured: `368 + a * (768 ±0) + d * (48 ±0)` + // Estimated: `9540 + a * (6912 ±0) + d * (441 ±0)` + // Minimum execution time: 268_021 nanoseconds. + Weight::from_parts(72_491_937, 9540) + // Standard Error: 2_910 + .saturating_add(Weight::from_ref_time(303_955).saturating_mul(a.into())) + // Standard Error: 4_363 + .saturating_add(Weight::from_ref_time(167_369).saturating_mul(d.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_proof_size(6912).saturating_mul(a.into())) + .saturating_add(Weight::from_proof_size(441).saturating_mul(d.into())) } - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) - // Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) - // Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) - // Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TransactionPayment NextFeeMultiplier (r:1 w:0) + /// Proof: TransactionPayment NextFeeMultiplier (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: ElectionProviderMultiPhase SignedSubmissionIndices (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionIndices (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionNextIndex (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionNextIndex (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SignedSubmissionsMap (r:0 w:1) + /// Proof Skipped: ElectionProviderMultiPhase SignedSubmissionsMap (max_values: None, max_size: None, mode: Measured) fn submit() -> Weight { - // Minimum execution time: 58_716 nanoseconds. - Weight::from_ref_time(59_480_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `924` + // Estimated: `7111` + // Minimum execution time: 44_177 nanoseconds. + Weight::from_parts(44_663_000, 7111) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) - // Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) - // Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) - // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase CurrentPhase (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase QueuedSolution (r:1 w:1) + /// Proof Skipped: ElectionProviderMultiPhase QueuedSolution (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase SnapshotMetadata (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase SnapshotMetadata (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn submit_unsigned(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { - // Minimum execution time: 5_540_737 nanoseconds. - Weight::from_ref_time(5_567_381_000 as u64) - // Standard Error: 18_563 - .saturating_add(Weight::from_ref_time(603_280 as u64).saturating_mul(v as u64)) - // Standard Error: 55_009 - .saturating_add(Weight::from_ref_time(3_164_053 as u64).saturating_mul(a as u64)) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + fn submit_unsigned(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `251 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `5222 + v * (3871 ±0) + t * (224 ±0)` + // Minimum execution time: 4_425_457 nanoseconds. + Weight::from_parts(4_445_889_000, 5222) + // Standard Error: 13_250 + .saturating_add(Weight::from_ref_time(48_844).saturating_mul(v.into())) + // Standard Error: 39_266 + .saturating_add(Weight::from_ref_time(4_144_034).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(3871).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(224).saturating_mul(t.into())) } - // Storage: ElectionProviderMultiPhase Round (r:1 w:0) - // Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) - // Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) - // Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Storage: ElectionProviderMultiPhase Round (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Round (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase DesiredTargets (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase DesiredTargets (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase MinimumUntrustedScore (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase MinimumUntrustedScore (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ElectionProviderMultiPhase Snapshot (r:1 w:0) + /// Proof Skipped: ElectionProviderMultiPhase Snapshot (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[1000, 2000]`. /// The range of component `t` is `[500, 1000]`. /// The range of component `a` is `[500, 800]`. /// The range of component `d` is `[200, 400]`. - fn feasibility_check(v: u32, _t: u32, a: u32, _d: u32, ) -> Weight { - // Minimum execution time: 5_021_808 nanoseconds. - Weight::from_ref_time(5_051_856_000 as u64) - // Standard Error: 16_650 - .saturating_add(Weight::from_ref_time(683_344 as u64).saturating_mul(v as u64)) - // Standard Error: 49_342 - .saturating_add(Weight::from_ref_time(2_190_098 as u64).saturating_mul(a as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) + fn feasibility_check(v: u32, t: u32, a: u32, _d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `226 + v * (553 ±0) + t * (32 ±0)` + // Estimated: `2884 + v * (2212 ±0) + t * (128 ±0)` + // Minimum execution time: 3_812_071 nanoseconds. + Weight::from_parts(3_826_375_000, 2884) + // Standard Error: 11_601 + .saturating_add(Weight::from_ref_time(145_309).saturating_mul(v.into())) + // Standard Error: 34_378 + .saturating_add(Weight::from_ref_time(3_223_977).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(Weight::from_proof_size(2212).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(128).saturating_mul(t.into())) } } diff --git a/frame/elections-phragmen/src/weights.rs b/frame/elections-phragmen/src/weights.rs index ddc55b0875..dc5d937e33 100644 --- a/frame/elections-phragmen/src/weights.rs +++ b/frame/elections-phragmen/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_elections_phragmen //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -64,306 +65,494 @@ pub trait WeightInfo { /// Weights for pallet_elections_phragmen using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Elections Candidates (r:1 w:0) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { - // Minimum execution time: 38_496 nanoseconds. - Weight::from_ref_time(39_424_348 as u64) - // Standard Error: 3_547 - .saturating_add(Weight::from_ref_time(119_971 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `499 + v * (80 ±0)` + // Estimated: `9726 + v * (320 ±0)` + // Minimum execution time: 25_407 nanoseconds. + Weight::from_parts(26_035_742, 9726) + // Standard Error: 2_162 + .saturating_add(Weight::from_ref_time(120_321).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(320).saturating_mul(v.into())) } - // Storage: Elections Candidates (r:1 w:0) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { - // Minimum execution time: 49_459 nanoseconds. - Weight::from_ref_time(50_225_486 as u64) - // Standard Error: 3_160 - .saturating_add(Weight::from_ref_time(170_360 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `467 + v * (80 ±0)` + // Estimated: `9598 + v * (320 ±0)` + // Minimum execution time: 34_477 nanoseconds. + Weight::from_parts(35_197_694, 9598) + // Standard Error: 2_089 + .saturating_add(Weight::from_ref_time(116_792).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(320).saturating_mul(v.into())) } - // Storage: Elections Candidates (r:1 w:0) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { - // Minimum execution time: 48_712 nanoseconds. - Weight::from_ref_time(49_463_298 as u64) - // Standard Error: 2_678 - .saturating_add(Weight::from_ref_time(231_771 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `499 + v * (80 ±0)` + // Estimated: `9726 + v * (320 ±0)` + // Minimum execution time: 34_573 nanoseconds. + Weight::from_parts(35_254_508, 9726) + // Standard Error: 2_076 + .saturating_add(Weight::from_ref_time(110_656).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(320).saturating_mul(v.into())) } - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn remove_voter() -> Weight { - // Minimum execution time: 48_359 nanoseconds. - Weight::from_ref_time(48_767_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `989` + // Estimated: `7238` + // Minimum execution time: 31_469 nanoseconds. + Weight::from_parts(31_877_000, 7238) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Elections Candidates (r:1 w:1) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) + /// Storage: Elections Candidates (r:1 w:1) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { - // Minimum execution time: 43_369 nanoseconds. - Weight::from_ref_time(49_587_113 as u64) - // Standard Error: 1_008 - .saturating_add(Weight::from_ref_time(77_752 as u64).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1687 + c * (48 ±0)` + // Estimated: `6540 + c * (144 ±0)` + // Minimum execution time: 26_969 nanoseconds. + Weight::from_parts(28_584_266, 6540) + // Standard Error: 93 + .saturating_add(Weight::from_ref_time(52_393).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(144).saturating_mul(c.into())) } - // Storage: Elections Candidates (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:1) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[1, 1000]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { - // Minimum execution time: 41_321 nanoseconds. - Weight::from_ref_time(50_803_289 as u64) - // Standard Error: 1_159 - .saturating_add(Weight::from_ref_time(57_239 as u64).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `348 + c * (48 ±0)` + // Estimated: `830 + c * (48 ±0)` + // Minimum execution time: 23_635 nanoseconds. + Weight::from_parts(23_482_193, 830) + // Standard Error: 103 + .saturating_add(Weight::from_ref_time(33_759).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(48).saturating_mul(c.into())) } - // Storage: Elections Members (r:1 w:1) - // Storage: Elections RunnersUp (r:1 w:1) - // Storage: Council Prime (r:1 w:1) - // Storage: Council Proposals (r:1 w:0) - // Storage: Council Members (r:0 w:1) + /// Storage: Elections Members (r:1 w:1) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Members (r:0 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_members() -> Weight { - // Minimum execution time: 53_542 nanoseconds. - Weight::from_ref_time(54_481_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `2027` + // Estimated: `12115` + // Minimum execution time: 39_124 nanoseconds. + Weight::from_parts(39_575_000, 12115) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: Elections RunnersUp (r:1 w:1) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_runners_up() -> Weight { - // Minimum execution time: 41_825 nanoseconds. - Weight::from_ref_time(42_248_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `975` + // Estimated: `1470` + // Minimum execution time: 25_377 nanoseconds. + Weight::from_parts(25_696_000, 1470) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Benchmark Override (r:0 w:0) + /// Storage: Benchmark Override (r:0 w:0) + /// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) fn remove_member_without_replacement() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` // Minimum execution time: 2_000_000_000 nanoseconds. - Weight::from_ref_time(2_000_000_000_000 as u64) + Weight::from_ref_time(2_000_000_000_000) } - // Storage: Elections Members (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Elections RunnersUp (r:1 w:1) - // Storage: Council Prime (r:1 w:1) - // Storage: Council Proposals (r:1 w:0) - // Storage: Council Members (r:0 w:1) + /// Storage: Elections Members (r:1 w:1) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Members (r:0 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn remove_member_with_replacement() -> Weight { - // Minimum execution time: 62_600 nanoseconds. - Weight::from_ref_time(63_152_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `2027` + // Estimated: `14718` + // Minimum execution time: 44_919 nanoseconds. + Weight::from_parts(45_548_000, 14718) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: Elections Voting (r:5001 w:5000) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Candidates (r:1 w:0) - // Storage: Balances Locks (r:5000 w:5000) - // Storage: System Account (r:5000 w:5000) + /// Storage: Elections Voting (r:10001 w:10000) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Balances Locks (r:10000 w:10000) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:10000 w:10000) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `v` is `[5000, 10000]`. /// The range of component `d` is `[0, 5000]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { - // Minimum execution time: 297_149_264 nanoseconds. - Weight::from_ref_time(297_898_499_000 as u64) - // Standard Error: 263_819 - .saturating_add(Weight::from_ref_time(37_914_985 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(v as u64))) - .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(v as u64))) + // Proof Size summary in bytes: + // Measured: `36028 + v * (872 ±0)` + // Estimated: `149172 + v * (12340 ±0)` + // Minimum execution time: 297_544_939 nanoseconds. + Weight::from_parts(298_088_024_000, 149172) + // Standard Error: 264_599 + .saturating_add(Weight::from_ref_time(38_142_857).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(v.into()))) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into()))) + .saturating_add(Weight::from_proof_size(12340).saturating_mul(v.into())) } - // Storage: Elections Candidates (r:1 w:1) - // Storage: Elections Members (r:1 w:1) - // Storage: Elections RunnersUp (r:1 w:1) - // Storage: Elections Voting (r:10001 w:0) - // Storage: Council Proposals (r:1 w:0) - // Storage: Elections ElectionRounds (r:1 w:1) - // Storage: Council Members (r:0 w:1) - // Storage: Council Prime (r:0 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:1) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:1) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:10001 w:0) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:980 w:980) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Elections ElectionRounds (r:1 w:1) + /// Proof Skipped: Elections ElectionRounds (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Members (r:0 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:0 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[1, 1000]`. /// The range of component `v` is `[1, 10000]`. /// The range of component `e` is `[10000, 160000]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { - // Minimum execution time: 22_034_317 nanoseconds. - Weight::from_ref_time(22_110_020_000 as u64) - // Standard Error: 235_528 - .saturating_add(Weight::from_ref_time(25_553_585 as u64).saturating_mul(v as u64)) - // Standard Error: 15_114 - .saturating_add(Weight::from_ref_time(1_032_330 as u64).saturating_mul(e as u64)) - .saturating_add(T::DbWeight::get().reads(280 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(c as u64))) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(v as u64))) - .saturating_add(T::DbWeight::get().writes(6 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + // Proof Size summary in bytes: + // Measured: `0 + v * (639 ±0) + e * (28 ±0)` + // Estimated: `5350105 + c * (2582 ±0) + v * (5721 ±6) + e * (123 ±0)` + // Minimum execution time: 21_844_965 nanoseconds. + Weight::from_parts(21_979_826_000, 5350105) + // Standard Error: 229_799 + .saturating_add(Weight::from_ref_time(24_976_612).saturating_mul(v.into())) + // Standard Error: 14_747 + .saturating_add(Weight::from_ref_time(1_025_848).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(280_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) + .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_proof_size(2582).saturating_mul(c.into())) + .saturating_add(Weight::from_proof_size(5721).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(123).saturating_mul(e.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Elections Candidates (r:1 w:0) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `v` is `[1, 16]`. fn vote_equal(v: u32, ) -> Weight { - // Minimum execution time: 38_496 nanoseconds. - Weight::from_ref_time(39_424_348 as u64) - // Standard Error: 3_547 - .saturating_add(Weight::from_ref_time(119_971 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `499 + v * (80 ±0)` + // Estimated: `9726 + v * (320 ±0)` + // Minimum execution time: 25_407 nanoseconds. + Weight::from_parts(26_035_742, 9726) + // Standard Error: 2_162 + .saturating_add(Weight::from_ref_time(120_321).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(320).saturating_mul(v.into())) } - // Storage: Elections Candidates (r:1 w:0) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `v` is `[2, 16]`. fn vote_more(v: u32, ) -> Weight { - // Minimum execution time: 49_459 nanoseconds. - Weight::from_ref_time(50_225_486 as u64) - // Standard Error: 3_160 - .saturating_add(Weight::from_ref_time(170_360 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `467 + v * (80 ±0)` + // Estimated: `9598 + v * (320 ±0)` + // Minimum execution time: 34_477 nanoseconds. + Weight::from_parts(35_197_694, 9598) + // Standard Error: 2_089 + .saturating_add(Weight::from_ref_time(116_792).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(320).saturating_mul(v.into())) } - // Storage: Elections Candidates (r:1 w:0) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `v` is `[2, 16]`. fn vote_less(v: u32, ) -> Weight { - // Minimum execution time: 48_712 nanoseconds. - Weight::from_ref_time(49_463_298 as u64) - // Standard Error: 2_678 - .saturating_add(Weight::from_ref_time(231_771 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `499 + v * (80 ±0)` + // Estimated: `9726 + v * (320 ±0)` + // Minimum execution time: 34_573 nanoseconds. + Weight::from_parts(35_254_508, 9726) + // Standard Error: 2_076 + .saturating_add(Weight::from_ref_time(110_656).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(320).saturating_mul(v.into())) } - // Storage: Elections Voting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Elections Voting (r:1 w:1) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) fn remove_voter() -> Weight { - // Minimum execution time: 48_359 nanoseconds. - Weight::from_ref_time(48_767_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `989` + // Estimated: `7238` + // Minimum execution time: 31_469 nanoseconds. + Weight::from_parts(31_877_000, 7238) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Elections Candidates (r:1 w:1) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) + /// Storage: Elections Candidates (r:1 w:1) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { - // Minimum execution time: 43_369 nanoseconds. - Weight::from_ref_time(49_587_113 as u64) - // Standard Error: 1_008 - .saturating_add(Weight::from_ref_time(77_752 as u64).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1687 + c * (48 ±0)` + // Estimated: `6540 + c * (144 ±0)` + // Minimum execution time: 26_969 nanoseconds. + Weight::from_parts(28_584_266, 6540) + // Standard Error: 93 + .saturating_add(Weight::from_ref_time(52_393).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(144).saturating_mul(c.into())) } - // Storage: Elections Candidates (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:1) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[1, 1000]`. fn renounce_candidacy_candidate(c: u32, ) -> Weight { - // Minimum execution time: 41_321 nanoseconds. - Weight::from_ref_time(50_803_289 as u64) - // Standard Error: 1_159 - .saturating_add(Weight::from_ref_time(57_239 as u64).saturating_mul(c as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `348 + c * (48 ±0)` + // Estimated: `830 + c * (48 ±0)` + // Minimum execution time: 23_635 nanoseconds. + Weight::from_parts(23_482_193, 830) + // Standard Error: 103 + .saturating_add(Weight::from_ref_time(33_759).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(48).saturating_mul(c.into())) } - // Storage: Elections Members (r:1 w:1) - // Storage: Elections RunnersUp (r:1 w:1) - // Storage: Council Prime (r:1 w:1) - // Storage: Council Proposals (r:1 w:0) - // Storage: Council Members (r:0 w:1) + /// Storage: Elections Members (r:1 w:1) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Members (r:0 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_members() -> Weight { - // Minimum execution time: 53_542 nanoseconds. - Weight::from_ref_time(54_481_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `2027` + // Estimated: `12115` + // Minimum execution time: 39_124 nanoseconds. + Weight::from_parts(39_575_000, 12115) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: Elections RunnersUp (r:1 w:1) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) fn renounce_candidacy_runners_up() -> Weight { - // Minimum execution time: 41_825 nanoseconds. - Weight::from_ref_time(42_248_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `975` + // Estimated: `1470` + // Minimum execution time: 25_377 nanoseconds. + Weight::from_parts(25_696_000, 1470) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Benchmark Override (r:0 w:0) + /// Storage: Benchmark Override (r:0 w:0) + /// Proof Skipped: Benchmark Override (max_values: None, max_size: None, mode: Measured) fn remove_member_without_replacement() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` // Minimum execution time: 2_000_000_000 nanoseconds. - Weight::from_ref_time(2_000_000_000_000 as u64) + Weight::from_ref_time(2_000_000_000_000) } - // Storage: Elections Members (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Elections RunnersUp (r:1 w:1) - // Storage: Council Prime (r:1 w:1) - // Storage: Council Proposals (r:1 w:0) - // Storage: Council Members (r:0 w:1) + /// Storage: Elections Members (r:1 w:1) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:1 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Members (r:0 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn remove_member_with_replacement() -> Weight { - // Minimum execution time: 62_600 nanoseconds. - Weight::from_ref_time(63_152_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `2027` + // Estimated: `14718` + // Minimum execution time: 44_919 nanoseconds. + Weight::from_parts(45_548_000, 14718) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: Elections Voting (r:5001 w:5000) - // Storage: Elections Members (r:1 w:0) - // Storage: Elections RunnersUp (r:1 w:0) - // Storage: Elections Candidates (r:1 w:0) - // Storage: Balances Locks (r:5000 w:5000) - // Storage: System Account (r:5000 w:5000) + /// Storage: Elections Voting (r:10001 w:10000) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:0) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Candidates (r:1 w:0) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Balances Locks (r:10000 w:10000) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:10000 w:10000) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `v` is `[5000, 10000]`. /// The range of component `d` is `[0, 5000]`. fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight { - // Minimum execution time: 297_149_264 nanoseconds. - Weight::from_ref_time(297_898_499_000 as u64) - // Standard Error: 263_819 - .saturating_add(Weight::from_ref_time(37_914_985 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(v as u64))) - .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(v as u64))) + // Proof Size summary in bytes: + // Measured: `36028 + v * (872 ±0)` + // Estimated: `149172 + v * (12340 ±0)` + // Minimum execution time: 297_544_939 nanoseconds. + Weight::from_parts(298_088_024_000, 149172) + // Standard Error: 264_599 + .saturating_add(Weight::from_ref_time(38_142_857).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(v.into()))) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(v.into()))) + .saturating_add(Weight::from_proof_size(12340).saturating_mul(v.into())) } - // Storage: Elections Candidates (r:1 w:1) - // Storage: Elections Members (r:1 w:1) - // Storage: Elections RunnersUp (r:1 w:1) - // Storage: Elections Voting (r:10001 w:0) - // Storage: Council Proposals (r:1 w:0) - // Storage: Elections ElectionRounds (r:1 w:1) - // Storage: Council Members (r:0 w:1) - // Storage: Council Prime (r:0 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Elections Candidates (r:1 w:1) + /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:1) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections RunnersUp (r:1 w:1) + /// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Elections Voting (r:10001 w:0) + /// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured) + /// Storage: Council Proposals (r:1 w:0) + /// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:980 w:980) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Elections ElectionRounds (r:1 w:1) + /// Proof Skipped: Elections ElectionRounds (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Members (r:0 w:1) + /// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Council Prime (r:0 w:1) + /// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `c` is `[1, 1000]`. /// The range of component `v` is `[1, 10000]`. /// The range of component `e` is `[10000, 160000]`. fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight { - // Minimum execution time: 22_034_317 nanoseconds. - Weight::from_ref_time(22_110_020_000 as u64) - // Standard Error: 235_528 - .saturating_add(Weight::from_ref_time(25_553_585 as u64).saturating_mul(v as u64)) - // Standard Error: 15_114 - .saturating_add(Weight::from_ref_time(1_032_330 as u64).saturating_mul(e as u64)) - .saturating_add(RocksDbWeight::get().reads(280 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(c as u64))) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(v as u64))) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(c as u64))) + // Proof Size summary in bytes: + // Measured: `0 + v * (639 ±0) + e * (28 ±0)` + // Estimated: `5350105 + c * (2582 ±0) + v * (5721 ±6) + e * (123 ±0)` + // Minimum execution time: 21_844_965 nanoseconds. + Weight::from_parts(21_979_826_000, 5350105) + // Standard Error: 229_799 + .saturating_add(Weight::from_ref_time(24_976_612).saturating_mul(v.into())) + // Standard Error: 14_747 + .saturating_add(Weight::from_ref_time(1_025_848).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(280_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_proof_size(2582).saturating_mul(c.into())) + .saturating_add(Weight::from_proof_size(5721).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(123).saturating_mul(e.into())) } } diff --git a/frame/identity/src/weights.rs b/frame/identity/src/weights.rs index 1f2e8f98e9..7bcbf539d6 100644 --- a/frame/identity/src/weights.rs +++ b/frame/identity/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_identity //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -68,420 +69,584 @@ pub trait WeightInfo { /// Weights for pallet_identity using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Identity Registrars (r:1 w:1) + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - // Minimum execution time: 20_269 nanoseconds. - Weight::from_ref_time(21_910_543 as u64) - // Standard Error: 4_604 - .saturating_add(Weight::from_ref_time(223_104 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `64 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 10_964 nanoseconds. + Weight::from_parts(11_800_935, 1636) + // Standard Error: 1_334 + .saturating_add(Weight::from_ref_time(96_038).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 41_872 nanoseconds. - Weight::from_ref_time(40_230_216 as u64) - // Standard Error: 2_342 - .saturating_add(Weight::from_ref_time(145_168 as u64).saturating_mul(r as u64)) - // Standard Error: 457 - .saturating_add(Weight::from_ref_time(291_732 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `474 + r * (5 ±0)` + // Estimated: `10013` + // Minimum execution time: 26_400 nanoseconds. + Weight::from_parts(26_060_549, 10013) + // Standard Error: 1_561 + .saturating_add(Weight::from_ref_time(72_083).saturating_mul(r.into())) + // Standard Error: 304 + .saturating_add(Weight::from_ref_time(306_994).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:100 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn set_subs_new(s: u32, ) -> Weight { - // Minimum execution time: 12_024 nanoseconds. - Weight::from_ref_time(32_550_819 as u64) - // Standard Error: 5_057 - .saturating_add(Weight::from_ref_time(2_521_245 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(s as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `101` + // Estimated: `15746 + s * (2589 ±0)` + // Minimum execution time: 8_492 nanoseconds. + Weight::from_parts(21_645_924, 15746) + // Standard Error: 3_452 + .saturating_add(Weight::from_ref_time(2_442_604).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(2589).saturating_mul(s.into())) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:0 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { - // Minimum execution time: 12_232 nanoseconds. - Weight::from_ref_time(34_009_761 as u64) - // Standard Error: 5_047 - .saturating_add(Weight::from_ref_time(1_113_100 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) - } - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity IdentityOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:100) + // Proof Size summary in bytes: + // Measured: `226 + p * (32 ±0)` + // Estimated: `15746` + // Minimum execution time: 8_488 nanoseconds. + Weight::from_parts(20_202_601, 15746) + // Standard Error: 2_834 + .saturating_add(Weight::from_ref_time(1_082_941).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + } + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:0 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `s` is `[0, 100]`. /// The range of component `x` is `[0, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - // Minimum execution time: 57_144 nanoseconds. - Weight::from_ref_time(41_559_247 as u64) - // Standard Error: 9_996 - .saturating_add(Weight::from_ref_time(146_770 as u64).saturating_mul(r as u64)) - // Standard Error: 1_952 - .saturating_add(Weight::from_ref_time(1_086_673 as u64).saturating_mul(s as u64)) - // Standard Error: 1_952 - .saturating_add(Weight::from_ref_time(162_481 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) - } - // Storage: Identity Registrars (r:1 w:0) - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `533 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `15746` + // Minimum execution time: 41_319 nanoseconds. + Weight::from_parts(25_850_055, 15746) + // Standard Error: 4_144 + .saturating_add(Weight::from_ref_time(59_619).saturating_mul(r.into())) + // Standard Error: 809 + .saturating_add(Weight::from_ref_time(1_076_550).saturating_mul(s.into())) + // Standard Error: 809 + .saturating_add(Weight::from_ref_time(163_191).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + } + /// Storage: Identity Registrars (r:1 w:0) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 44_726 nanoseconds. - Weight::from_ref_time(41_637_308 as u64) - // Standard Error: 1_907 - .saturating_add(Weight::from_ref_time(219_078 as u64).saturating_mul(r as u64)) - // Standard Error: 372 - .saturating_add(Weight::from_ref_time(309_888 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `431 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `11649` + // Minimum execution time: 28_118 nanoseconds. + Weight::from_parts(27_359_471, 11649) + // Standard Error: 2_707 + .saturating_add(Weight::from_ref_time(107_279).saturating_mul(r.into())) + // Standard Error: 528 + .saturating_add(Weight::from_ref_time(325_165).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 39_719 nanoseconds. - Weight::from_ref_time(38_008_751 as u64) - // Standard Error: 2_394 - .saturating_add(Weight::from_ref_time(181_870 as u64).saturating_mul(r as u64)) - // Standard Error: 467 - .saturating_add(Weight::from_ref_time(314_990 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `430 + x * (66 ±0)` + // Estimated: `10013` + // Minimum execution time: 24_817 nanoseconds. + Weight::from_parts(24_749_808, 10013) + // Standard Error: 1_938 + .saturating_add(Weight::from_ref_time(63_396).saturating_mul(r.into())) + // Standard Error: 378 + .saturating_add(Weight::from_ref_time(327_083).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - // Minimum execution time: 10_634 nanoseconds. - Weight::from_ref_time(11_383_704 as u64) - // Standard Error: 2_250 - .saturating_add(Weight::from_ref_time(193_094 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `121 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 6_664 nanoseconds. + Weight::from_parts(7_286_307, 1636) + // Standard Error: 1_560 + .saturating_add(Weight::from_ref_time(96_416).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - // Minimum execution time: 10_840 nanoseconds. - Weight::from_ref_time(11_638_740 as u64) - // Standard Error: 1_985 - .saturating_add(Weight::from_ref_time(193_016 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `121 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 7_054 nanoseconds. + Weight::from_parts(7_382_954, 1636) + // Standard Error: 1_621 + .saturating_add(Weight::from_ref_time(101_595).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - // Minimum execution time: 10_748 nanoseconds. - Weight::from_ref_time(11_346_901 as u64) - // Standard Error: 2_132 - .saturating_add(Weight::from_ref_time(196_630 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:0) - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `121 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 6_659 nanoseconds. + Weight::from_parts(7_188_883, 1636) + // Standard Error: 1_377 + .saturating_add(Weight::from_ref_time(98_965).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:0) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 33_682 nanoseconds. - Weight::from_ref_time(31_336_603 as u64) - // Standard Error: 3_056 - .saturating_add(Weight::from_ref_time(200_403 as u64).saturating_mul(r as u64)) - // Standard Error: 565 - .saturating_add(Weight::from_ref_time(525_142 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity IdentityOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:100) + // Proof Size summary in bytes: + // Measured: `509 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `11649` + // Minimum execution time: 21_567 nanoseconds. + Weight::from_parts(21_015_310, 11649) + // Standard Error: 2_516 + .saturating_add(Weight::from_ref_time(123_992).saturating_mul(r.into())) + // Standard Error: 465 + .saturating_add(Weight::from_ref_time(552_116).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:0 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `s` is `[0, 100]`. /// The range of component `x` is `[0, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { - // Minimum execution time: 68_794 nanoseconds. - Weight::from_ref_time(52_114_486 as u64) - // Standard Error: 4_808 - .saturating_add(Weight::from_ref_time(153_462 as u64).saturating_mul(r as u64)) - // Standard Error: 939 - .saturating_add(Weight::from_ref_time(1_084_612 as u64).saturating_mul(s as u64)) - // Standard Error: 939 - .saturating_add(Weight::from_ref_time(170_112 as u64).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(s as u64))) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SuperOf (r:1 w:1) - // Storage: Identity SubsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `772 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `18349` + // Minimum execution time: 52_881 nanoseconds. + Weight::from_parts(38_504_388, 18349) + // Standard Error: 3_909 + .saturating_add(Weight::from_ref_time(51_452).saturating_mul(r.into())) + // Standard Error: 763 + .saturating_add(Weight::from_ref_time(1_069_924).saturating_mul(s.into())) + // Standard Error: 763 + .saturating_add(Weight::from_ref_time(164_906).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { - // Minimum execution time: 37_914 nanoseconds. - Weight::from_ref_time(43_488_083 as u64) - // Standard Error: 1_631 - .saturating_add(Weight::from_ref_time(118_845 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SuperOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `507 + s * (36 ±0)` + // Estimated: `18335` + // Minimum execution time: 24_556 nanoseconds. + Weight::from_parts(28_641_160, 18335) + // Standard Error: 1_327 + .saturating_add(Weight::from_ref_time(66_150).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - // Minimum execution time: 16_124 nanoseconds. - Weight::from_ref_time(18_580_462 as u64) - // Standard Error: 688 - .saturating_add(Weight::from_ref_time(67_220 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SuperOf (r:1 w:1) - // Storage: Identity SubsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `623 + s * (3 ±0)` + // Estimated: `12602` + // Minimum execution time: 11_347 nanoseconds. + Weight::from_parts(13_299_367, 12602) + // Standard Error: 525 + .saturating_add(Weight::from_ref_time(16_472).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - // Minimum execution time: 41_517 nanoseconds. - Weight::from_ref_time(45_123_530 as u64) - // Standard Error: 1_530 - .saturating_add(Weight::from_ref_time(105_429 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Identity SuperOf (r:1 w:1) - // Storage: Identity SubsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `702 + s * (35 ±0)` + // Estimated: `18335` + // Minimum execution time: 27_810 nanoseconds. + Weight::from_parts(30_347_763, 18335) + // Standard Error: 928 + .saturating_add(Weight::from_ref_time(55_342).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { - // Minimum execution time: 30_171 nanoseconds. - Weight::from_ref_time(33_355_514 as u64) - // Standard Error: 1_286 - .saturating_add(Weight::from_ref_time(114_716 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `628 + s * (37 ±0)` + // Estimated: `8322` + // Minimum execution time: 17_601 nanoseconds. + Weight::from_parts(19_794_971, 8322) + // Standard Error: 934 + .saturating_add(Weight::from_ref_time(59_289).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Identity Registrars (r:1 w:1) + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn add_registrar(r: u32, ) -> Weight { - // Minimum execution time: 20_269 nanoseconds. - Weight::from_ref_time(21_910_543 as u64) - // Standard Error: 4_604 - .saturating_add(Weight::from_ref_time(223_104 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `64 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 10_964 nanoseconds. + Weight::from_parts(11_800_935, 1636) + // Standard Error: 1_334 + .saturating_add(Weight::from_ref_time(96_038).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[0, 100]`. fn set_identity(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 41_872 nanoseconds. - Weight::from_ref_time(40_230_216 as u64) - // Standard Error: 2_342 - .saturating_add(Weight::from_ref_time(145_168 as u64).saturating_mul(r as u64)) - // Standard Error: 457 - .saturating_add(Weight::from_ref_time(291_732 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `474 + r * (5 ±0)` + // Estimated: `10013` + // Minimum execution time: 26_400 nanoseconds. + Weight::from_parts(26_060_549, 10013) + // Standard Error: 1_561 + .saturating_add(Weight::from_ref_time(72_083).saturating_mul(r.into())) + // Standard Error: 304 + .saturating_add(Weight::from_ref_time(306_994).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:100 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn set_subs_new(s: u32, ) -> Weight { - // Minimum execution time: 12_024 nanoseconds. - Weight::from_ref_time(32_550_819 as u64) - // Standard Error: 5_057 - .saturating_add(Weight::from_ref_time(2_521_245 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(s as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(s as u64))) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `101` + // Estimated: `15746 + s * (2589 ±0)` + // Minimum execution time: 8_492 nanoseconds. + Weight::from_parts(21_645_924, 15746) + // Standard Error: 3_452 + .saturating_add(Weight::from_ref_time(2_442_604).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(s.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(2589).saturating_mul(s.into())) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:0 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `p` is `[0, 100]`. fn set_subs_old(p: u32, ) -> Weight { - // Minimum execution time: 12_232 nanoseconds. - Weight::from_ref_time(34_009_761 as u64) - // Standard Error: 5_047 - .saturating_add(Weight::from_ref_time(1_113_100 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(p as u64))) - } - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity IdentityOf (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:100) + // Proof Size summary in bytes: + // Measured: `226 + p * (32 ±0)` + // Estimated: `15746` + // Minimum execution time: 8_488 nanoseconds. + Weight::from_parts(20_202_601, 15746) + // Standard Error: 2_834 + .saturating_add(Weight::from_ref_time(1_082_941).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) + } + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:0 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `s` is `[0, 100]`. /// The range of component `x` is `[0, 100]`. fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight { - // Minimum execution time: 57_144 nanoseconds. - Weight::from_ref_time(41_559_247 as u64) - // Standard Error: 9_996 - .saturating_add(Weight::from_ref_time(146_770 as u64).saturating_mul(r as u64)) - // Standard Error: 1_952 - .saturating_add(Weight::from_ref_time(1_086_673 as u64).saturating_mul(s as u64)) - // Standard Error: 1_952 - .saturating_add(Weight::from_ref_time(162_481 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(s as u64))) - } - // Storage: Identity Registrars (r:1 w:0) - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `533 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `15746` + // Minimum execution time: 41_319 nanoseconds. + Weight::from_parts(25_850_055, 15746) + // Standard Error: 4_144 + .saturating_add(Weight::from_ref_time(59_619).saturating_mul(r.into())) + // Standard Error: 809 + .saturating_add(Weight::from_ref_time(1_076_550).saturating_mul(s.into())) + // Standard Error: 809 + .saturating_add(Weight::from_ref_time(163_191).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + } + /// Storage: Identity Registrars (r:1 w:0) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[0, 100]`. fn request_judgement(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 44_726 nanoseconds. - Weight::from_ref_time(41_637_308 as u64) - // Standard Error: 1_907 - .saturating_add(Weight::from_ref_time(219_078 as u64).saturating_mul(r as u64)) - // Standard Error: 372 - .saturating_add(Weight::from_ref_time(309_888 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `431 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `11649` + // Minimum execution time: 28_118 nanoseconds. + Weight::from_parts(27_359_471, 11649) + // Standard Error: 2_707 + .saturating_add(Weight::from_ref_time(107_279).saturating_mul(r.into())) + // Standard Error: 528 + .saturating_add(Weight::from_ref_time(325_165).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `x` is `[0, 100]`. fn cancel_request(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 39_719 nanoseconds. - Weight::from_ref_time(38_008_751 as u64) - // Standard Error: 2_394 - .saturating_add(Weight::from_ref_time(181_870 as u64).saturating_mul(r as u64)) - // Standard Error: 467 - .saturating_add(Weight::from_ref_time(314_990 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `430 + x * (66 ±0)` + // Estimated: `10013` + // Minimum execution time: 24_817 nanoseconds. + Weight::from_parts(24_749_808, 10013) + // Standard Error: 1_938 + .saturating_add(Weight::from_ref_time(63_396).saturating_mul(r.into())) + // Standard Error: 378 + .saturating_add(Weight::from_ref_time(327_083).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn set_fee(r: u32, ) -> Weight { - // Minimum execution time: 10_634 nanoseconds. - Weight::from_ref_time(11_383_704 as u64) - // Standard Error: 2_250 - .saturating_add(Weight::from_ref_time(193_094 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `121 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 6_664 nanoseconds. + Weight::from_parts(7_286_307, 1636) + // Standard Error: 1_560 + .saturating_add(Weight::from_ref_time(96_416).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn set_account_id(r: u32, ) -> Weight { - // Minimum execution time: 10_840 nanoseconds. - Weight::from_ref_time(11_638_740 as u64) - // Standard Error: 1_985 - .saturating_add(Weight::from_ref_time(193_016 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `121 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 7_054 nanoseconds. + Weight::from_parts(7_382_954, 1636) + // Standard Error: 1_621 + .saturating_add(Weight::from_ref_time(101_595).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:1) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. fn set_fields(r: u32, ) -> Weight { - // Minimum execution time: 10_748 nanoseconds. - Weight::from_ref_time(11_346_901 as u64) - // Standard Error: 2_132 - .saturating_add(Weight::from_ref_time(196_630 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity Registrars (r:1 w:0) - // Storage: Identity IdentityOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `121 + r * (57 ±0)` + // Estimated: `1636` + // Minimum execution time: 6_659 nanoseconds. + Weight::from_parts(7_188_883, 1636) + // Standard Error: 1_377 + .saturating_add(Weight::from_ref_time(98_965).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity Registrars (r:1 w:0) + /// Proof: Identity Registrars (max_values: Some(1), max_size: Some(1141), added: 1636, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) /// The range of component `r` is `[1, 19]`. /// The range of component `x` is `[0, 100]`. fn provide_judgement(r: u32, x: u32, ) -> Weight { - // Minimum execution time: 33_682 nanoseconds. - Weight::from_ref_time(31_336_603 as u64) - // Standard Error: 3_056 - .saturating_add(Weight::from_ref_time(200_403 as u64).saturating_mul(r as u64)) - // Standard Error: 565 - .saturating_add(Weight::from_ref_time(525_142 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity SubsOf (r:1 w:1) - // Storage: Identity IdentityOf (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Identity SuperOf (r:0 w:100) + // Proof Size summary in bytes: + // Measured: `509 + r * (57 ±0) + x * (66 ±0)` + // Estimated: `11649` + // Minimum execution time: 21_567 nanoseconds. + Weight::from_parts(21_015_310, 11649) + // Standard Error: 2_516 + .saturating_add(Weight::from_ref_time(123_992).saturating_mul(r.into())) + // Standard Error: 465 + .saturating_add(Weight::from_ref_time(552_116).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) + /// Storage: Identity IdentityOf (r:1 w:1) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:0 w:100) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `r` is `[1, 20]`. /// The range of component `s` is `[0, 100]`. /// The range of component `x` is `[0, 100]`. fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight { - // Minimum execution time: 68_794 nanoseconds. - Weight::from_ref_time(52_114_486 as u64) - // Standard Error: 4_808 - .saturating_add(Weight::from_ref_time(153_462 as u64).saturating_mul(r as u64)) - // Standard Error: 939 - .saturating_add(Weight::from_ref_time(1_084_612 as u64).saturating_mul(s as u64)) - // Standard Error: 939 - .saturating_add(Weight::from_ref_time(170_112 as u64).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(s as u64))) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SuperOf (r:1 w:1) - // Storage: Identity SubsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `772 + r * (5 ±0) + s * (32 ±0) + x * (66 ±0)` + // Estimated: `18349` + // Minimum execution time: 52_881 nanoseconds. + Weight::from_parts(38_504_388, 18349) + // Standard Error: 3_909 + .saturating_add(Weight::from_ref_time(51_452).saturating_mul(r.into())) + // Standard Error: 763 + .saturating_add(Weight::from_ref_time(1_069_924).saturating_mul(s.into())) + // Standard Error: 763 + .saturating_add(Weight::from_ref_time(164_906).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) /// The range of component `s` is `[0, 99]`. fn add_sub(s: u32, ) -> Weight { - // Minimum execution time: 37_914 nanoseconds. - Weight::from_ref_time(43_488_083 as u64) - // Standard Error: 1_631 - .saturating_add(Weight::from_ref_time(118_845 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SuperOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `507 + s * (36 ±0)` + // Estimated: `18335` + // Minimum execution time: 24_556 nanoseconds. + Weight::from_parts(28_641_160, 18335) + // Standard Error: 1_327 + .saturating_add(Weight::from_ref_time(66_150).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) /// The range of component `s` is `[1, 100]`. fn rename_sub(s: u32, ) -> Weight { - // Minimum execution time: 16_124 nanoseconds. - Weight::from_ref_time(18_580_462 as u64) - // Standard Error: 688 - .saturating_add(Weight::from_ref_time(67_220 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Identity IdentityOf (r:1 w:0) - // Storage: Identity SuperOf (r:1 w:1) - // Storage: Identity SubsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `623 + s * (3 ±0)` + // Estimated: `12602` + // Minimum execution time: 11_347 nanoseconds. + Weight::from_parts(13_299_367, 12602) + // Standard Error: 525 + .saturating_add(Weight::from_ref_time(16_472).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Identity IdentityOf (r:1 w:0) + /// Proof: Identity IdentityOf (max_values: None, max_size: Some(7538), added: 10013, mode: MaxEncodedLen) + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) /// The range of component `s` is `[1, 100]`. fn remove_sub(s: u32, ) -> Weight { - // Minimum execution time: 41_517 nanoseconds. - Weight::from_ref_time(45_123_530 as u64) - // Standard Error: 1_530 - .saturating_add(Weight::from_ref_time(105_429 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Identity SuperOf (r:1 w:1) - // Storage: Identity SubsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `702 + s * (35 ±0)` + // Estimated: `18335` + // Minimum execution time: 27_810 nanoseconds. + Weight::from_parts(30_347_763, 18335) + // Standard Error: 928 + .saturating_add(Weight::from_ref_time(55_342).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Identity SuperOf (r:1 w:1) + /// Proof: Identity SuperOf (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: Identity SubsOf (r:1 w:1) + /// Proof: Identity SubsOf (max_values: None, max_size: Some(3258), added: 5733, mode: MaxEncodedLen) /// The range of component `s` is `[0, 99]`. fn quit_sub(s: u32, ) -> Weight { - // Minimum execution time: 30_171 nanoseconds. - Weight::from_ref_time(33_355_514 as u64) - // Standard Error: 1_286 - .saturating_add(Weight::from_ref_time(114_716 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `628 + s * (37 ±0)` + // Estimated: `8322` + // Minimum execution time: 17_601 nanoseconds. + Weight::from_parts(19_794_971, 8322) + // Standard Error: 934 + .saturating_add(Weight::from_ref_time(59_289).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/im-online/src/weights.rs b/frame/im-online/src/weights.rs index f81db997c3..4ea275a33f 100644 --- a/frame/im-online/src/weights.rs +++ b/frame/im-online/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_im_online //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -53,42 +54,62 @@ pub trait WeightInfo { /// Weights for pallet_im_online using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Session Validators (r:1 w:0) - // Storage: Session CurrentIndex (r:1 w:0) - // Storage: ImOnline ReceivedHeartbeats (r:1 w:1) - // Storage: ImOnline AuthoredBlocks (r:1 w:0) - // Storage: ImOnline Keys (r:1 w:0) + /// Storage: Session Validators (r:1 w:0) + /// Proof Skipped: Session Validators (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Session CurrentIndex (r:1 w:0) + /// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ImOnline Keys (r:1 w:0) + /// Proof: ImOnline Keys (max_values: Some(1), max_size: Some(320002), added: 320497, mode: MaxEncodedLen) + /// Storage: ImOnline ReceivedHeartbeats (r:1 w:1) + /// Proof: ImOnline ReceivedHeartbeats (max_values: None, max_size: Some(10021032), added: 10023507, mode: MaxEncodedLen) + /// Storage: ImOnline AuthoredBlocks (r:1 w:0) + /// Proof: ImOnline AuthoredBlocks (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) /// The range of component `k` is `[1, 1000]`. /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - // Minimum execution time: 101_380 nanoseconds. - Weight::from_ref_time(82_735_670 as u64) - // Standard Error: 121 - .saturating_add(Weight::from_ref_time(21_279 as u64).saturating_mul(k as u64)) - // Standard Error: 1_222 - .saturating_add(Weight::from_ref_time(296_343 as u64).saturating_mul(e as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `359 + k * (32 ±0)` + // Estimated: `10345712 + e * (25 ±0) + k * (64 ±0)` + // Minimum execution time: 91_116 nanoseconds. + Weight::from_parts(72_526_877, 10345712) + // Standard Error: 95 + .saturating_add(Weight::from_ref_time(20_461).saturating_mul(k.into())) + // Standard Error: 967 + .saturating_add(Weight::from_ref_time(307_869).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(25).saturating_mul(e.into())) + .saturating_add(Weight::from_proof_size(64).saturating_mul(k.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Session Validators (r:1 w:0) - // Storage: Session CurrentIndex (r:1 w:0) - // Storage: ImOnline ReceivedHeartbeats (r:1 w:1) - // Storage: ImOnline AuthoredBlocks (r:1 w:0) - // Storage: ImOnline Keys (r:1 w:0) + /// Storage: Session Validators (r:1 w:0) + /// Proof Skipped: Session Validators (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Session CurrentIndex (r:1 w:0) + /// Proof Skipped: Session CurrentIndex (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: ImOnline Keys (r:1 w:0) + /// Proof: ImOnline Keys (max_values: Some(1), max_size: Some(320002), added: 320497, mode: MaxEncodedLen) + /// Storage: ImOnline ReceivedHeartbeats (r:1 w:1) + /// Proof: ImOnline ReceivedHeartbeats (max_values: None, max_size: Some(10021032), added: 10023507, mode: MaxEncodedLen) + /// Storage: ImOnline AuthoredBlocks (r:1 w:0) + /// Proof: ImOnline AuthoredBlocks (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) /// The range of component `k` is `[1, 1000]`. /// The range of component `e` is `[1, 100]`. fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight { - // Minimum execution time: 101_380 nanoseconds. - Weight::from_ref_time(82_735_670 as u64) - // Standard Error: 121 - .saturating_add(Weight::from_ref_time(21_279 as u64).saturating_mul(k as u64)) - // Standard Error: 1_222 - .saturating_add(Weight::from_ref_time(296_343 as u64).saturating_mul(e as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `359 + k * (32 ±0)` + // Estimated: `10345712 + e * (25 ±0) + k * (64 ±0)` + // Minimum execution time: 91_116 nanoseconds. + Weight::from_parts(72_526_877, 10345712) + // Standard Error: 95 + .saturating_add(Weight::from_ref_time(20_461).saturating_mul(k.into())) + // Standard Error: 967 + .saturating_add(Weight::from_ref_time(307_869).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(25).saturating_mul(e.into())) + .saturating_add(Weight::from_proof_size(64).saturating_mul(k.into())) } } diff --git a/frame/indices/src/weights.rs b/frame/indices/src/weights.rs index 7b974875cd..36dd79ece4 100644 --- a/frame/indices/src/weights.rs +++ b/frame/indices/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_indices //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -57,82 +58,126 @@ pub trait WeightInfo { /// Weights for pallet_indices using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Indices Accounts (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn claim() -> Weight { - // Minimum execution time: 31_756 nanoseconds. - Weight::from_ref_time(32_252_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `2544` + // Minimum execution time: 19_738 nanoseconds. + Weight::from_parts(20_029_000, 2544) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Indices Accounts (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 38_686 nanoseconds. - Weight::from_ref_time(39_402_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `5147` + // Minimum execution time: 24_494 nanoseconds. + Weight::from_parts(24_794_000, 5147) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Indices Accounts (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn free() -> Weight { - // Minimum execution time: 33_752 nanoseconds. - Weight::from_ref_time(34_348_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `204` + // Estimated: `2544` + // Minimum execution time: 20_041 nanoseconds. + Weight::from_parts(20_473_000, 2544) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Indices Accounts (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { - // Minimum execution time: 32_739 nanoseconds. - Weight::from_ref_time(33_151_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `5147` + // Minimum execution time: 21_874 nanoseconds. + Weight::from_parts(22_438_000, 5147) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Indices Accounts (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn freeze() -> Weight { - // Minimum execution time: 40_369 nanoseconds. - Weight::from_ref_time(40_982_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `204` + // Estimated: `2544` + // Minimum execution time: 22_407 nanoseconds. + Weight::from_parts(22_768_000, 2544) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Indices Accounts (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn claim() -> Weight { - // Minimum execution time: 31_756 nanoseconds. - Weight::from_ref_time(32_252_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `2544` + // Minimum execution time: 19_738 nanoseconds. + Weight::from_parts(20_029_000, 2544) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Indices Accounts (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 38_686 nanoseconds. - Weight::from_ref_time(39_402_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `5147` + // Minimum execution time: 24_494 nanoseconds. + Weight::from_parts(24_794_000, 5147) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Indices Accounts (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn free() -> Weight { - // Minimum execution time: 33_752 nanoseconds. - Weight::from_ref_time(34_348_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `204` + // Estimated: `2544` + // Minimum execution time: 20_041 nanoseconds. + Weight::from_parts(20_473_000, 2544) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Indices Accounts (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn force_transfer() -> Weight { - // Minimum execution time: 32_739 nanoseconds. - Weight::from_ref_time(33_151_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `339` + // Estimated: `5147` + // Minimum execution time: 21_874 nanoseconds. + Weight::from_parts(22_438_000, 5147) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Indices Accounts (r:1 w:1) + /// Storage: Indices Accounts (r:1 w:1) + /// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn freeze() -> Weight { - // Minimum execution time: 40_369 nanoseconds. - Weight::from_ref_time(40_982_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `204` + // Estimated: `2544` + // Minimum execution time: 22_407 nanoseconds. + Weight::from_parts(22_768_000, 2544) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/lottery/src/weights.rs b/frame/lottery/src/weights.rs index e9ee528cc4..e2cf9ea2b7 100644 --- a/frame/lottery/src/weights.rs +++ b/frame/lottery/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_lottery //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_lottery // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_lottery -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/lottery/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -59,130 +59,212 @@ pub trait WeightInfo { /// Weights for pallet_lottery using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Lottery Lottery (r:1 w:0) - // Storage: Lottery CallIndices (r:1 w:0) - // Storage: Lottery TicketsCount (r:1 w:1) - // Storage: Lottery Participants (r:1 w:1) - // Storage: Lottery LotteryIndex (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Lottery Tickets (r:0 w:1) + /// Storage: Lottery Lottery (r:1 w:0) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: Lottery CallIndices (r:1 w:0) + /// Proof: Lottery CallIndices (max_values: Some(1), max_size: Some(21), added: 516, mode: MaxEncodedLen) + /// Storage: Lottery TicketsCount (r:1 w:1) + /// Proof: Lottery TicketsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Lottery Participants (r:1 w:1) + /// Proof: Lottery Participants (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + /// Storage: Lottery LotteryIndex (r:1 w:0) + /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Lottery Tickets (r:0 w:1) + /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn buy_ticket() -> Weight { - // Minimum execution time: 52_479 nanoseconds. - Weight::from_ref_time(53_225_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `484` + // Estimated: `7181` + // Minimum execution time: 62_125 nanoseconds. + Weight::from_parts(63_145_000, 7181) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: Lottery CallIndices (r:0 w:1) + /// Storage: Lottery CallIndices (r:0 w:1) + /// Proof: Lottery CallIndices (max_values: Some(1), max_size: Some(21), added: 516, mode: MaxEncodedLen) /// The range of component `n` is `[0, 10]`. fn set_calls(n: u32, ) -> Weight { - // Minimum execution time: 14_433 nanoseconds. - Weight::from_ref_time(15_660_780) - // Standard Error: 5_894 - .saturating_add(Weight::from_ref_time(290_482).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_650 nanoseconds. + Weight::from_ref_time(8_344_960) + // Standard Error: 2_629 + .saturating_add(Weight::from_ref_time(268_557).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Lottery Lottery (r:1 w:1) - // Storage: Lottery LotteryIndex (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: Lottery LotteryIndex (r:1 w:1) + /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn start_lottery() -> Weight { - // Minimum execution time: 43_683 nanoseconds. - Weight::from_ref_time(44_580_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `3626` + // Minimum execution time: 31_324 nanoseconds. + Weight::from_parts(31_985_000, 3626) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Lottery Lottery (r:1 w:1) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) fn stop_repeat() -> Weight { - // Minimum execution time: 10_514 nanoseconds. - Weight::from_ref_time(10_821_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `219` + // Estimated: `524` + // Minimum execution time: 7_124 nanoseconds. + Weight::from_parts(7_285_000, 524) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - // Storage: Lottery Lottery (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Lottery TicketsCount (r:1 w:1) - // Storage: Lottery Tickets (r:1 w:0) + /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Lottery TicketsCount (r:1 w:1) + /// Proof: Lottery TicketsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Lottery Tickets (r:1 w:0) + /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn on_initialize_end() -> Weight { - // Minimum execution time: 60_254 nanoseconds. - Weight::from_ref_time(61_924_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `556` + // Estimated: `11837` + // Minimum execution time: 50_745 nanoseconds. + Weight::from_parts(52_232_000, 11837) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - // Storage: Lottery Lottery (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Lottery TicketsCount (r:1 w:1) - // Storage: Lottery Tickets (r:1 w:0) - // Storage: Lottery LotteryIndex (r:1 w:1) + /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Lottery TicketsCount (r:1 w:1) + /// Proof: Lottery TicketsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Lottery Tickets (r:1 w:0) + /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: Lottery LotteryIndex (r:1 w:1) + /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn on_initialize_repeat() -> Weight { - // Minimum execution time: 61_552 nanoseconds. - Weight::from_ref_time(62_152_000) - .saturating_add(T::DbWeight::get().reads(7)) - .saturating_add(T::DbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `556` + // Estimated: `12336` + // Minimum execution time: 52_437 nanoseconds. + Weight::from_parts(53_063_000, 12336) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Lottery Lottery (r:1 w:0) - // Storage: Lottery CallIndices (r:1 w:0) - // Storage: Lottery TicketsCount (r:1 w:1) - // Storage: Lottery Participants (r:1 w:1) - // Storage: Lottery LotteryIndex (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Lottery Tickets (r:0 w:1) + /// Storage: Lottery Lottery (r:1 w:0) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: Lottery CallIndices (r:1 w:0) + /// Proof: Lottery CallIndices (max_values: Some(1), max_size: Some(21), added: 516, mode: MaxEncodedLen) + /// Storage: Lottery TicketsCount (r:1 w:1) + /// Proof: Lottery TicketsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Lottery Participants (r:1 w:1) + /// Proof: Lottery Participants (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + /// Storage: Lottery LotteryIndex (r:1 w:0) + /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Lottery Tickets (r:0 w:1) + /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn buy_ticket() -> Weight { - // Minimum execution time: 52_479 nanoseconds. - Weight::from_ref_time(53_225_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `484` + // Estimated: `7181` + // Minimum execution time: 62_125 nanoseconds. + Weight::from_parts(63_145_000, 7181) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: Lottery CallIndices (r:0 w:1) + /// Storage: Lottery CallIndices (r:0 w:1) + /// Proof: Lottery CallIndices (max_values: Some(1), max_size: Some(21), added: 516, mode: MaxEncodedLen) /// The range of component `n` is `[0, 10]`. fn set_calls(n: u32, ) -> Weight { - // Minimum execution time: 14_433 nanoseconds. - Weight::from_ref_time(15_660_780) - // Standard Error: 5_894 - .saturating_add(Weight::from_ref_time(290_482).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_650 nanoseconds. + Weight::from_ref_time(8_344_960) + // Standard Error: 2_629 + .saturating_add(Weight::from_ref_time(268_557).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Lottery Lottery (r:1 w:1) - // Storage: Lottery LotteryIndex (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: Lottery LotteryIndex (r:1 w:1) + /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn start_lottery() -> Weight { - // Minimum execution time: 43_683 nanoseconds. - Weight::from_ref_time(44_580_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `3626` + // Minimum execution time: 31_324 nanoseconds. + Weight::from_parts(31_985_000, 3626) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Lottery Lottery (r:1 w:1) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) fn stop_repeat() -> Weight { - // Minimum execution time: 10_514 nanoseconds. - Weight::from_ref_time(10_821_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `219` + // Estimated: `524` + // Minimum execution time: 7_124 nanoseconds. + Weight::from_parts(7_285_000, 524) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - // Storage: Lottery Lottery (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Lottery TicketsCount (r:1 w:1) - // Storage: Lottery Tickets (r:1 w:0) + /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Lottery TicketsCount (r:1 w:1) + /// Proof: Lottery TicketsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Lottery Tickets (r:1 w:0) + /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) fn on_initialize_end() -> Weight { - // Minimum execution time: 60_254 nanoseconds. - Weight::from_ref_time(61_924_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(4)) + // Proof Size summary in bytes: + // Measured: `556` + // Estimated: `11837` + // Minimum execution time: 50_745 nanoseconds. + Weight::from_parts(52_232_000, 11837) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) - // Storage: Lottery Lottery (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Lottery TicketsCount (r:1 w:1) - // Storage: Lottery Tickets (r:1 w:0) - // Storage: Lottery LotteryIndex (r:1 w:1) + /// Storage: RandomnessCollectiveFlip RandomMaterial (r:1 w:0) + /// Proof: RandomnessCollectiveFlip RandomMaterial (max_values: Some(1), max_size: Some(2594), added: 3089, mode: MaxEncodedLen) + /// Storage: Lottery Lottery (r:1 w:1) + /// Proof: Lottery Lottery (max_values: Some(1), max_size: Some(29), added: 524, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Lottery TicketsCount (r:1 w:1) + /// Proof: Lottery TicketsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Lottery Tickets (r:1 w:0) + /// Proof: Lottery Tickets (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: Lottery LotteryIndex (r:1 w:1) + /// Proof: Lottery LotteryIndex (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn on_initialize_repeat() -> Weight { - // Minimum execution time: 61_552 nanoseconds. - Weight::from_ref_time(62_152_000) - .saturating_add(RocksDbWeight::get().reads(7)) - .saturating_add(RocksDbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `556` + // Estimated: `12336` + // Minimum execution time: 52_437 nanoseconds. + Weight::from_parts(53_063_000, 12336) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } } diff --git a/frame/membership/src/weights.rs b/frame/membership/src/weights.rs index 11574bc8fa..1be50afc52 100644 --- a/frame/membership/src/weights.rs +++ b/frame/membership/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_membership //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -59,190 +60,302 @@ pub trait WeightInfo { /// Weights for pallet_membership using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { - // Minimum execution time: 23_796 nanoseconds. - Weight::from_ref_time(24_829_996 as u64) - // Standard Error: 723 - .saturating_add(Weight::from_ref_time(48_467 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `238 + m * (64 ±0)` + // Estimated: `4903 + m * (192 ±0)` + // Minimum execution time: 15_673 nanoseconds. + Weight::from_parts(16_830_288, 4903) + // Standard Error: 570 + .saturating_add(Weight::from_ref_time(41_959).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:0) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { - // Minimum execution time: 27_255 nanoseconds. - Weight::from_ref_time(28_234_490 as u64) - // Standard Error: 833 - .saturating_add(Weight::from_ref_time(34_894 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 18_231 nanoseconds. + Weight::from_parts(19_081_297, 5742) + // Standard Error: 571 + .saturating_add(Weight::from_ref_time(41_331).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:0) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { - // Minimum execution time: 26_626 nanoseconds. - Weight::from_ref_time(27_989_042 as u64) - // Standard Error: 729 - .saturating_add(Weight::from_ref_time(51_567 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 18_517 nanoseconds. + Weight::from_parts(19_388_310, 5742) + // Standard Error: 625 + .saturating_add(Weight::from_ref_time(51_422).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:0) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { - // Minimum execution time: 25_412 nanoseconds. - Weight::from_ref_time(27_713_414 as u64) - // Standard Error: 883 - .saturating_add(Weight::from_ref_time(157_085 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 17_628 nanoseconds. + Weight::from_parts(19_258_882, 5742) + // Standard Error: 820 + .saturating_add(Weight::from_ref_time(153_956).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:1) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:1) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { - // Minimum execution time: 27_122 nanoseconds. - Weight::from_ref_time(28_477_394 as u64) - // Standard Error: 801 - .saturating_add(Weight::from_ref_time(56_383 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 19_031 nanoseconds. + Weight::from_parts(20_264_948, 5742) + // Standard Error: 707 + .saturating_add(Weight::from_ref_time(51_060).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:0) - // Storage: TechnicalMembership Prime (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:0) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalMembership Prime (r:0 w:1) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { - // Minimum execution time: 9_368 nanoseconds. - Weight::from_ref_time(10_133_132 as u64) - // Standard Error: 366 - .saturating_add(Weight::from_ref_time(17_708 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `64 + m * (32 ±0)` + // Estimated: `3761 + m * (32 ±0)` + // Minimum execution time: 6_897 nanoseconds. + Weight::from_parts(7_455_387, 3761) + // Standard Error: 326 + .saturating_add(Weight::from_ref_time(16_653).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(32).saturating_mul(m.into())) } - // Storage: TechnicalMembership Prime (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Prime (r:0 w:1) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn clear_prime(m: u32, ) -> Weight { - // Minimum execution time: 5_546 nanoseconds. - Weight::from_ref_time(5_962_740 as u64) - // Standard Error: 186 - .saturating_add(Weight::from_ref_time(2_096 as u64).saturating_mul(m as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_400 nanoseconds. + Weight::from_ref_time(3_703_421) + // Standard Error: 119 + .saturating_add(Weight::from_ref_time(915).saturating_mul(m.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 99]`. fn add_member(m: u32, ) -> Weight { - // Minimum execution time: 23_796 nanoseconds. - Weight::from_ref_time(24_829_996 as u64) - // Standard Error: 723 - .saturating_add(Weight::from_ref_time(48_467 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `238 + m * (64 ±0)` + // Estimated: `4903 + m * (192 ±0)` + // Minimum execution time: 15_673 nanoseconds. + Weight::from_parts(16_830_288, 4903) + // Standard Error: 570 + .saturating_add(Weight::from_ref_time(41_959).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:0) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[2, 100]`. fn remove_member(m: u32, ) -> Weight { - // Minimum execution time: 27_255 nanoseconds. - Weight::from_ref_time(28_234_490 as u64) - // Standard Error: 833 - .saturating_add(Weight::from_ref_time(34_894 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 18_231 nanoseconds. + Weight::from_parts(19_081_297, 5742) + // Standard Error: 571 + .saturating_add(Weight::from_ref_time(41_331).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:0) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[2, 100]`. fn swap_member(m: u32, ) -> Weight { - // Minimum execution time: 26_626 nanoseconds. - Weight::from_ref_time(27_989_042 as u64) - // Standard Error: 729 - .saturating_add(Weight::from_ref_time(51_567 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 18_517 nanoseconds. + Weight::from_parts(19_388_310, 5742) + // Standard Error: 625 + .saturating_add(Weight::from_ref_time(51_422).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:0) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:0) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn reset_member(m: u32, ) -> Weight { - // Minimum execution time: 25_412 nanoseconds. - Weight::from_ref_time(27_713_414 as u64) - // Standard Error: 883 - .saturating_add(Weight::from_ref_time(157_085 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 17_628 nanoseconds. + Weight::from_parts(19_258_882, 5742) + // Standard Error: 820 + .saturating_add(Weight::from_ref_time(153_956).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:1) - // Storage: TechnicalCommittee Proposals (r:1 w:0) - // Storage: TechnicalMembership Prime (r:1 w:1) - // Storage: TechnicalCommittee Members (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:1) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Proposals (r:1 w:0) + /// Proof Skipped: TechnicalCommittee Proposals (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalMembership Prime (r:1 w:1) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Members (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn change_key(m: u32, ) -> Weight { - // Minimum execution time: 27_122 nanoseconds. - Weight::from_ref_time(28_477_394 as u64) - // Standard Error: 801 - .saturating_add(Weight::from_ref_time(56_383 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `342 + m * (64 ±0)` + // Estimated: `5742 + m * (192 ±0)` + // Minimum execution time: 19_031 nanoseconds. + Weight::from_parts(20_264_948, 5742) + // Standard Error: 707 + .saturating_add(Weight::from_ref_time(51_060).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(m.into())) } - // Storage: TechnicalMembership Members (r:1 w:0) - // Storage: TechnicalMembership Prime (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Members (r:1 w:0) + /// Proof: TechnicalMembership Members (max_values: Some(1), max_size: Some(3202), added: 3697, mode: MaxEncodedLen) + /// Storage: TechnicalMembership Prime (r:0 w:1) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn set_prime(m: u32, ) -> Weight { - // Minimum execution time: 9_368 nanoseconds. - Weight::from_ref_time(10_133_132 as u64) - // Standard Error: 366 - .saturating_add(Weight::from_ref_time(17_708 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `64 + m * (32 ±0)` + // Estimated: `3761 + m * (32 ±0)` + // Minimum execution time: 6_897 nanoseconds. + Weight::from_parts(7_455_387, 3761) + // Standard Error: 326 + .saturating_add(Weight::from_ref_time(16_653).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(32).saturating_mul(m.into())) } - // Storage: TechnicalMembership Prime (r:0 w:1) - // Storage: TechnicalCommittee Prime (r:0 w:1) + /// Storage: TechnicalMembership Prime (r:0 w:1) + /// Proof: TechnicalMembership Prime (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TechnicalCommittee Prime (r:0 w:1) + /// Proof Skipped: TechnicalCommittee Prime (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `m` is `[1, 100]`. fn clear_prime(m: u32, ) -> Weight { - // Minimum execution time: 5_546 nanoseconds. - Weight::from_ref_time(5_962_740 as u64) - // Standard Error: 186 - .saturating_add(Weight::from_ref_time(2_096 as u64).saturating_mul(m as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_400 nanoseconds. + Weight::from_ref_time(3_703_421) + // Standard Error: 119 + .saturating_add(Weight::from_ref_time(915).saturating_mul(m.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/message-queue/src/weights.rs b/frame/message-queue/src/weights.rs index cd9268ffde..325fc20830 100644 --- a/frame/message-queue/src/weights.rs +++ b/frame/message-queue/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_message_queue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_message_queue // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_message_queue -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/message-queue/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -63,154 +63,244 @@ pub trait WeightInfo { /// Weights for pallet_message_queue using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: MessageQueue ServiceHead (r:1 w:0) - // Storage: MessageQueue BookStateFor (r:2 w:2) + /// Storage: MessageQueue ServiceHead (r:1 w:0) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn ready_ring_knit() -> Weight { - // Minimum execution time: 12_330 nanoseconds. - Weight::from_ref_time(12_711_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `837` + // Estimated: `5554` + // Minimum execution time: 12_676 nanoseconds. + Weight::from_parts(13_113_000, 5554) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: MessageQueue BookStateFor (r:2 w:2) - // Storage: MessageQueue ServiceHead (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:1) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) fn ready_ring_unknit() -> Weight { - // Minimum execution time: 12_322 nanoseconds. - Weight::from_ref_time(12_560_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `837` + // Estimated: `5554` + // Minimum execution time: 12_654 nanoseconds. + Weight::from_parts(12_969_000, 5554) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn service_queue_base() -> Weight { - // Minimum execution time: 4_652 nanoseconds. - Weight::from_ref_time(4_848_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `576` + // Estimated: `2527` + // Minimum execution time: 5_096 nanoseconds. + Weight::from_parts(5_280_000, 2527) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn service_page_base_completion() -> Weight { - // Minimum execution time: 7_115 nanoseconds. - Weight::from_ref_time(7_407_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `648` + // Estimated: `68060` + // Minimum execution time: 7_291 nanoseconds. + Weight::from_parts(7_564_000, 68060) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn service_page_base_no_completion() -> Weight { - // Minimum execution time: 6_974 nanoseconds. - Weight::from_ref_time(7_200_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `648` + // Estimated: `68060` + // Minimum execution time: 7_401 nanoseconds. + Weight::from_parts(7_681_000, 68060) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn service_page_item() -> Weight { - // Minimum execution time: 79_657 nanoseconds. - Weight::from_ref_time(80_050_000) + // Proof Size summary in bytes: + // Measured: `972` + // Estimated: `0` + // Minimum execution time: 79_412 nanoseconds. + Weight::from_ref_time(79_816_000) } - // Storage: MessageQueue ServiceHead (r:1 w:1) - // Storage: MessageQueue BookStateFor (r:1 w:0) + /// Storage: MessageQueue ServiceHead (r:1 w:1) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:1 w:0) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn bump_service_head() -> Weight { - // Minimum execution time: 7_598 nanoseconds. - Weight::from_ref_time(8_118_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `712` + // Estimated: `3027` + // Minimum execution time: 8_258 nanoseconds. + Weight::from_parts(8_438_000, 3027) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn reap_page() -> Weight { - // Minimum execution time: 60_562 nanoseconds. - Weight::from_ref_time(61_430_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `66827` + // Estimated: `70587` + // Minimum execution time: 61_361 nanoseconds. + Weight::from_parts(62_103_000, 70587) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn execute_overweight_page_removed() -> Weight { - // Minimum execution time: 74_582 nanoseconds. - Weight::from_ref_time(75_445_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `66827` + // Estimated: `70587` + // Minimum execution time: 75_153 nanoseconds. + Weight::from_parts(76_093_000, 70587) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn execute_overweight_page_updated() -> Weight { - // Minimum execution time: 87_526 nanoseconds. - Weight::from_ref_time(88_055_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `66827` + // Estimated: `70587` + // Minimum execution time: 88_272 nanoseconds. + Weight::from_parts(89_373_000, 70587) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: MessageQueue ServiceHead (r:1 w:0) - // Storage: MessageQueue BookStateFor (r:2 w:2) + /// Storage: MessageQueue ServiceHead (r:1 w:0) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn ready_ring_knit() -> Weight { - // Minimum execution time: 12_330 nanoseconds. - Weight::from_ref_time(12_711_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `837` + // Estimated: `5554` + // Minimum execution time: 12_676 nanoseconds. + Weight::from_parts(13_113_000, 5554) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: MessageQueue BookStateFor (r:2 w:2) - // Storage: MessageQueue ServiceHead (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:2 w:2) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue ServiceHead (r:1 w:1) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) fn ready_ring_unknit() -> Weight { - // Minimum execution time: 12_322 nanoseconds. - Weight::from_ref_time(12_560_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `837` + // Estimated: `5554` + // Minimum execution time: 12_654 nanoseconds. + Weight::from_parts(12_969_000, 5554) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn service_queue_base() -> Weight { - // Minimum execution time: 4_652 nanoseconds. - Weight::from_ref_time(4_848_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `576` + // Estimated: `2527` + // Minimum execution time: 5_096 nanoseconds. + Weight::from_parts(5_280_000, 2527) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn service_page_base_completion() -> Weight { - // Minimum execution time: 7_115 nanoseconds. - Weight::from_ref_time(7_407_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `648` + // Estimated: `68060` + // Minimum execution time: 7_291 nanoseconds. + Weight::from_parts(7_564_000, 68060) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn service_page_base_no_completion() -> Weight { - // Minimum execution time: 6_974 nanoseconds. - Weight::from_ref_time(7_200_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `648` + // Estimated: `68060` + // Minimum execution time: 7_401 nanoseconds. + Weight::from_parts(7_681_000, 68060) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn service_page_item() -> Weight { - // Minimum execution time: 79_657 nanoseconds. - Weight::from_ref_time(80_050_000) + // Proof Size summary in bytes: + // Measured: `972` + // Estimated: `0` + // Minimum execution time: 79_412 nanoseconds. + Weight::from_ref_time(79_816_000) } - // Storage: MessageQueue ServiceHead (r:1 w:1) - // Storage: MessageQueue BookStateFor (r:1 w:0) + /// Storage: MessageQueue ServiceHead (r:1 w:1) + /// Proof: MessageQueue ServiceHead (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: MessageQueue BookStateFor (r:1 w:0) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn bump_service_head() -> Weight { - // Minimum execution time: 7_598 nanoseconds. - Weight::from_ref_time(8_118_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `712` + // Estimated: `3027` + // Minimum execution time: 8_258 nanoseconds. + Weight::from_parts(8_438_000, 3027) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn reap_page() -> Weight { - // Minimum execution time: 60_562 nanoseconds. - Weight::from_ref_time(61_430_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `66827` + // Estimated: `70587` + // Minimum execution time: 61_361 nanoseconds. + Weight::from_parts(62_103_000, 70587) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn execute_overweight_page_removed() -> Weight { - // Minimum execution time: 74_582 nanoseconds. - Weight::from_ref_time(75_445_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `66827` + // Estimated: `70587` + // Minimum execution time: 75_153 nanoseconds. + Weight::from_parts(76_093_000, 70587) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: MessageQueue BookStateFor (r:1 w:1) - // Storage: MessageQueue Pages (r:1 w:1) + /// Storage: MessageQueue BookStateFor (r:1 w:1) + /// Proof: MessageQueue BookStateFor (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: MessageQueue Pages (r:1 w:1) + /// Proof: MessageQueue Pages (max_values: None, max_size: Some(65585), added: 68060, mode: MaxEncodedLen) fn execute_overweight_page_updated() -> Weight { - // Minimum execution time: 87_526 nanoseconds. - Weight::from_ref_time(88_055_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `66827` + // Estimated: `70587` + // Minimum execution time: 88_272 nanoseconds. + Weight::from_parts(89_373_000, 70587) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/multisig/src/weights.rs b/frame/multisig/src/weights.rs index 1f435cb9f9..46bf911f27 100644 --- a/frame/multisig/src/weights.rs +++ b/frame/multisig/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_multisig //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -61,82 +62,108 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// The range of component `z` is `[0, 10000]`. fn as_multi_threshold_1(z: u32, ) -> Weight { - // Minimum execution time: 20_447 nanoseconds. - Weight::from_ref_time(20_896_236 as u64) - // Standard Error: 2 - .saturating_add(Weight::from_ref_time(568 as u64).saturating_mul(z as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 12_086 nanoseconds. + Weight::from_ref_time(12_464_828) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(494).saturating_mul(z.into())) } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { - // Minimum execution time: 54_987 nanoseconds. - Weight::from_ref_time(42_525_077 as u64) - // Standard Error: 562 - .saturating_add(Weight::from_ref_time(136_064 as u64).saturating_mul(s as u64)) - // Standard Error: 5 - .saturating_add(Weight::from_ref_time(1_508 as u64).saturating_mul(z as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `352 + s * (2 ±0)` + // Estimated: `5821` + // Minimum execution time: 35_377 nanoseconds. + Weight::from_parts(29_088_956, 5821) + // Standard Error: 335 + .saturating_add(Weight::from_ref_time(67_846).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_ref_time(1_523).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { - // Minimum execution time: 42_573 nanoseconds. - Weight::from_ref_time(30_585_734 as u64) - // Standard Error: 637 - .saturating_add(Weight::from_ref_time(128_012 as u64).saturating_mul(s as u64)) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(1_507 as u64).saturating_mul(z as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `5821` + // Minimum execution time: 26_138 nanoseconds. + Weight::from_parts(20_479_380, 5821) + // Standard Error: 259 + .saturating_add(Weight::from_ref_time(64_116).saturating_mul(s.into())) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(1_520).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { - // Minimum execution time: 57_143 nanoseconds. - Weight::from_ref_time(43_921_674 as u64) - // Standard Error: 704 - .saturating_add(Weight::from_ref_time(153_474 as u64).saturating_mul(s as u64)) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(1_536 as u64).saturating_mul(z as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `489 + s * (33 ±0)` + // Estimated: `8424` + // Minimum execution time: 40_323 nanoseconds. + Weight::from_parts(32_311_615, 8424) + // Standard Error: 401 + .saturating_add(Weight::from_ref_time(85_999).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_ref_time(1_534).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { - // Minimum execution time: 39_088 nanoseconds. - Weight::from_ref_time(41_258_697 as u64) - // Standard Error: 1_038 - .saturating_add(Weight::from_ref_time(126_040 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `359 + s * (2 ±0)` + // Estimated: `5821` + // Minimum execution time: 26_938 nanoseconds. + Weight::from_parts(27_802_216, 5821) + // Standard Error: 342 + .saturating_add(Weight::from_ref_time(69_282).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { - // Minimum execution time: 26_872 nanoseconds. - Weight::from_ref_time(28_625_218 as u64) - // Standard Error: 793 - .saturating_add(Weight::from_ref_time(128_542 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `5821` + // Minimum execution time: 18_050 nanoseconds. + Weight::from_parts(19_095_404, 5821) + // Standard Error: 419 + .saturating_add(Weight::from_ref_time(66_914).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { - // Minimum execution time: 37_636 nanoseconds. - Weight::from_ref_time(39_614_705 as u64) - // Standard Error: 850 - .saturating_add(Weight::from_ref_time(136_222 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `555 + s * (1 ±0)` + // Estimated: `5821` + // Minimum execution time: 27_508 nanoseconds. + Weight::from_parts(28_702_686, 5821) + // Standard Error: 466 + .saturating_add(Weight::from_ref_time(69_419).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } @@ -144,81 +171,107 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { /// The range of component `z` is `[0, 10000]`. fn as_multi_threshold_1(z: u32, ) -> Weight { - // Minimum execution time: 20_447 nanoseconds. - Weight::from_ref_time(20_896_236 as u64) - // Standard Error: 2 - .saturating_add(Weight::from_ref_time(568 as u64).saturating_mul(z as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 12_086 nanoseconds. + Weight::from_ref_time(12_464_828) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(494).saturating_mul(z.into())) } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_create(s: u32, z: u32, ) -> Weight { - // Minimum execution time: 54_987 nanoseconds. - Weight::from_ref_time(42_525_077 as u64) - // Standard Error: 562 - .saturating_add(Weight::from_ref_time(136_064 as u64).saturating_mul(s as u64)) - // Standard Error: 5 - .saturating_add(Weight::from_ref_time(1_508 as u64).saturating_mul(z as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `352 + s * (2 ±0)` + // Estimated: `5821` + // Minimum execution time: 35_377 nanoseconds. + Weight::from_parts(29_088_956, 5821) + // Standard Error: 335 + .saturating_add(Weight::from_ref_time(67_846).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_ref_time(1_523).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[3, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_approve(s: u32, z: u32, ) -> Weight { - // Minimum execution time: 42_573 nanoseconds. - Weight::from_ref_time(30_585_734 as u64) - // Standard Error: 637 - .saturating_add(Weight::from_ref_time(128_012 as u64).saturating_mul(s as u64)) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(1_507 as u64).saturating_mul(z as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `5821` + // Minimum execution time: 26_138 nanoseconds. + Weight::from_parts(20_479_380, 5821) + // Standard Error: 259 + .saturating_add(Weight::from_ref_time(64_116).saturating_mul(s.into())) + // Standard Error: 2 + .saturating_add(Weight::from_ref_time(1_520).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. /// The range of component `z` is `[0, 10000]`. fn as_multi_complete(s: u32, z: u32, ) -> Weight { - // Minimum execution time: 57_143 nanoseconds. - Weight::from_ref_time(43_921_674 as u64) - // Standard Error: 704 - .saturating_add(Weight::from_ref_time(153_474 as u64).saturating_mul(s as u64)) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(1_536 as u64).saturating_mul(z as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `489 + s * (33 ±0)` + // Estimated: `8424` + // Minimum execution time: 40_323 nanoseconds. + Weight::from_parts(32_311_615, 8424) + // Standard Error: 401 + .saturating_add(Weight::from_ref_time(85_999).saturating_mul(s.into())) + // Standard Error: 3 + .saturating_add(Weight::from_ref_time(1_534).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_create(s: u32, ) -> Weight { - // Minimum execution time: 39_088 nanoseconds. - Weight::from_ref_time(41_258_697 as u64) - // Standard Error: 1_038 - .saturating_add(Weight::from_ref_time(126_040 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `359 + s * (2 ±0)` + // Estimated: `5821` + // Minimum execution time: 26_938 nanoseconds. + Weight::from_parts(27_802_216, 5821) + // Standard Error: 342 + .saturating_add(Weight::from_ref_time(69_282).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. fn approve_as_multi_approve(s: u32, ) -> Weight { - // Minimum execution time: 26_872 nanoseconds. - Weight::from_ref_time(28_625_218 as u64) - // Standard Error: 793 - .saturating_add(Weight::from_ref_time(128_542 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `351` + // Estimated: `5821` + // Minimum execution time: 18_050 nanoseconds. + Weight::from_parts(19_095_404, 5821) + // Standard Error: 419 + .saturating_add(Weight::from_ref_time(66_914).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Multisig Multisigs (r:1 w:1) + /// Storage: Multisig Multisigs (r:1 w:1) + /// Proof: Multisig Multisigs (max_values: None, max_size: Some(3346), added: 5821, mode: MaxEncodedLen) /// The range of component `s` is `[2, 100]`. fn cancel_as_multi(s: u32, ) -> Weight { - // Minimum execution time: 37_636 nanoseconds. - Weight::from_ref_time(39_614_705 as u64) - // Standard Error: 850 - .saturating_add(Weight::from_ref_time(136_222 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `555 + s * (1 ±0)` + // Estimated: `5821` + // Minimum execution time: 27_508 nanoseconds. + Weight::from_parts(28_702_686, 5821) + // Standard Error: 466 + .saturating_add(Weight::from_ref_time(69_419).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/nfts/src/weights.rs b/frame/nfts/src/weights.rs index f05f8ca514..81be145b67 100644 --- a/frame/nfts/src/weights.rs +++ b/frame/nfts/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_nfts //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_nfts // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_nfts -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/nfts/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -90,762 +90,1264 @@ pub trait WeightInfo { /// Weights for pallet_nfts using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Nfts NextCollectionId (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:0 w:1) - // Storage: Nfts CollectionConfigOf (r:0 w:1) - // Storage: Nfts CollectionAccount (r:0 w:1) + /// Storage: Nfts NextCollectionId (r:1 w:1) + /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 44_312 nanoseconds. - Weight::from_ref_time(44_871_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: Nfts NextCollectionId (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:0 w:1) - // Storage: Nfts CollectionConfigOf (r:0 w:1) - // Storage: Nfts CollectionAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `214` + // Estimated: `3054` + // Minimum execution time: 32_467 nanoseconds. + Weight::from_parts(33_236_000, 3054) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Nfts NextCollectionId (r:1 w:1) + /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_create() -> Weight { - // Minimum execution time: 31_654 nanoseconds. - Weight::from_ref_time(32_078_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts Item (r:1001 w:1000) - // Storage: Nfts Attribute (r:1001 w:1000) - // Storage: Nfts ItemMetadataOf (r:0 w:1000) - // Storage: Nfts CollectionRoleOf (r:0 w:1) - // Storage: Nfts CollectionMetadataOf (r:0 w:1) - // Storage: Nfts CollectionConfigOf (r:0 w:1) - // Storage: Nfts ItemConfigOf (r:0 w:1000) - // Storage: Nfts Account (r:0 w:1000) - // Storage: Nfts CollectionAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3054` + // Minimum execution time: 22_198 nanoseconds. + Weight::from_parts(22_776_000, 3054) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1001 w:1000) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1001 w:1000) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1001 w:1000) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:0 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:0 w:1000) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1000) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - // Minimum execution time: 19_183_393 nanoseconds. - Weight::from_ref_time(17_061_526_855) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(353_523).saturating_mul(n.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(1_861_080).saturating_mul(m.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(8_858_987).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(1003)) + // Proof Size summary in bytes: + // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` + // Estimated: `3347427 + a * (2921 ±0) + m * (2615 ±0)` + // Minimum execution time: 24_021_657 nanoseconds. + Weight::from_parts(16_029_391_606, 3347427) + // Standard Error: 20_364 + .saturating_add(Weight::from_ref_time(300_580).saturating_mul(n.into())) + // Standard Error: 20_364 + .saturating_add(Weight::from_ref_time(7_748_502).saturating_mul(m.into())) + // Standard Error: 20_364 + .saturating_add(Weight::from_ref_time(9_183_566).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1004_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) - .saturating_add(T::DbWeight::get().writes(3005)) + .saturating_add(T::DbWeight::get().writes(3005_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) - } - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) - // Storage: Nfts Account (r:0 w:1) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(a.into())) + .saturating_add(Weight::from_proof_size(2615).saturating_mul(m.into())) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { - // Minimum execution time: 57_753 nanoseconds. - Weight::from_ref_time(58_313_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) - // Storage: Nfts Account (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `448` + // Estimated: `13506` + // Minimum execution time: 42_634 nanoseconds. + Weight::from_parts(43_231_000, 13506) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn force_mint() -> Weight { - // Minimum execution time: 56_429 nanoseconds. - Weight::from_ref_time(57_202_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) - // Storage: Nfts Account (r:0 w:1) - // Storage: Nfts ItemPriceOf (r:0 w:1) - // Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `448` + // Estimated: `13506` + // Minimum execution time: 41_686 nanoseconds. + Weight::from_parts(41_991_000, 13506) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:0) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn burn() -> Weight { - // Minimum execution time: 59_681 nanoseconds. - Weight::from_ref_time(60_058_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(7)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Nfts Account (r:0 w:2) - // Storage: Nfts ItemPriceOf (r:0 w:1) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `647` + // Estimated: `13573` + // Minimum execution time: 45_192 nanoseconds. + Weight::from_parts(45_792_000, 13573) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:2) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 66_085 nanoseconds. - Weight::from_ref_time(67_065_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(6)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts Item (r:102 w:102) + // Proof Size summary in bytes: + // Measured: `882` + // Estimated: `16109` + // Minimum execution time: 51_962 nanoseconds. + Weight::from_parts(52_367_000, 16109) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:5000 w:5000) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - // Minimum execution time: 25_949 nanoseconds. - Weight::from_ref_time(26_106_000) - // Standard Error: 10_326 - .saturating_add(Weight::from_ref_time(11_496_776).saturating_mul(i.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Proof Size summary in bytes: + // Measured: `756 + i * (140 ±0)` + // Estimated: `5103 + i * (3336 ±0)` + // Minimum execution time: 15_512 nanoseconds. + Weight::from_parts(15_731_000, 5103) + // Standard Error: 9_495 + .saturating_add(Weight::from_ref_time(11_462_413).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_proof_size(3336).saturating_mul(i.into())) } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn lock_item_transfer() -> Weight { - // Minimum execution time: 30_080 nanoseconds. - Weight::from_ref_time(30_825_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `5067` + // Minimum execution time: 19_273 nanoseconds. + Weight::from_parts(19_508_000, 5067) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn unlock_item_transfer() -> Weight { - // Minimum execution time: 30_612 nanoseconds. - Weight::from_ref_time(31_422_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `5067` + // Minimum execution time: 19_022 nanoseconds. + Weight::from_parts(19_430_000, 5067) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn lock_collection() -> Weight { - // Minimum execution time: 27_470 nanoseconds. - Weight::from_ref_time(28_015_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts OwnershipAcceptance (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionAccount (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `5092` + // Minimum execution time: 17_593 nanoseconds. + Weight::from_parts(17_950_000, 5092) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts OwnershipAcceptance (r:1 w:1) + /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:2) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { - // Minimum execution time: 33_750 nanoseconds. - Weight::from_ref_time(34_139_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:0 w:4) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `5082` + // Minimum execution time: 22_068 nanoseconds. + Weight::from_parts(22_235_000, 5082) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:4) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn set_team() -> Weight { - // Minimum execution time: 36_565 nanoseconds. - Weight::from_ref_time(37_464_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(5)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionAccount (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `362` + // Estimated: `2555` + // Minimum execution time: 25_056 nanoseconds. + Weight::from_parts(25_767_000, 2555) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:2) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_collection_owner() -> Weight { - // Minimum execution time: 29_028 nanoseconds. - Weight::from_ref_time(29_479_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `304` + // Estimated: `2555` + // Minimum execution time: 17_398 nanoseconds. + Weight::from_parts(17_684_000, 2555) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn force_collection_config() -> Weight { - // Minimum execution time: 24_695 nanoseconds. - Weight::from_ref_time(25_304_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `242` + // Estimated: `2555` + // Minimum execution time: 14_054 nanoseconds. + Weight::from_parts(14_243_000, 2555) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn lock_item_properties() -> Weight { - // Minimum execution time: 28_910 nanoseconds. - Weight::from_ref_time(29_186_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `445` + // Estimated: `5078` + // Minimum execution time: 17_662 nanoseconds. + Weight::from_parts(18_073_000, 5078) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn set_attribute() -> Weight { - // Minimum execution time: 56_407 nanoseconds. - Weight::from_ref_time(58_176_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `10547` + // Minimum execution time: 40_098 nanoseconds. + Weight::from_parts(40_649_000, 10547) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn force_set_attribute() -> Weight { - // Minimum execution time: 36_402 nanoseconds. - Weight::from_ref_time(37_034_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Nfts Attribute (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts ItemConfigOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `337` + // Estimated: `5476` + // Minimum execution time: 25_178 nanoseconds. + Weight::from_parts(25_473_000, 5476) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_attribute() -> Weight { - // Minimum execution time: 52_022 nanoseconds. - Weight::from_ref_time(54_059_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Nfts Item (r:1 w:0) - // Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `916` + // Estimated: `7999` + // Minimum execution time: 35_202 nanoseconds. + Weight::from_parts(35_518_000, 7999) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) fn approve_item_attributes() -> Weight { - // Minimum execution time: 28_475 nanoseconds. - Weight::from_ref_time(29_162_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:0) - // Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) - // Storage: Nfts Attribute (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `379` + // Estimated: `6492` + // Minimum execution time: 17_260 nanoseconds. + Weight::from_parts(17_498_000, 6492) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1001 w:1000) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { - // Minimum execution time: 37_529 nanoseconds. - Weight::from_ref_time(38_023_000) - // Standard Error: 8_136 - .saturating_add(Weight::from_ref_time(7_452_872).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(4)) + // Proof Size summary in bytes: + // Measured: `865 + n * (367 ±0)` + // Estimated: `12016 + n * (2921 ±0)` + // Minimum execution time: 25_579 nanoseconds. + Weight::from_parts(25_846_000, 12016) + // Standard Error: 7_759 + .saturating_add(Weight::from_ref_time(7_159_200).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemMetadataOf (r:1 w:1) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn set_metadata() -> Weight { - // Minimum execution time: 49_300 nanoseconds. - Weight::from_ref_time(49_790_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts ItemMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `10241` + // Minimum execution time: 33_285 nanoseconds. + Weight::from_parts(33_692_000, 10241) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 47_248 nanoseconds. - Weight::from_ref_time(48_094_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `609` + // Estimated: `7693` + // Minimum execution time: 30_670 nanoseconds. + Weight::from_parts(31_282_000, 7693) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:1 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { - // Minimum execution time: 44_137 nanoseconds. - Weight::from_ref_time(44_905_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts CollectionMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `333` + // Estimated: `7665` + // Minimum execution time: 28_313 nanoseconds. + Weight::from_parts(28_724_000, 7665) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:1 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { - // Minimum execution time: 43_005 nanoseconds. - Weight::from_ref_time(43_898_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts CollectionRoleOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `476` + // Estimated: `7665` + // Minimum execution time: 27_034 nanoseconds. + Weight::from_parts(27_655_000, 7665) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn approve_transfer() -> Weight { - // Minimum execution time: 36_344 nanoseconds. - Weight::from_ref_time(36_954_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `466` + // Estimated: `8428` + // Minimum execution time: 23_408 nanoseconds. + Weight::from_parts(23_916_000, 8428) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn cancel_approval() -> Weight { - // Minimum execution time: 32_418 nanoseconds. - Weight::from_ref_time(33_029_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `5880` + // Minimum execution time: 21_177 nanoseconds. + Weight::from_parts(21_492_000, 5880) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn clear_all_transfer_approvals() -> Weight { - // Minimum execution time: 31_448 nanoseconds. - Weight::from_ref_time(31_979_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts OwnershipAcceptance (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `5880` + // Minimum execution time: 20_279 nanoseconds. + Weight::from_parts(20_919_000, 5880) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts OwnershipAcceptance (r:1 w:1) + /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_accept_ownership() -> Weight { - // Minimum execution time: 27_487 nanoseconds. - Weight::from_ref_time(28_080_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts CollectionConfigOf (r:1 w:1) - // Storage: Nfts Collection (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `2527` + // Minimum execution time: 14_921 nanoseconds. + Weight::from_parts(15_382_000, 2527) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { - // Minimum execution time: 28_235 nanoseconds. - Weight::from_ref_time(28_967_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `333` + // Estimated: `5103` + // Minimum execution time: 18_201 nanoseconds. + Weight::from_parts(18_628_000, 5103) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn update_mint_settings() -> Weight { - // Minimum execution time: 28_172 nanoseconds. - Weight::from_ref_time(28_636_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `333` + // Estimated: `5103` + // Minimum execution time: 16_870 nanoseconds. + Weight::from_parts(17_318_000, 5103) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { - // Minimum execution time: 35_336 nanoseconds. - Weight::from_ref_time(36_026_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts ItemPriceOf (r:1 w:1) - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Nfts Account (r:0 w:2) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `516` + // Estimated: `8407` + // Minimum execution time: 22_604 nanoseconds. + Weight::from_parts(22_867_000, 8407) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:1 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:2) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn buy_item() -> Weight { - // Minimum execution time: 70_971 nanoseconds. - Weight::from_ref_time(72_036_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `934` + // Estimated: `16129` + // Minimum execution time: 56_849 nanoseconds. + Weight::from_parts(57_336_000, 16129) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { - // Minimum execution time: 5_151 nanoseconds. - Weight::from_ref_time(11_822_888) - // Standard Error: 38_439 - .saturating_add(Weight::from_ref_time(3_511_844).saturating_mul(n.into())) - } - // Storage: Nfts Item (r:2 w:0) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_308 nanoseconds. + Weight::from_ref_time(4_805_401) + // Standard Error: 13_875 + .saturating_add(Weight::from_ref_time(3_167_190).saturating_mul(n.into())) + } + /// Storage: Nfts Item (r:2 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn create_swap() -> Weight { - // Minimum execution time: 33_027 nanoseconds. - Weight::from_ref_time(33_628_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts PendingSwapOf (r:1 w:1) - // Storage: Nfts Item (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `524` + // Estimated: `6672` + // Minimum execution time: 20_395 nanoseconds. + Weight::from_parts(20_716_000, 6672) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts PendingSwapOf (r:1 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn cancel_swap() -> Weight { - // Minimum execution time: 35_890 nanoseconds. - Weight::from_ref_time(36_508_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:2 w:2) - // Storage: Nfts PendingSwapOf (r:1 w:2) - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:2 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Nfts Account (r:0 w:4) - // Storage: Nfts ItemPriceOf (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `511` + // Estimated: `5882` + // Minimum execution time: 19_936 nanoseconds. + Weight::from_parts(20_344_000, 5882) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:2 w:2) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:1 w:2) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:2 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:4) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:2) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn claim_swap() -> Weight { - // Minimum execution time: 101_076 nanoseconds. - Weight::from_ref_time(101_863_000) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(11)) + // Proof Size summary in bytes: + // Measured: `1097` + // Estimated: `21970` + // Minimum execution time: 80_884 nanoseconds. + Weight::from_parts(81_643_000, 21970) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(11_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Nfts NextCollectionId (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:0 w:1) - // Storage: Nfts CollectionConfigOf (r:0 w:1) - // Storage: Nfts CollectionAccount (r:0 w:1) + /// Storage: Nfts NextCollectionId (r:1 w:1) + /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 44_312 nanoseconds. - Weight::from_ref_time(44_871_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(5)) - } - // Storage: Nfts NextCollectionId (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:0 w:1) - // Storage: Nfts CollectionConfigOf (r:0 w:1) - // Storage: Nfts CollectionAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `214` + // Estimated: `3054` + // Minimum execution time: 32_467 nanoseconds. + Weight::from_parts(33_236_000, 3054) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Nfts NextCollectionId (r:1 w:1) + /// Proof: Nfts NextCollectionId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_create() -> Weight { - // Minimum execution time: 31_654 nanoseconds. - Weight::from_ref_time(32_078_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(5)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts Item (r:1001 w:1000) - // Storage: Nfts Attribute (r:1001 w:1000) - // Storage: Nfts ItemMetadataOf (r:0 w:1000) - // Storage: Nfts CollectionRoleOf (r:0 w:1) - // Storage: Nfts CollectionMetadataOf (r:0 w:1) - // Storage: Nfts CollectionConfigOf (r:0 w:1) - // Storage: Nfts ItemConfigOf (r:0 w:1000) - // Storage: Nfts Account (r:0 w:1000) - // Storage: Nfts CollectionAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3054` + // Minimum execution time: 22_198 nanoseconds. + Weight::from_parts(22_776_000, 3054) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1001 w:1000) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1001 w:1000) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1001 w:1000) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:1) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:0 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:0 w:1000) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1000) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:1) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - // Minimum execution time: 19_183_393 nanoseconds. - Weight::from_ref_time(17_061_526_855) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(353_523).saturating_mul(n.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(1_861_080).saturating_mul(m.into())) - // Standard Error: 16_689 - .saturating_add(Weight::from_ref_time(8_858_987).saturating_mul(a.into())) - .saturating_add(RocksDbWeight::get().reads(1003)) + // Proof Size summary in bytes: + // Measured: `172781 + m * (127 ±0) + a * (402 ±0)` + // Estimated: `3347427 + a * (2921 ±0) + m * (2615 ±0)` + // Minimum execution time: 24_021_657 nanoseconds. + Weight::from_parts(16_029_391_606, 3347427) + // Standard Error: 20_364 + .saturating_add(Weight::from_ref_time(300_580).saturating_mul(n.into())) + // Standard Error: 20_364 + .saturating_add(Weight::from_ref_time(7_748_502).saturating_mul(m.into())) + // Standard Error: 20_364 + .saturating_add(Weight::from_ref_time(9_183_566).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(1004_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) - .saturating_add(RocksDbWeight::get().writes(3005)) + .saturating_add(RocksDbWeight::get().writes(3005_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(m.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) - } - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) - // Storage: Nfts Account (r:0 w:1) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(a.into())) + .saturating_add(Weight::from_proof_size(2615).saturating_mul(m.into())) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { - // Minimum execution time: 57_753 nanoseconds. - Weight::from_ref_time(58_313_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) - // Storage: Nfts Account (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `448` + // Estimated: `13506` + // Minimum execution time: 42_634 nanoseconds. + Weight::from_parts(43_231_000, 13506) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn force_mint() -> Weight { - // Minimum execution time: 56_429 nanoseconds. - Weight::from_ref_time(57_202_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) - // Storage: Nfts Account (r:0 w:1) - // Storage: Nfts ItemPriceOf (r:0 w:1) - // Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `448` + // Estimated: `13506` + // Minimum execution time: 41_686 nanoseconds. + Weight::from_parts(41_991_000, 13506) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:0) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:1) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:0 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn burn() -> Weight { - // Minimum execution time: 59_681 nanoseconds. - Weight::from_ref_time(60_058_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(7)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Nfts Account (r:0 w:2) - // Storage: Nfts ItemPriceOf (r:0 w:1) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `647` + // Estimated: `13573` + // Minimum execution time: 45_192 nanoseconds. + Weight::from_parts(45_792_000, 13573) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:2) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 66_085 nanoseconds. - Weight::from_ref_time(67_065_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(6)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts Item (r:102 w:102) + // Proof Size summary in bytes: + // Measured: `882` + // Estimated: `16109` + // Minimum execution time: 51_962 nanoseconds. + Weight::from_parts(52_367_000, 16109) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:5000 w:5000) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - // Minimum execution time: 25_949 nanoseconds. - Weight::from_ref_time(26_106_000) - // Standard Error: 10_326 - .saturating_add(Weight::from_ref_time(11_496_776).saturating_mul(i.into())) - .saturating_add(RocksDbWeight::get().reads(2)) + // Proof Size summary in bytes: + // Measured: `756 + i * (140 ±0)` + // Estimated: `5103 + i * (3336 ±0)` + // Minimum execution time: 15_512 nanoseconds. + Weight::from_parts(15_731_000, 5103) + // Standard Error: 9_495 + .saturating_add(Weight::from_ref_time(11_462_413).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_proof_size(3336).saturating_mul(i.into())) } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn lock_item_transfer() -> Weight { - // Minimum execution time: 30_080 nanoseconds. - Weight::from_ref_time(30_825_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `5067` + // Minimum execution time: 19_273 nanoseconds. + Weight::from_parts(19_508_000, 5067) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn unlock_item_transfer() -> Weight { - // Minimum execution time: 30_612 nanoseconds. - Weight::from_ref_time(31_422_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts CollectionRoleOf (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `401` + // Estimated: `5067` + // Minimum execution time: 19_022 nanoseconds. + Weight::from_parts(19_430_000, 5067) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn lock_collection() -> Weight { - // Minimum execution time: 27_470 nanoseconds. - Weight::from_ref_time(28_015_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts OwnershipAcceptance (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionAccount (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `289` + // Estimated: `5092` + // Minimum execution time: 17_593 nanoseconds. + Weight::from_parts(17_950_000, 5092) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts OwnershipAcceptance (r:1 w:1) + /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:2) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { - // Minimum execution time: 33_750 nanoseconds. - Weight::from_ref_time(34_139_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:0 w:4) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `5082` + // Minimum execution time: 22_068 nanoseconds. + Weight::from_parts(22_235_000, 5082) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:0 w:4) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn set_team() -> Weight { - // Minimum execution time: 36_565 nanoseconds. - Weight::from_ref_time(37_464_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(5)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionAccount (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `362` + // Estimated: `2555` + // Minimum execution time: 25_056 nanoseconds. + Weight::from_parts(25_767_000, 2555) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionAccount (r:0 w:2) + /// Proof: Nfts CollectionAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_collection_owner() -> Weight { - // Minimum execution time: 29_028 nanoseconds. - Weight::from_ref_time(29_479_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `304` + // Estimated: `2555` + // Minimum execution time: 17_398 nanoseconds. + Weight::from_parts(17_684_000, 2555) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:0 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn force_collection_config() -> Weight { - // Minimum execution time: 24_695 nanoseconds. - Weight::from_ref_time(25_304_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `242` + // Estimated: `2555` + // Minimum execution time: 14_054 nanoseconds. + Weight::from_parts(14_243_000, 2555) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:1) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn lock_item_properties() -> Weight { - // Minimum execution time: 28_910 nanoseconds. - Weight::from_ref_time(29_186_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `445` + // Estimated: `5078` + // Minimum execution time: 17_662 nanoseconds. + Weight::from_parts(18_073_000, 5078) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn set_attribute() -> Weight { - // Minimum execution time: 56_407 nanoseconds. - Weight::from_ref_time(58_176_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `10547` + // Minimum execution time: 40_098 nanoseconds. + Weight::from_parts(40_649_000, 10547) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) fn force_set_attribute() -> Weight { - // Minimum execution time: 36_402 nanoseconds. - Weight::from_ref_time(37_034_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Nfts Attribute (r:1 w:1) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts ItemConfigOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `337` + // Estimated: `5476` + // Minimum execution time: 25_178 nanoseconds. + Weight::from_parts(25_473_000, 5476) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Attribute (r:1 w:1) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_attribute() -> Weight { - // Minimum execution time: 52_022 nanoseconds. - Weight::from_ref_time(54_059_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Nfts Item (r:1 w:0) - // Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `916` + // Estimated: `7999` + // Minimum execution time: 35_202 nanoseconds. + Weight::from_parts(35_518_000, 7999) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) fn approve_item_attributes() -> Weight { - // Minimum execution time: 28_475 nanoseconds. - Weight::from_ref_time(29_162_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:0) - // Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) - // Storage: Nfts Attribute (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `379` + // Estimated: `6492` + // Minimum execution time: 17_260 nanoseconds. + Weight::from_parts(17_498_000, 6492) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemAttributesApprovalsOf (r:1 w:1) + /// Proof: Nfts ItemAttributesApprovalsOf (max_values: None, max_size: Some(681), added: 3156, mode: MaxEncodedLen) + /// Storage: Nfts Attribute (r:1001 w:1000) + /// Proof: Nfts Attribute (max_values: None, max_size: Some(446), added: 2921, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[0, 1000]`. fn cancel_item_attributes_approval(n: u32, ) -> Weight { - // Minimum execution time: 37_529 nanoseconds. - Weight::from_ref_time(38_023_000) - // Standard Error: 8_136 - .saturating_add(Weight::from_ref_time(7_452_872).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(4)) + // Proof Size summary in bytes: + // Measured: `865 + n * (367 ±0)` + // Estimated: `12016 + n * (2921 ±0)` + // Minimum execution time: 25_579 nanoseconds. + Weight::from_parts(25_846_000, 12016) + // Standard Error: 7_759 + .saturating_add(Weight::from_ref_time(7_159_200).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemMetadataOf (r:1 w:1) + .saturating_add(Weight::from_proof_size(2921).saturating_mul(n.into())) + } + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) fn set_metadata() -> Weight { - // Minimum execution time: 49_300 nanoseconds. - Weight::from_ref_time(49_790_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts ItemMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `10241` + // Minimum execution time: 33_285 nanoseconds. + Weight::from_parts(33_692_000, 10241) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Nfts ItemMetadataOf (r:1 w:1) + /// Proof: Nfts ItemMetadataOf (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 47_248 nanoseconds. - Weight::from_ref_time(48_094_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts Collection (r:1 w:1) - // Storage: Nfts CollectionMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `609` + // Estimated: `7693` + // Minimum execution time: 30_670 nanoseconds. + Weight::from_parts(31_282_000, 7693) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:1) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:1 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { - // Minimum execution time: 44_137 nanoseconds. - Weight::from_ref_time(44_905_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts CollectionMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `333` + // Estimated: `7665` + // Minimum execution time: 28_313 nanoseconds. + Weight::from_parts(28_724_000, 7665) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionMetadataOf (r:1 w:1) + /// Proof: Nfts CollectionMetadataOf (max_values: None, max_size: Some(87), added: 2562, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { - // Minimum execution time: 43_005 nanoseconds. - Weight::from_ref_time(43_898_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts CollectionRoleOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `476` + // Estimated: `7665` + // Minimum execution time: 27_034 nanoseconds. + Weight::from_parts(27_655_000, 7665) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn approve_transfer() -> Weight { - // Minimum execution time: 36_344 nanoseconds. - Weight::from_ref_time(36_954_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `466` + // Estimated: `8428` + // Minimum execution time: 23_408 nanoseconds. + Weight::from_parts(23_916_000, 8428) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn cancel_approval() -> Weight { - // Minimum execution time: 32_418 nanoseconds. - Weight::from_ref_time(33_029_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts CollectionRoleOf (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `5880` + // Minimum execution time: 21_177 nanoseconds. + Weight::from_parts(21_492_000, 5880) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionRoleOf (r:1 w:0) + /// Proof: Nfts CollectionRoleOf (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen) fn clear_all_transfer_approvals() -> Weight { - // Minimum execution time: 31_448 nanoseconds. - Weight::from_ref_time(31_979_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts OwnershipAcceptance (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `474` + // Estimated: `5880` + // Minimum execution time: 20_279 nanoseconds. + Weight::from_parts(20_919_000, 5880) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts OwnershipAcceptance (r:1 w:1) + /// Proof: Nfts OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_accept_ownership() -> Weight { - // Minimum execution time: 27_487 nanoseconds. - Weight::from_ref_time(28_080_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts CollectionConfigOf (r:1 w:1) - // Storage: Nfts Collection (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `2527` + // Minimum execution time: 14_921 nanoseconds. + Weight::from_parts(15_382_000, 2527) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { - // Minimum execution time: 28_235 nanoseconds. - Weight::from_ref_time(28_967_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `333` + // Estimated: `5103` + // Minimum execution time: 18_201 nanoseconds. + Weight::from_parts(18_628_000, 5103) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:1) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn update_mint_settings() -> Weight { - // Minimum execution time: 28_172 nanoseconds. - Weight::from_ref_time(28_636_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: Nfts ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `333` + // Estimated: `5103` + // Minimum execution time: 16_870 nanoseconds. + Weight::from_parts(17_318_000, 5103) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { - // Minimum execution time: 35_336 nanoseconds. - Weight::from_ref_time(36_026_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:1 w:1) - // Storage: Nfts ItemPriceOf (r:1 w:1) - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Nfts Account (r:0 w:2) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `516` + // Estimated: `8407` + // Minimum execution time: 22_604 nanoseconds. + Weight::from_parts(22_867_000, 8407) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:1 w:1) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:1 w:1) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:1 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:2) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn buy_item() -> Weight { - // Minimum execution time: 70_971 nanoseconds. - Weight::from_ref_time(72_036_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `934` + // Estimated: `16129` + // Minimum execution time: 56_849 nanoseconds. + Weight::from_parts(57_336_000, 16129) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { - // Minimum execution time: 5_151 nanoseconds. - Weight::from_ref_time(11_822_888) - // Standard Error: 38_439 - .saturating_add(Weight::from_ref_time(3_511_844).saturating_mul(n.into())) - } - // Storage: Nfts Item (r:2 w:0) - // Storage: Nfts PendingSwapOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_308 nanoseconds. + Weight::from_ref_time(4_805_401) + // Standard Error: 13_875 + .saturating_add(Weight::from_ref_time(3_167_190).saturating_mul(n.into())) + } + /// Storage: Nfts Item (r:2 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:0 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) fn create_swap() -> Weight { - // Minimum execution time: 33_027 nanoseconds. - Weight::from_ref_time(33_628_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts PendingSwapOf (r:1 w:1) - // Storage: Nfts Item (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `524` + // Estimated: `6672` + // Minimum execution time: 20_395 nanoseconds. + Weight::from_parts(20_716_000, 6672) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts PendingSwapOf (r:1 w:1) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + /// Storage: Nfts Item (r:1 w:0) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) fn cancel_swap() -> Weight { - // Minimum execution time: 35_890 nanoseconds. - Weight::from_ref_time(36_508_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Nfts Item (r:2 w:2) - // Storage: Nfts PendingSwapOf (r:1 w:2) - // Storage: Nfts Collection (r:1 w:0) - // Storage: Nfts CollectionConfigOf (r:1 w:0) - // Storage: Nfts ItemConfigOf (r:2 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Nfts Account (r:0 w:4) - // Storage: Nfts ItemPriceOf (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `511` + // Estimated: `5882` + // Minimum execution time: 19_936 nanoseconds. + Weight::from_parts(20_344_000, 5882) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Nfts Item (r:2 w:2) + /// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen) + /// Storage: Nfts PendingSwapOf (r:1 w:2) + /// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) + /// Storage: Nfts Collection (r:1 w:0) + /// Proof: Nfts Collection (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) + /// Storage: Nfts CollectionConfigOf (r:1 w:0) + /// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Nfts ItemConfigOf (r:2 w:0) + /// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nfts Account (r:0 w:4) + /// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Nfts ItemPriceOf (r:0 w:2) + /// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn claim_swap() -> Weight { - // Minimum execution time: 101_076 nanoseconds. - Weight::from_ref_time(101_863_000) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(11)) + // Proof Size summary in bytes: + // Measured: `1097` + // Estimated: `21970` + // Minimum execution time: 80_884 nanoseconds. + Weight::from_parts(81_643_000, 21970) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(11_u64)) } } diff --git a/frame/nis/src/weights.rs b/frame/nis/src/weights.rs index 769ff79551..07221f358c 100644 --- a/frame/nis/src/weights.rs +++ b/frame/nis/src/weights.rs @@ -1,31 +1,43 @@ +// This file is part of Substrate. + +// Copyright (C) 2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. //! Autogenerated weights for pallet_nis //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-15, STEPS: `5`, REPEAT: 2, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `Workhorse.local`, CPU: `` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ../../../target/release/substrate +// ./target/production/substrate // benchmark // pallet -// --chain -// dev -// --steps -// 5 -// --repeat -// 2 -// --pallet -// pallet_nis -// --extrinsic -// * +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_nis +// --extrinsic=* // --execution=wasm // --wasm-execution=compiled -// --output -// ../../../frame/nis/src/weights.rs -// --template -// ../../../.maintain/frame-weight-template.hbs +// --heap-pages=4096 +// --output=./frame/nis/src/weights.rs +// --header=./HEADER-APACHE2 +// --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -52,224 +64,364 @@ pub trait WeightInfo { /// Weights for pallet_nis using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Nis Queues (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { - // Minimum execution time: 47_000 nanoseconds. - Weight::from_ref_time(53_822_030) - // Standard Error: 4_869 - .saturating_add(Weight::from_ref_time(47_431).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `6245 + l * (48 ±0)` + // Estimated: `60718` + // Minimum execution time: 28_814 nanoseconds. + Weight::from_parts(35_245_917, 60718) + // Standard Error: 189 + .saturating_add(Weight::from_ref_time(45_322).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Nis Queues (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn place_bid_max() -> Weight { - // Minimum execution time: 109_000 nanoseconds. - Weight::from_ref_time(109_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `54247` + // Estimated: `60718` + // Minimum execution time: 80_332 nanoseconds. + Weight::from_parts(81_050_000, 60718) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Nis Queues (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { - // Minimum execution time: 50_000 nanoseconds. - Weight::from_ref_time(54_479_879) - // Standard Error: 4_891 - .saturating_add(Weight::from_ref_time(38_224).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `6245 + l * (48 ±0)` + // Estimated: `60718` + // Minimum execution time: 34_426 nanoseconds. + Weight::from_parts(36_434_166, 60718) + // Standard Error: 135 + .saturating_add(Weight::from_ref_time(33_923).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Nis Summary (r:1 w:0) - // Storage: System Account (r:1 w:1) + /// Storage: Nis Summary (r:1 w:0) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn fund_deficit() -> Weight { - // Minimum execution time: 57_000 nanoseconds. - Weight::from_ref_time(62_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `222` + // Estimated: `3138` + // Minimum execution time: 32_566 nanoseconds. + Weight::from_parts(32_880_000, 3138) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: System Account (r:1 w:0) - // Storage: Balances Reserves (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn thaw_private() -> Weight { - // Minimum execution time: 84_000 nanoseconds. - Weight::from_ref_time(85_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `423` + // Estimated: `9418` + // Minimum execution time: 46_212 nanoseconds. + Weight::from_parts(46_748_000, 9418) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn thaw_communal() -> Weight { - // Minimum execution time: 108_000 nanoseconds. - Weight::from_ref_time(115_000_000) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `868` + // Estimated: `10956` + // Minimum execution time: 68_791 nanoseconds. + Weight::from_parts(69_504_000, 10956) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn privatize() -> Weight { - // Minimum execution time: 107_000 nanoseconds. - Weight::from_ref_time(110_000_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `930` + // Estimated: `14680` + // Minimum execution time: 76_784 nanoseconds. + Weight::from_parts(77_575_000, 14680) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn communify() -> Weight { - // Minimum execution time: 89_000 nanoseconds. - Weight::from_ref_time(89_000_000) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `769` + // Estimated: `14680` + // Minimum execution time: 64_543 nanoseconds. + Weight::from_parts(65_258_000, 14680) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: Nis Summary (r:1 w:1) - // Storage: System Account (r:1 w:0) - // Storage: Nis QueueTotals (r:1 w:1) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn process_queues() -> Weight { - // Minimum execution time: 34_000 nanoseconds. - Weight::from_ref_time(38_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `6655` + // Estimated: `9635` + // Minimum execution time: 21_379 nanoseconds. + Weight::from_parts(21_736_000, 9635) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Nis Queues (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) fn process_queue() -> Weight { - // Minimum execution time: 6_000 nanoseconds. - Weight::from_ref_time(7_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `50497` + // Minimum execution time: 4_302 nanoseconds. + Weight::from_parts(4_440_000, 50497) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Nis Receipts (r:0 w:1) + /// Storage: Nis Receipts (r:0 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) fn process_bid() -> Weight { - // Minimum execution time: 14_000 nanoseconds. - Weight::from_ref_time(15_000_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_758 nanoseconds. + Weight::from_ref_time(6_911_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Nis Queues (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) /// The range of component `l` is `[0, 999]`. fn place_bid(l: u32, ) -> Weight { - // Minimum execution time: 47_000 nanoseconds. - Weight::from_ref_time(53_822_030) - // Standard Error: 4_869 - .saturating_add(Weight::from_ref_time(47_431).saturating_mul(l.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `6245 + l * (48 ±0)` + // Estimated: `60718` + // Minimum execution time: 28_814 nanoseconds. + Weight::from_parts(35_245_917, 60718) + // Standard Error: 189 + .saturating_add(Weight::from_ref_time(45_322).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Nis Queues (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn place_bid_max() -> Weight { - // Minimum execution time: 109_000 nanoseconds. - Weight::from_ref_time(109_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `54247` + // Estimated: `60718` + // Minimum execution time: 80_332 nanoseconds. + Weight::from_parts(81_050_000, 60718) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Nis Queues (r:1 w:1) - // Storage: Nis QueueTotals (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) /// The range of component `l` is `[1, 1000]`. fn retract_bid(l: u32, ) -> Weight { - // Minimum execution time: 50_000 nanoseconds. - Weight::from_ref_time(54_479_879) - // Standard Error: 4_891 - .saturating_add(Weight::from_ref_time(38_224).saturating_mul(l.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `6245 + l * (48 ±0)` + // Estimated: `60718` + // Minimum execution time: 34_426 nanoseconds. + Weight::from_parts(36_434_166, 60718) + // Standard Error: 135 + .saturating_add(Weight::from_ref_time(33_923).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Nis Summary (r:1 w:0) - // Storage: System Account (r:1 w:1) + /// Storage: Nis Summary (r:1 w:0) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn fund_deficit() -> Weight { - // Minimum execution time: 57_000 nanoseconds. - Weight::from_ref_time(62_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `222` + // Estimated: `3138` + // Minimum execution time: 32_566 nanoseconds. + Weight::from_parts(32_880_000, 3138) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: System Account (r:1 w:0) - // Storage: Balances Reserves (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn thaw_private() -> Weight { - // Minimum execution time: 84_000 nanoseconds. - Weight::from_ref_time(85_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `423` + // Estimated: `9418` + // Minimum execution time: 46_212 nanoseconds. + Weight::from_parts(46_748_000, 9418) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn thaw_communal() -> Weight { - // Minimum execution time: 108_000 nanoseconds. - Weight::from_ref_time(115_000_000) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `868` + // Estimated: `10956` + // Minimum execution time: 68_791 nanoseconds. + Weight::from_parts(69_504_000, 10956) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) fn privatize() -> Weight { - // Minimum execution time: 107_000 nanoseconds. - Weight::from_ref_time(110_000_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `930` + // Estimated: `14680` + // Minimum execution time: 76_784 nanoseconds. + Weight::from_parts(77_575_000, 14680) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: Nis Receipts (r:1 w:1) - // Storage: Balances Reserves (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Nis Summary (r:1 w:1) - // Storage: Assets Asset (r:1 w:1) - // Storage: Assets Account (r:1 w:1) + /// Storage: Nis Receipts (r:1 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:1) + /// Proof: Balances Reserves (max_values: None, max_size: Some(1249), added: 3724, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: Assets Asset (r:1 w:1) + /// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) + /// Storage: Assets Account (r:1 w:1) + /// Proof: Assets Account (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) fn communify() -> Weight { - // Minimum execution time: 89_000 nanoseconds. - Weight::from_ref_time(89_000_000) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `769` + // Estimated: `14680` + // Minimum execution time: 64_543 nanoseconds. + Weight::from_parts(65_258_000, 14680) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: Nis Summary (r:1 w:1) - // Storage: System Account (r:1 w:0) - // Storage: Nis QueueTotals (r:1 w:1) + /// Storage: Nis Summary (r:1 w:1) + /// Proof: Nis Summary (max_values: Some(1), max_size: Some(40), added: 535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Nis QueueTotals (r:1 w:1) + /// Proof: Nis QueueTotals (max_values: Some(1), max_size: Some(6002), added: 6497, mode: MaxEncodedLen) fn process_queues() -> Weight { - // Minimum execution time: 34_000 nanoseconds. - Weight::from_ref_time(38_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `6655` + // Estimated: `9635` + // Minimum execution time: 21_379 nanoseconds. + Weight::from_parts(21_736_000, 9635) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Nis Queues (r:1 w:1) + /// Storage: Nis Queues (r:1 w:1) + /// Proof: Nis Queues (max_values: None, max_size: Some(48022), added: 50497, mode: MaxEncodedLen) fn process_queue() -> Weight { - // Minimum execution time: 6_000 nanoseconds. - Weight::from_ref_time(7_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `50497` + // Minimum execution time: 4_302 nanoseconds. + Weight::from_parts(4_440_000, 50497) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Nis Receipts (r:0 w:1) + /// Storage: Nis Receipts (r:0 w:1) + /// Proof: Nis Receipts (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) fn process_bid() -> Weight { - // Minimum execution time: 14_000 nanoseconds. - Weight::from_ref_time(15_000_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_758 nanoseconds. + Weight::from_ref_time(6_911_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/nomination-pools/src/weights.rs b/frame/nomination-pools/src/weights.rs index 1062b1749d..ae73015940 100644 --- a/frame/nomination-pools/src/weights.rs +++ b/frame/nomination-pools/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_nomination_pools //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -67,492 +68,854 @@ pub trait WeightInfo { /// Weights for pallet_nomination_pools using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: NominationPools MinJoinBond (r:1 w:0) - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:2 w:1) - // Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) - // Storage: NominationPools MaxPoolMembers (r:1 w:0) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: NominationPools MinJoinBond (r:1 w:0) + /// Proof: NominationPools MinJoinBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) + /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembers (r:1 w:0) + /// Proof: NominationPools MaxPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn join() -> Weight { - // Minimum execution time: 159_948 nanoseconds. - Weight::from_ref_time(161_133_000 as u64) - .saturating_add(T::DbWeight::get().reads(17 as u64)) - .saturating_add(T::DbWeight::get().writes(12 as u64)) + // Proof Size summary in bytes: + // Measured: `3573` + // Estimated: `37988` + // Minimum execution time: 140_155 nanoseconds. + Weight::from_parts(141_098_000, 37988) + .saturating_add(T::DbWeight::get().reads(17_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:3 w:2) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_transfer() -> Weight { - // Minimum execution time: 155_517 nanoseconds. - Weight::from_ref_time(159_101_000 as u64) - .saturating_add(T::DbWeight::get().reads(14 as u64)) - .saturating_add(T::DbWeight::get().writes(12 as u64)) + // Proof Size summary in bytes: + // Measured: `3615` + // Estimated: `38583` + // Minimum execution time: 136_048 nanoseconds. + Weight::from_parts(136_767_000, 38583) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_reward() -> Weight { - // Minimum execution time: 172_788 nanoseconds. - Weight::from_ref_time(174_212_000 as u64) - .saturating_add(T::DbWeight::get().reads(14 as u64)) - .saturating_add(T::DbWeight::get().writes(13 as u64)) + // Proof Size summary in bytes: + // Measured: `3615` + // Estimated: `38583` + // Minimum execution time: 151_473 nanoseconds. + Weight::from_parts(152_375_000, 38583) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(13_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_payout() -> Weight { - // Minimum execution time: 64_560 nanoseconds. - Weight::from_ref_time(64_950_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `1189` + // Estimated: `10489` + // Minimum execution time: 51_146 nanoseconds. + Weight::from_parts(51_570_000, 10489) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: System Account (r:2 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) - // Storage: NominationPools SubPoolsStorage (r:1 w:1) - // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: NominationPools SubPoolsStorage (r:1 w:1) + /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn unbond() -> Weight { - // Minimum execution time: 161_398 nanoseconds. - Weight::from_ref_time(162_991_000 as u64) - .saturating_add(T::DbWeight::get().reads(18 as u64)) - .saturating_add(T::DbWeight::get().writes(13 as u64)) + // Proof Size summary in bytes: + // Measured: `3858` + // Estimated: `67379` + // Minimum execution time: 141_400 nanoseconds. + Weight::from_parts(141_822_000, 67379) + .saturating_add(T::DbWeight::get().reads(18_u64)) + .saturating_add(T::DbWeight::get().writes(13_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - // Minimum execution time: 66_036 nanoseconds. - Weight::from_ref_time(67_183_304 as u64) - // Standard Error: 565 - .saturating_add(Weight::from_ref_time(57_830 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `1779` + // Estimated: `13025` + // Minimum execution time: 49_021 nanoseconds. + Weight::from_parts(49_954_282, 13025) + // Standard Error: 378 + .saturating_add(Weight::from_ref_time(5_165).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools SubPoolsStorage (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools SubPoolsStorage (r:1 w:1) + /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - // Minimum execution time: 111_156 nanoseconds. - Weight::from_ref_time(112_507_059 as u64) - // Standard Error: 655 - .saturating_add(Weight::from_ref_time(53_711 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(9 as u64)) - .saturating_add(T::DbWeight::get().writes(7 as u64)) + // Proof Size summary in bytes: + // Measured: `2303` + // Estimated: `45696` + // Minimum execution time: 92_473 nanoseconds. + Weight::from_parts(93_901_972, 45696) + // Standard Error: 618 + .saturating_add(Weight::from_ref_time(12_032).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools SubPoolsStorage (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:1 w:1) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) - // Storage: NominationPools ReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: NominationPools CounterForRewardPools (r:1 w:1) - // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) - // Storage: NominationPools Metadata (r:1 w:1) - // Storage: NominationPools CounterForBondedPools (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools SubPoolsStorage (r:1 w:1) + /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:0) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools ReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools ReversePoolIdLookup (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForRewardPools (r:1 w:1) + /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools Metadata (r:1 w:1) + /// Proof: NominationPools Metadata (max_values: None, max_size: Some(270), added: 2745, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForBondedPools (r:1 w:1) + /// Proof: NominationPools CounterForBondedPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - // Minimum execution time: 168_270 nanoseconds. - Weight::from_ref_time(170_059_380 as u64) - // Standard Error: 1_506 - .saturating_add(Weight::from_ref_time(1_258 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(20 as u64)) - .saturating_add(T::DbWeight::get().writes(17 as u64)) + fn withdraw_unbonded_kill(_s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2690` + // Estimated: `68812` + // Minimum execution time: 150_063 nanoseconds. + Weight::from_parts(152_321_387, 68812) + .saturating_add(T::DbWeight::get().reads(20_u64)) + .saturating_add(T::DbWeight::get().writes(17_u64)) } - // Storage: NominationPools LastPoolId (r:1 w:1) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: NominationPools MinCreateBond (r:1 w:0) - // Storage: NominationPools MinJoinBond (r:1 w:0) - // Storage: NominationPools MaxPools (r:1 w:0) - // Storage: NominationPools CounterForBondedPools (r:1 w:1) - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) - // Storage: NominationPools MaxPoolMembers (r:1 w:0) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: NominationPools CounterForRewardPools (r:1 w:1) - // Storage: NominationPools ReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: NominationPools LastPoolId (r:1 w:1) + /// Proof: NominationPools LastPoolId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MinCreateBond (r:1 w:0) + /// Proof: NominationPools MinCreateBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MinJoinBond (r:1 w:0) + /// Proof: NominationPools MinJoinBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPools (r:1 w:0) + /// Proof: NominationPools MaxPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForBondedPools (r:1 w:1) + /// Proof: NominationPools CounterForBondedPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) + /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembers (r:1 w:0) + /// Proof: NominationPools MaxPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForRewardPools (r:1 w:1) + /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools ReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools ReversePoolIdLookup (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 146_153 nanoseconds. - Weight::from_ref_time(146_955_000 as u64) - .saturating_add(T::DbWeight::get().reads(21 as u64)) - .saturating_add(T::DbWeight::get().writes(15 as u64)) + // Proof Size summary in bytes: + // Measured: `1321` + // Estimated: `31522` + // Minimum execution time: 131_430 nanoseconds. + Weight::from_parts(132_214_000, 31522) + .saturating_add(T::DbWeight::get().reads(21_u64)) + .saturating_add(T::DbWeight::get().writes(15_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:1 w:0) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:17 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - // Minimum execution time: 71_380 nanoseconds. - Weight::from_ref_time(71_060_388 as u64) - // Standard Error: 2_587 - .saturating_add(Weight::from_ref_time(1_185_729 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(12 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1909` + // Estimated: `21998 + n * (2520 ±0)` + // Minimum execution time: 61_798 nanoseconds. + Weight::from_parts(61_504_758, 21998) + // Standard Error: 4_046 + .saturating_add(Weight::from_ref_time(1_159_175).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(Weight::from_proof_size(2520).saturating_mul(n.into())) } - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_state() -> Weight { - // Minimum execution time: 46_275 nanoseconds. - Weight::from_ref_time(46_689_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1498` + // Estimated: `8752` + // Minimum execution time: 32_433 nanoseconds. + Weight::from_parts(32_894_000, 8752) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: NominationPools Metadata (r:1 w:1) - // Storage: NominationPools CounterForMetadata (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools Metadata (r:1 w:1) + /// Proof: NominationPools Metadata (max_values: None, max_size: Some(270), added: 2745, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForMetadata (r:1 w:1) + /// Proof: NominationPools CounterForMetadata (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { - // Minimum execution time: 19_246 nanoseconds. - Weight::from_ref_time(20_415_018 as u64) - // Standard Error: 95 - .saturating_add(Weight::from_ref_time(2_040 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5883` + // Minimum execution time: 13_608 nanoseconds. + Weight::from_parts(13_966_346, 5883) + // Standard Error: 44 + .saturating_add(Weight::from_ref_time(1_511).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: NominationPools MinJoinBond (r:0 w:1) - // Storage: NominationPools MaxPoolMembers (r:0 w:1) - // Storage: NominationPools MaxPoolMembersPerPool (r:0 w:1) - // Storage: NominationPools MinCreateBond (r:0 w:1) - // Storage: NominationPools MaxPools (r:0 w:1) + /// Storage: NominationPools MinJoinBond (r:0 w:1) + /// Proof: NominationPools MinJoinBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembers (r:0 w:1) + /// Proof: NominationPools MaxPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembersPerPool (r:0 w:1) + /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MinCreateBond (r:0 w:1) + /// Proof: NominationPools MinCreateBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPools (r:0 w:1) + /// Proof: NominationPools MaxPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_configs() -> Weight { - // Minimum execution time: 9_231 nanoseconds. - Weight::from_ref_time(9_526_000 as u64) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_832 nanoseconds. + Weight::from_ref_time(6_117_000) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: NominationPools BondedPools (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) fn update_roles() -> Weight { - // Minimum execution time: 31_246 nanoseconds. - Weight::from_ref_time(31_762_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `2639` + // Minimum execution time: 18_160 nanoseconds. + Weight::from_parts(18_567_000, 2639) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { - // Minimum execution time: 73_812 nanoseconds. - Weight::from_ref_time(74_790_000 as u64) - .saturating_add(T::DbWeight::get().reads(9 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `2136` + // Estimated: `20489` + // Minimum execution time: 58_991 nanoseconds. + Weight::from_parts(59_528_000, 20489) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: NominationPools MinJoinBond (r:1 w:0) - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:2 w:1) - // Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) - // Storage: NominationPools MaxPoolMembers (r:1 w:0) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: NominationPools MinJoinBond (r:1 w:0) + /// Proof: NominationPools MinJoinBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) + /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembers (r:1 w:0) + /// Proof: NominationPools MaxPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn join() -> Weight { - // Minimum execution time: 159_948 nanoseconds. - Weight::from_ref_time(161_133_000 as u64) - .saturating_add(RocksDbWeight::get().reads(17 as u64)) - .saturating_add(RocksDbWeight::get().writes(12 as u64)) + // Proof Size summary in bytes: + // Measured: `3573` + // Estimated: `37988` + // Minimum execution time: 140_155 nanoseconds. + Weight::from_parts(141_098_000, 37988) + .saturating_add(RocksDbWeight::get().reads(17_u64)) + .saturating_add(RocksDbWeight::get().writes(12_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:3 w:2) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_transfer() -> Weight { - // Minimum execution time: 155_517 nanoseconds. - Weight::from_ref_time(159_101_000 as u64) - .saturating_add(RocksDbWeight::get().reads(14 as u64)) - .saturating_add(RocksDbWeight::get().writes(12 as u64)) + // Proof Size summary in bytes: + // Measured: `3615` + // Estimated: `38583` + // Minimum execution time: 136_048 nanoseconds. + Weight::from_parts(136_767_000, 38583) + .saturating_add(RocksDbWeight::get().reads(14_u64)) + .saturating_add(RocksDbWeight::get().writes(12_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:3 w:3) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:3 w:3) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra_reward() -> Weight { - // Minimum execution time: 172_788 nanoseconds. - Weight::from_ref_time(174_212_000 as u64) - .saturating_add(RocksDbWeight::get().reads(14 as u64)) - .saturating_add(RocksDbWeight::get().writes(13 as u64)) + // Proof Size summary in bytes: + // Measured: `3615` + // Estimated: `38583` + // Minimum execution time: 151_473 nanoseconds. + Weight::from_parts(152_375_000, 38583) + .saturating_add(RocksDbWeight::get().reads(14_u64)) + .saturating_add(RocksDbWeight::get().writes(13_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn claim_payout() -> Weight { - // Minimum execution time: 64_560 nanoseconds. - Weight::from_ref_time(64_950_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `1189` + // Estimated: `10489` + // Minimum execution time: 51_146 nanoseconds. + Weight::from_parts(51_570_000, 10489) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: System Account (r:2 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) - // Storage: NominationPools SubPoolsStorage (r:1 w:1) - // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: NominationPools SubPoolsStorage (r:1 w:1) + /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn unbond() -> Weight { - // Minimum execution time: 161_398 nanoseconds. - Weight::from_ref_time(162_991_000 as u64) - .saturating_add(RocksDbWeight::get().reads(18 as u64)) - .saturating_add(RocksDbWeight::get().writes(13 as u64)) + // Proof Size summary in bytes: + // Measured: `3858` + // Estimated: `67379` + // Minimum execution time: 141_400 nanoseconds. + Weight::from_parts(141_822_000, 67379) + .saturating_add(RocksDbWeight::get().reads(18_u64)) + .saturating_add(RocksDbWeight::get().writes(13_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn pool_withdraw_unbonded(s: u32, ) -> Weight { - // Minimum execution time: 66_036 nanoseconds. - Weight::from_ref_time(67_183_304 as u64) - // Standard Error: 565 - .saturating_add(Weight::from_ref_time(57_830 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `1779` + // Estimated: `13025` + // Minimum execution time: 49_021 nanoseconds. + Weight::from_parts(49_954_282, 13025) + // Standard Error: 378 + .saturating_add(Weight::from_ref_time(5_165).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools SubPoolsStorage (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools SubPoolsStorage (r:1 w:1) + /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - // Minimum execution time: 111_156 nanoseconds. - Weight::from_ref_time(112_507_059 as u64) - // Standard Error: 655 - .saturating_add(Weight::from_ref_time(53_711 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(9 as u64)) - .saturating_add(RocksDbWeight::get().writes(7 as u64)) + // Proof Size summary in bytes: + // Measured: `2303` + // Estimated: `45696` + // Minimum execution time: 92_473 nanoseconds. + Weight::from_parts(93_901_972, 45696) + // Standard Error: 618 + .saturating_add(Weight::from_ref_time(12_032).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) } - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: NominationPools SubPoolsStorage (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:1 w:1) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) - // Storage: NominationPools ReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: NominationPools CounterForRewardPools (r:1 w:1) - // Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) - // Storage: NominationPools Metadata (r:1 w:1) - // Storage: NominationPools CounterForBondedPools (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools SubPoolsStorage (r:1 w:1) + /// Proof: NominationPools SubPoolsStorage (max_values: None, max_size: Some(24382), added: 26857, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:0) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools ReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools ReversePoolIdLookup (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForRewardPools (r:1 w:1) + /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForSubPoolsStorage (r:1 w:1) + /// Proof: NominationPools CounterForSubPoolsStorage (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools Metadata (r:1 w:1) + /// Proof: NominationPools Metadata (max_values: None, max_size: Some(270), added: 2745, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForBondedPools (r:1 w:1) + /// Proof: NominationPools CounterForBondedPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. - fn withdraw_unbonded_kill(s: u32, ) -> Weight { - // Minimum execution time: 168_270 nanoseconds. - Weight::from_ref_time(170_059_380 as u64) - // Standard Error: 1_506 - .saturating_add(Weight::from_ref_time(1_258 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(20 as u64)) - .saturating_add(RocksDbWeight::get().writes(17 as u64)) + fn withdraw_unbonded_kill(_s: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2690` + // Estimated: `68812` + // Minimum execution time: 150_063 nanoseconds. + Weight::from_parts(152_321_387, 68812) + .saturating_add(RocksDbWeight::get().reads(20_u64)) + .saturating_add(RocksDbWeight::get().writes(17_u64)) } - // Storage: NominationPools LastPoolId (r:1 w:1) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: NominationPools MinCreateBond (r:1 w:0) - // Storage: NominationPools MinJoinBond (r:1 w:0) - // Storage: NominationPools MaxPools (r:1 w:0) - // Storage: NominationPools CounterForBondedPools (r:1 w:1) - // Storage: NominationPools PoolMembers (r:1 w:1) - // Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) - // Storage: NominationPools MaxPoolMembers (r:1 w:0) - // Storage: NominationPools CounterForPoolMembers (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: NominationPools RewardPools (r:1 w:1) - // Storage: NominationPools CounterForRewardPools (r:1 w:1) - // Storage: NominationPools ReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: NominationPools LastPoolId (r:1 w:1) + /// Proof: NominationPools LastPoolId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MinCreateBond (r:1 w:0) + /// Proof: NominationPools MinCreateBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MinJoinBond (r:1 w:0) + /// Proof: NominationPools MinJoinBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPools (r:1 w:0) + /// Proof: NominationPools MaxPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForBondedPools (r:1 w:1) + /// Proof: NominationPools CounterForBondedPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools PoolMembers (r:1 w:1) + /// Proof: NominationPools PoolMembers (max_values: None, max_size: Some(237), added: 2712, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembersPerPool (r:1 w:0) + /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembers (r:1 w:0) + /// Proof: NominationPools MaxPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForPoolMembers (r:1 w:1) + /// Proof: NominationPools CounterForPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: NominationPools RewardPools (r:1 w:1) + /// Proof: NominationPools RewardPools (max_values: None, max_size: Some(60), added: 2535, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForRewardPools (r:1 w:1) + /// Proof: NominationPools CounterForRewardPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools ReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools ReversePoolIdLookup (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForReversePoolIdLookup (r:1 w:1) + /// Proof: NominationPools CounterForReversePoolIdLookup (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 146_153 nanoseconds. - Weight::from_ref_time(146_955_000 as u64) - .saturating_add(RocksDbWeight::get().reads(21 as u64)) - .saturating_add(RocksDbWeight::get().writes(15 as u64)) + // Proof Size summary in bytes: + // Measured: `1321` + // Estimated: `31522` + // Minimum execution time: 131_430 nanoseconds. + Weight::from_parts(132_214_000, 31522) + .saturating_add(RocksDbWeight::get().reads(21_u64)) + .saturating_add(RocksDbWeight::get().writes(15_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:1 w:0) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:17 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - // Minimum execution time: 71_380 nanoseconds. - Weight::from_ref_time(71_060_388 as u64) - // Standard Error: 2_587 - .saturating_add(Weight::from_ref_time(1_185_729 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(12 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(n as u64))) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1909` + // Estimated: `21998 + n * (2520 ±0)` + // Minimum execution time: 61_798 nanoseconds. + Weight::from_parts(61_504_758, 21998) + // Standard Error: 4_046 + .saturating_add(Weight::from_ref_time(1_159_175).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + .saturating_add(Weight::from_proof_size(2520).saturating_mul(n.into())) } - // Storage: NominationPools BondedPools (r:1 w:1) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_state() -> Weight { - // Minimum execution time: 46_275 nanoseconds. - Weight::from_ref_time(46_689_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `1498` + // Estimated: `8752` + // Minimum execution time: 32_433 nanoseconds. + Weight::from_parts(32_894_000, 8752) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: NominationPools Metadata (r:1 w:1) - // Storage: NominationPools CounterForMetadata (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: NominationPools Metadata (r:1 w:1) + /// Proof: NominationPools Metadata (max_values: None, max_size: Some(270), added: 2745, mode: MaxEncodedLen) + /// Storage: NominationPools CounterForMetadata (r:1 w:1) + /// Proof: NominationPools CounterForMetadata (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `n` is `[1, 256]`. fn set_metadata(n: u32, ) -> Weight { - // Minimum execution time: 19_246 nanoseconds. - Weight::from_ref_time(20_415_018 as u64) - // Standard Error: 95 - .saturating_add(Weight::from_ref_time(2_040 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5883` + // Minimum execution time: 13_608 nanoseconds. + Weight::from_parts(13_966_346, 5883) + // Standard Error: 44 + .saturating_add(Weight::from_ref_time(1_511).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: NominationPools MinJoinBond (r:0 w:1) - // Storage: NominationPools MaxPoolMembers (r:0 w:1) - // Storage: NominationPools MaxPoolMembersPerPool (r:0 w:1) - // Storage: NominationPools MinCreateBond (r:0 w:1) - // Storage: NominationPools MaxPools (r:0 w:1) + /// Storage: NominationPools MinJoinBond (r:0 w:1) + /// Proof: NominationPools MinJoinBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembers (r:0 w:1) + /// Proof: NominationPools MaxPoolMembers (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPoolMembersPerPool (r:0 w:1) + /// Proof: NominationPools MaxPoolMembersPerPool (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: NominationPools MinCreateBond (r:0 w:1) + /// Proof: NominationPools MinCreateBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: NominationPools MaxPools (r:0 w:1) + /// Proof: NominationPools MaxPools (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_configs() -> Weight { - // Minimum execution time: 9_231 nanoseconds. - Weight::from_ref_time(9_526_000 as u64) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_832 nanoseconds. + Weight::from_ref_time(6_117_000) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: NominationPools BondedPools (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:1) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) fn update_roles() -> Weight { - // Minimum execution time: 31_246 nanoseconds. - Weight::from_ref_time(31_762_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `2639` + // Minimum execution time: 18_160 nanoseconds. + Weight::from_parts(18_567_000, 2639) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: NominationPools BondedPools (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) + /// Storage: NominationPools BondedPools (r:1 w:0) + /// Proof: NominationPools BondedPools (max_values: None, max_size: Some(164), added: 2639, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { - // Minimum execution time: 73_812 nanoseconds. - Weight::from_ref_time(74_790_000 as u64) - .saturating_add(RocksDbWeight::get().reads(9 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `2136` + // Estimated: `20489` + // Minimum execution time: 58_991 nanoseconds. + Weight::from_parts(59_528_000, 20489) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } } diff --git a/frame/preimage/src/weights.rs b/frame/preimage/src/weights.rs index e73c986891..394c76956d 100644 --- a/frame/preimage/src/weights.rs +++ b/frame/preimage/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_preimage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -64,206 +65,314 @@ pub trait WeightInfo { /// Weights for pallet_preimage using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { - // Minimum execution time: 33_810 nanoseconds. - Weight::from_ref_time(34_299_000 as u64) + // Proof Size summary in bytes: + // Measured: `175` + // Estimated: `2566` + // Minimum execution time: 23_484 nanoseconds. + Weight::from_parts(23_828_000, 2566) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_703 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_705).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. fn note_requested_preimage(s: u32, ) -> Weight { - // Minimum execution time: 24_398 nanoseconds. - Weight::from_ref_time(24_839_000 as u64) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 14_812 nanoseconds. + Weight::from_parts(14_949_000, 2566) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_702 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_707).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. fn note_no_deposit_preimage(s: u32, ) -> Weight { - // Minimum execution time: 22_235 nanoseconds. - Weight::from_ref_time(22_473_000 as u64) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 14_185 nanoseconds. + Weight::from_parts(14_398_000, 2566) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_703 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_709).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_preimage() -> Weight { - // Minimum execution time: 43_241 nanoseconds. - Weight::from_ref_time(44_470_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `353` + // Estimated: `2566` + // Minimum execution time: 29_917 nanoseconds. + Weight::from_parts(30_691_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_no_deposit_preimage() -> Weight { - // Minimum execution time: 29_529 nanoseconds. - Weight::from_ref_time(30_364_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 19_281 nanoseconds. + Weight::from_parts(20_121_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_preimage() -> Weight { - // Minimum execution time: 28_914 nanoseconds. - Weight::from_ref_time(30_103_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `220` + // Estimated: `2566` + // Minimum execution time: 17_192 nanoseconds. + Weight::from_parts(18_637_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_no_deposit_preimage() -> Weight { - // Minimum execution time: 14_479 nanoseconds. - Weight::from_ref_time(15_244_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 10_139 nanoseconds. + Weight::from_parts(10_773_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_unnoted_preimage() -> Weight { - // Minimum execution time: 20_171 nanoseconds. - Weight::from_ref_time(20_806_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `2566` + // Minimum execution time: 11_721 nanoseconds. + Weight::from_parts(12_313_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_requested_preimage() -> Weight { - // Minimum execution time: 9_756 nanoseconds. - Weight::from_ref_time(10_115_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 7_263 nanoseconds. + Weight::from_parts(7_547_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unrequest_preimage() -> Weight { - // Minimum execution time: 28_379 nanoseconds. - Weight::from_ref_time(29_778_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 17_785 nanoseconds. + Weight::from_parts(18_501_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn unrequest_unnoted_preimage() -> Weight { - // Minimum execution time: 9_595 nanoseconds. - Weight::from_ref_time(9_888_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 7_090 nanoseconds. + Weight::from_parts(7_319_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn unrequest_multi_referenced_preimage() -> Weight { - // Minimum execution time: 9_642 nanoseconds. - Weight::from_ref_time(9_985_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 7_253 nanoseconds. + Weight::from_parts(7_508_000, 2566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. fn note_preimage(s: u32, ) -> Weight { - // Minimum execution time: 33_810 nanoseconds. - Weight::from_ref_time(34_299_000 as u64) + // Proof Size summary in bytes: + // Measured: `175` + // Estimated: `2566` + // Minimum execution time: 23_484 nanoseconds. + Weight::from_parts(23_828_000, 2566) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_703 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_705).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. fn note_requested_preimage(s: u32, ) -> Weight { - // Minimum execution time: 24_398 nanoseconds. - Weight::from_ref_time(24_839_000 as u64) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 14_812 nanoseconds. + Weight::from_parts(14_949_000, 2566) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_702 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_707).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) /// The range of component `s` is `[0, 4194304]`. fn note_no_deposit_preimage(s: u32, ) -> Weight { - // Minimum execution time: 22_235 nanoseconds. - Weight::from_ref_time(22_473_000 as u64) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 14_185 nanoseconds. + Weight::from_parts(14_398_000, 2566) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_703 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_709).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_preimage() -> Weight { - // Minimum execution time: 43_241 nanoseconds. - Weight::from_ref_time(44_470_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `353` + // Estimated: `2566` + // Minimum execution time: 29_917 nanoseconds. + Weight::from_parts(30_691_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unnote_no_deposit_preimage() -> Weight { - // Minimum execution time: 29_529 nanoseconds. - Weight::from_ref_time(30_364_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 19_281 nanoseconds. + Weight::from_parts(20_121_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_preimage() -> Weight { - // Minimum execution time: 28_914 nanoseconds. - Weight::from_ref_time(30_103_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `220` + // Estimated: `2566` + // Minimum execution time: 17_192 nanoseconds. + Weight::from_parts(18_637_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_no_deposit_preimage() -> Weight { - // Minimum execution time: 14_479 nanoseconds. - Weight::from_ref_time(15_244_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 10_139 nanoseconds. + Weight::from_parts(10_773_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_unnoted_preimage() -> Weight { - // Minimum execution time: 20_171 nanoseconds. - Weight::from_ref_time(20_806_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `2566` + // Minimum execution time: 11_721 nanoseconds. + Weight::from_parts(12_313_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn request_requested_preimage() -> Weight { - // Minimum execution time: 9_756 nanoseconds. - Weight::from_ref_time(10_115_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 7_263 nanoseconds. + Weight::from_parts(7_547_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) - // Storage: Preimage PreimageFor (r:0 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:0 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: MaxEncodedLen) fn unrequest_preimage() -> Weight { - // Minimum execution time: 28_379 nanoseconds. - Weight::from_ref_time(29_778_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2566` + // Minimum execution time: 17_785 nanoseconds. + Weight::from_parts(18_501_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn unrequest_unnoted_preimage() -> Weight { - // Minimum execution time: 9_595 nanoseconds. - Weight::from_ref_time(9_888_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 7_090 nanoseconds. + Weight::from_parts(7_319_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn unrequest_multi_referenced_preimage() -> Weight { - // Minimum execution time: 9_642 nanoseconds. - Weight::from_ref_time(9_985_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `106` + // Estimated: `2566` + // Minimum execution time: 7_253 nanoseconds. + Weight::from_parts(7_508_000, 2566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/proxy/src/weights.rs b/frame/proxy/src/weights.rs index 706810d340..53e368acae 100644 --- a/frame/proxy/src/weights.rs +++ b/frame/proxy/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_proxy //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -62,244 +63,334 @@ pub trait WeightInfo { /// Weights for pallet_proxy using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Proxy Proxies (r:1 w:0) + /// Storage: Proxy Proxies (r:1 w:0) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { - // Minimum execution time: 24_285 nanoseconds. - Weight::from_ref_time(25_355_667 as u64) - // Standard Error: 1_468 - .saturating_add(Weight::from_ref_time(38_185 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 14_461 nanoseconds. + Weight::from_parts(14_913_927, 3716) + // Standard Error: 1_174 + .saturating_add(Weight::from_ref_time(36_087).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) } - // Storage: Proxy Proxies (r:1 w:0) - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:0) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 44_948 nanoseconds. - Weight::from_ref_time(44_762_064 as u64) - // Standard Error: 1_778 - .saturating_add(Weight::from_ref_time(118_940 as u64).saturating_mul(a as u64)) - // Standard Error: 1_837 - .saturating_add(Weight::from_ref_time(51_232 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `584 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `11027` + // Minimum execution time: 31_523 nanoseconds. + Weight::from_parts(31_116_270, 11027) + // Standard Error: 1_789 + .saturating_add(Weight::from_ref_time(135_656).saturating_mul(a.into())) + // Standard Error: 1_849 + .saturating_add(Weight::from_ref_time(53_893).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn remove_announcement(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 31_274 nanoseconds. - Weight::from_ref_time(32_219_165 as u64) - // Standard Error: 1_832 - .saturating_add(Weight::from_ref_time(132_454 as u64).saturating_mul(a as u64)) - // Standard Error: 1_893 - .saturating_add(Weight::from_ref_time(9_077 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `467 + a * (68 ±0)` + // Estimated: `7311` + // Minimum execution time: 19_363 nanoseconds. + Weight::from_parts(20_282_191, 7311) + // Standard Error: 1_084 + .saturating_add(Weight::from_ref_time(133_825).saturating_mul(a.into())) + // Standard Error: 1_120 + .saturating_add(Weight::from_ref_time(3_434).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 31_219 nanoseconds. - Weight::from_ref_time(32_439_563 as u64) - // Standard Error: 1_829 - .saturating_add(Weight::from_ref_time(120_251 as u64).saturating_mul(a as u64)) - // Standard Error: 1_890 - .saturating_add(Weight::from_ref_time(8_689 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `467 + a * (68 ±0)` + // Estimated: `7311` + // Minimum execution time: 19_363 nanoseconds. + Weight::from_parts(20_211_584, 7311) + // Standard Error: 1_171 + .saturating_add(Weight::from_ref_time(136_984).saturating_mul(a.into())) + // Standard Error: 1_210 + .saturating_add(Weight::from_ref_time(3_686).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Proxy Proxies (r:1 w:0) - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:0) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 40_388 nanoseconds. - Weight::from_ref_time(40_718_245 as u64) - // Standard Error: 1_821 - .saturating_add(Weight::from_ref_time(129_674 as u64).saturating_mul(a as u64)) - // Standard Error: 1_882 - .saturating_add(Weight::from_ref_time(56_001 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `516 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `11027` + // Minimum execution time: 27_811 nanoseconds. + Weight::from_parts(27_965_813, 11027) + // Standard Error: 1_987 + .saturating_add(Weight::from_ref_time(124_133).saturating_mul(a.into())) + // Standard Error: 2_053 + .saturating_add(Weight::from_ref_time(54_692).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { - // Minimum execution time: 33_997 nanoseconds. - Weight::from_ref_time(34_840_036 as u64) - // Standard Error: 1_659 - .saturating_add(Weight::from_ref_time(71_349 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 20_922 nanoseconds. + Weight::from_parts(21_551_797, 3716) + // Standard Error: 1_425 + .saturating_add(Weight::from_ref_time(58_434).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { - // Minimum execution time: 33_900 nanoseconds. - Weight::from_ref_time(35_069_110 as u64) - // Standard Error: 1_848 - .saturating_add(Weight::from_ref_time(82_380 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 20_812 nanoseconds. + Weight::from_parts(21_660_732, 3716) + // Standard Error: 1_438 + .saturating_add(Weight::from_ref_time(68_740).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { - // Minimum execution time: 29_627 nanoseconds. - Weight::from_ref_time(30_641_642 as u64) - // Standard Error: 1_495 - .saturating_add(Weight::from_ref_time(51_919 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 16_786 nanoseconds. + Weight::from_parts(17_249_958, 3716) + // Standard Error: 1_007 + .saturating_add(Weight::from_ref_time(37_546).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn create_pure(p: u32, ) -> Weight { - // Minimum execution time: 37_761 nanoseconds. - Weight::from_ref_time(38_748_697 as u64) - // Standard Error: 1_594 - .saturating_add(Weight::from_ref_time(19_022 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `173` + // Estimated: `3716` + // Minimum execution time: 22_764 nanoseconds. + Weight::from_parts(23_539_039, 3716) + // Standard Error: 814 + .saturating_add(Weight::from_ref_time(144).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[0, 30]`. fn kill_pure(p: u32, ) -> Weight { - // Minimum execution time: 31_145 nanoseconds. - Weight::from_ref_time(31_933_568 as u64) - // Standard Error: 1_492 - .saturating_add(Weight::from_ref_time(50_250 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `230 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 17_720 nanoseconds. + Weight::from_parts(18_428_849, 3716) + // Standard Error: 1_093 + .saturating_add(Weight::from_ref_time(34_600).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Proxy Proxies (r:1 w:0) + /// Storage: Proxy Proxies (r:1 w:0) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn proxy(p: u32, ) -> Weight { - // Minimum execution time: 24_285 nanoseconds. - Weight::from_ref_time(25_355_667 as u64) - // Standard Error: 1_468 - .saturating_add(Weight::from_ref_time(38_185 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 14_461 nanoseconds. + Weight::from_parts(14_913_927, 3716) + // Standard Error: 1_174 + .saturating_add(Weight::from_ref_time(36_087).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) } - // Storage: Proxy Proxies (r:1 w:0) - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:0) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn proxy_announced(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 44_948 nanoseconds. - Weight::from_ref_time(44_762_064 as u64) - // Standard Error: 1_778 - .saturating_add(Weight::from_ref_time(118_940 as u64).saturating_mul(a as u64)) - // Standard Error: 1_837 - .saturating_add(Weight::from_ref_time(51_232 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `584 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `11027` + // Minimum execution time: 31_523 nanoseconds. + Weight::from_parts(31_116_270, 11027) + // Standard Error: 1_789 + .saturating_add(Weight::from_ref_time(135_656).saturating_mul(a.into())) + // Standard Error: 1_849 + .saturating_add(Weight::from_ref_time(53_893).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn remove_announcement(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 31_274 nanoseconds. - Weight::from_ref_time(32_219_165 as u64) - // Standard Error: 1_832 - .saturating_add(Weight::from_ref_time(132_454 as u64).saturating_mul(a as u64)) - // Standard Error: 1_893 - .saturating_add(Weight::from_ref_time(9_077 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `467 + a * (68 ±0)` + // Estimated: `7311` + // Minimum execution time: 19_363 nanoseconds. + Weight::from_parts(20_282_191, 7311) + // Standard Error: 1_084 + .saturating_add(Weight::from_ref_time(133_825).saturating_mul(a.into())) + // Standard Error: 1_120 + .saturating_add(Weight::from_ref_time(3_434).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn reject_announcement(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 31_219 nanoseconds. - Weight::from_ref_time(32_439_563 as u64) - // Standard Error: 1_829 - .saturating_add(Weight::from_ref_time(120_251 as u64).saturating_mul(a as u64)) - // Standard Error: 1_890 - .saturating_add(Weight::from_ref_time(8_689 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `467 + a * (68 ±0)` + // Estimated: `7311` + // Minimum execution time: 19_363 nanoseconds. + Weight::from_parts(20_211_584, 7311) + // Standard Error: 1_171 + .saturating_add(Weight::from_ref_time(136_984).saturating_mul(a.into())) + // Standard Error: 1_210 + .saturating_add(Weight::from_ref_time(3_686).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Proxy Proxies (r:1 w:0) - // Storage: Proxy Announcements (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:0) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) + /// Storage: Proxy Announcements (r:1 w:1) + /// Proof: Proxy Announcements (max_values: None, max_size: Some(2233), added: 4708, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `a` is `[0, 31]`. /// The range of component `p` is `[1, 31]`. fn announce(a: u32, p: u32, ) -> Weight { - // Minimum execution time: 40_388 nanoseconds. - Weight::from_ref_time(40_718_245 as u64) - // Standard Error: 1_821 - .saturating_add(Weight::from_ref_time(129_674 as u64).saturating_mul(a as u64)) - // Standard Error: 1_882 - .saturating_add(Weight::from_ref_time(56_001 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `516 + a * (68 ±0) + p * (37 ±0)` + // Estimated: `11027` + // Minimum execution time: 27_811 nanoseconds. + Weight::from_parts(27_965_813, 11027) + // Standard Error: 1_987 + .saturating_add(Weight::from_ref_time(124_133).saturating_mul(a.into())) + // Standard Error: 2_053 + .saturating_add(Weight::from_ref_time(54_692).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn add_proxy(p: u32, ) -> Weight { - // Minimum execution time: 33_997 nanoseconds. - Weight::from_ref_time(34_840_036 as u64) - // Standard Error: 1_659 - .saturating_add(Weight::from_ref_time(71_349 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 20_922 nanoseconds. + Weight::from_parts(21_551_797, 3716) + // Standard Error: 1_425 + .saturating_add(Weight::from_ref_time(58_434).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn remove_proxy(p: u32, ) -> Weight { - // Minimum execution time: 33_900 nanoseconds. - Weight::from_ref_time(35_069_110 as u64) - // Standard Error: 1_848 - .saturating_add(Weight::from_ref_time(82_380 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 20_812 nanoseconds. + Weight::from_parts(21_660_732, 3716) + // Standard Error: 1_438 + .saturating_add(Weight::from_ref_time(68_740).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn remove_proxies(p: u32, ) -> Weight { - // Minimum execution time: 29_627 nanoseconds. - Weight::from_ref_time(30_641_642 as u64) - // Standard Error: 1_495 - .saturating_add(Weight::from_ref_time(51_919 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `193 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 16_786 nanoseconds. + Weight::from_parts(17_249_958, 3716) + // Standard Error: 1_007 + .saturating_add(Weight::from_ref_time(37_546).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[1, 31]`. fn create_pure(p: u32, ) -> Weight { - // Minimum execution time: 37_761 nanoseconds. - Weight::from_ref_time(38_748_697 as u64) - // Standard Error: 1_594 - .saturating_add(Weight::from_ref_time(19_022 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `173` + // Estimated: `3716` + // Minimum execution time: 22_764 nanoseconds. + Weight::from_parts(23_539_039, 3716) + // Standard Error: 814 + .saturating_add(Weight::from_ref_time(144).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Proxy Proxies (r:1 w:1) + /// Storage: Proxy Proxies (r:1 w:1) + /// Proof: Proxy Proxies (max_values: None, max_size: Some(1241), added: 3716, mode: MaxEncodedLen) /// The range of component `p` is `[0, 30]`. fn kill_pure(p: u32, ) -> Weight { - // Minimum execution time: 31_145 nanoseconds. - Weight::from_ref_time(31_933_568 as u64) - // Standard Error: 1_492 - .saturating_add(Weight::from_ref_time(50_250 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `230 + p * (37 ±0)` + // Estimated: `3716` + // Minimum execution time: 17_720 nanoseconds. + Weight::from_parts(18_428_849, 3716) + // Standard Error: 1_093 + .saturating_add(Weight::from_ref_time(34_600).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/ranked-collective/src/weights.rs b/frame/ranked-collective/src/weights.rs index c054d20045..2d5ed3afdb 100644 --- a/frame/ranked-collective/src/weights.rs +++ b/frame/ranked-collective/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_ranked_collective //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -58,154 +59,238 @@ pub trait WeightInfo { /// Weights for pallet_ranked_collective using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IndexToId (r:0 w:1) - // Storage: RankedCollective IdToIndex (r:0 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) fn add_member() -> Weight { - // Minimum execution time: 24_344 nanoseconds. - Weight::from_ref_time(24_856_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `5006` + // Minimum execution time: 16_334 nanoseconds. + Weight::from_parts(16_784_000, 5006) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IdToIndex (r:1 w:1) - // Storage: RankedCollective IndexToId (r:1 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:11 w:11) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:11 w:11) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:11 w:11) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. fn remove_member(r: u32, ) -> Weight { - // Minimum execution time: 36_881 nanoseconds. - Weight::from_ref_time(39_284_238 as u64) - // Standard Error: 16_355 - .saturating_add(Weight::from_ref_time(11_385_424 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(r as u64))) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + // Proof Size summary in bytes: + // Measured: `583 + r * (281 ±0)` + // Estimated: `10064 + r * (7547 ±0)` + // Minimum execution time: 26_177 nanoseconds. + Weight::from_parts(29_245_248, 10064) + // Standard Error: 18_611 + .saturating_add(Weight::from_ref_time(10_916_516).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(7547).saturating_mul(r.into())) } - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IndexToId (r:0 w:1) - // Storage: RankedCollective IdToIndex (r:0 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. fn promote_member(r: u32, ) -> Weight { - // Minimum execution time: 27_444 nanoseconds. - Weight::from_ref_time(28_576_394 as u64) - // Standard Error: 4_818 - .saturating_add(Weight::from_ref_time(519_056 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `281 + r * (17 ±0)` + // Estimated: `5006` + // Minimum execution time: 18_953 nanoseconds. + Weight::from_parts(19_570_567, 5006) + // Standard Error: 4_156 + .saturating_add(Weight::from_ref_time(263_843).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IdToIndex (r:1 w:1) - // Storage: RankedCollective IndexToId (r:1 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:1 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:1 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. fn demote_member(r: u32, ) -> Weight { - // Minimum execution time: 36_539 nanoseconds. - Weight::from_ref_time(39_339_893 as u64) - // Standard Error: 16_526 - .saturating_add(Weight::from_ref_time(807_457 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `599 + r * (72 ±0)` + // Estimated: `10064` + // Minimum execution time: 26_243 nanoseconds. + Weight::from_parts(28_532_816, 10064) + // Standard Error: 22_689 + .saturating_add(Weight::from_ref_time(614_464).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: RankedCollective Members (r:1 w:0) - // Storage: RankedPolls ReferendumInfoFor (r:1 w:1) - // Storage: RankedCollective Voting (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedPolls ReferendumInfoFor (r:1 w:1) + /// Proof: RankedPolls ReferendumInfoFor (max_values: None, max_size: Some(330), added: 2805, mode: MaxEncodedLen) + /// Storage: RankedCollective Voting (r:1 w:1) + /// Proof: RankedCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote() -> Weight { - // Minimum execution time: 50_548 nanoseconds. - Weight::from_ref_time(51_276_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `626` + // Estimated: `226856` + // Minimum execution time: 41_121 nanoseconds. + Weight::from_parts(41_606_000, 226856) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: RankedPolls ReferendumInfoFor (r:1 w:0) - // Storage: RankedCollective VotingCleanup (r:1 w:0) - // Storage: RankedCollective Voting (r:0 w:2) + /// Storage: RankedPolls ReferendumInfoFor (r:1 w:0) + /// Proof: RankedPolls ReferendumInfoFor (max_values: None, max_size: Some(330), added: 2805, mode: MaxEncodedLen) + /// Storage: RankedCollective VotingCleanup (r:1 w:0) + /// Proof: RankedCollective VotingCleanup (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: RankedCollective Voting (r:0 w:100) + /// Proof: RankedCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. fn cleanup_poll(n: u32, ) -> Weight { - // Minimum execution time: 16_222 nanoseconds. - Weight::from_ref_time(22_982_955 as u64) - // Standard Error: 3_863 - .saturating_add(Weight::from_ref_time(1_074_054 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(n as u64))) + // Proof Size summary in bytes: + // Measured: `461 + n * (50 ±0)` + // Estimated: `5394` + // Minimum execution time: 13_245 nanoseconds. + Weight::from_parts(17_420_271, 5394) + // Standard Error: 1_503 + .saturating_add(Weight::from_ref_time(952_500).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IndexToId (r:0 w:1) - // Storage: RankedCollective IdToIndex (r:0 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) fn add_member() -> Weight { - // Minimum execution time: 24_344 nanoseconds. - Weight::from_ref_time(24_856_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `5006` + // Minimum execution time: 16_334 nanoseconds. + Weight::from_parts(16_784_000, 5006) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IdToIndex (r:1 w:1) - // Storage: RankedCollective IndexToId (r:1 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:11 w:11) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:11 w:11) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:11 w:11) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. fn remove_member(r: u32, ) -> Weight { - // Minimum execution time: 36_881 nanoseconds. - Weight::from_ref_time(39_284_238 as u64) - // Standard Error: 16_355 - .saturating_add(Weight::from_ref_time(11_385_424 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(r as u64))) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(r as u64))) + // Proof Size summary in bytes: + // Measured: `583 + r * (281 ±0)` + // Estimated: `10064 + r * (7547 ±0)` + // Minimum execution time: 26_177 nanoseconds. + Weight::from_parts(29_245_248, 10064) + // Standard Error: 18_611 + .saturating_add(Weight::from_ref_time(10_916_516).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(r.into()))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(r.into()))) + .saturating_add(Weight::from_proof_size(7547).saturating_mul(r.into())) } - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IndexToId (r:0 w:1) - // Storage: RankedCollective IdToIndex (r:0 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:0 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:0 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. fn promote_member(r: u32, ) -> Weight { - // Minimum execution time: 27_444 nanoseconds. - Weight::from_ref_time(28_576_394 as u64) - // Standard Error: 4_818 - .saturating_add(Weight::from_ref_time(519_056 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `281 + r * (17 ±0)` + // Estimated: `5006` + // Minimum execution time: 18_953 nanoseconds. + Weight::from_parts(19_570_567, 5006) + // Standard Error: 4_156 + .saturating_add(Weight::from_ref_time(263_843).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: RankedCollective Members (r:1 w:1) - // Storage: RankedCollective MemberCount (r:1 w:1) - // Storage: RankedCollective IdToIndex (r:1 w:1) - // Storage: RankedCollective IndexToId (r:1 w:1) + /// Storage: RankedCollective Members (r:1 w:1) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedCollective MemberCount (r:1 w:1) + /// Proof: RankedCollective MemberCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: RankedCollective IdToIndex (r:1 w:1) + /// Proof: RankedCollective IdToIndex (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: RankedCollective IndexToId (r:1 w:1) + /// Proof: RankedCollective IndexToId (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// The range of component `r` is `[0, 10]`. fn demote_member(r: u32, ) -> Weight { - // Minimum execution time: 36_539 nanoseconds. - Weight::from_ref_time(39_339_893 as u64) - // Standard Error: 16_526 - .saturating_add(Weight::from_ref_time(807_457 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `599 + r * (72 ±0)` + // Estimated: `10064` + // Minimum execution time: 26_243 nanoseconds. + Weight::from_parts(28_532_816, 10064) + // Standard Error: 22_689 + .saturating_add(Weight::from_ref_time(614_464).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: RankedCollective Members (r:1 w:0) - // Storage: RankedPolls ReferendumInfoFor (r:1 w:1) - // Storage: RankedCollective Voting (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + /// Storage: RankedCollective Members (r:1 w:0) + /// Proof: RankedCollective Members (max_values: None, max_size: Some(42), added: 2517, mode: MaxEncodedLen) + /// Storage: RankedPolls ReferendumInfoFor (r:1 w:1) + /// Proof: RankedPolls ReferendumInfoFor (max_values: None, max_size: Some(330), added: 2805, mode: MaxEncodedLen) + /// Storage: RankedCollective Voting (r:1 w:1) + /// Proof: RankedCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn vote() -> Weight { - // Minimum execution time: 50_548 nanoseconds. - Weight::from_ref_time(51_276_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `626` + // Estimated: `226856` + // Minimum execution time: 41_121 nanoseconds. + Weight::from_parts(41_606_000, 226856) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: RankedPolls ReferendumInfoFor (r:1 w:0) - // Storage: RankedCollective VotingCleanup (r:1 w:0) - // Storage: RankedCollective Voting (r:0 w:2) + /// Storage: RankedPolls ReferendumInfoFor (r:1 w:0) + /// Proof: RankedPolls ReferendumInfoFor (max_values: None, max_size: Some(330), added: 2805, mode: MaxEncodedLen) + /// Storage: RankedCollective VotingCleanup (r:1 w:0) + /// Proof: RankedCollective VotingCleanup (max_values: None, max_size: Some(114), added: 2589, mode: MaxEncodedLen) + /// Storage: RankedCollective Voting (r:0 w:100) + /// Proof: RankedCollective Voting (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen) /// The range of component `n` is `[0, 100]`. fn cleanup_poll(n: u32, ) -> Weight { - // Minimum execution time: 16_222 nanoseconds. - Weight::from_ref_time(22_982_955 as u64) - // Standard Error: 3_863 - .saturating_add(Weight::from_ref_time(1_074_054 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(n as u64))) + // Proof Size summary in bytes: + // Measured: `461 + n * (50 ±0)` + // Estimated: `5394` + // Minimum execution time: 13_245 nanoseconds. + Weight::from_parts(17_420_271, 5394) + // Standard Error: 1_503 + .saturating_add(Weight::from_ref_time(952_500).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) } } diff --git a/frame/recovery/src/weights.rs b/frame/recovery/src/weights.rs index 39a8d09a38..73f61654a6 100644 --- a/frame/recovery/src/weights.rs +++ b/frame/recovery/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_recovery //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -61,172 +62,256 @@ pub trait WeightInfo { /// Weights for pallet_recovery using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Recovery Proxy (r:1 w:0) + /// Storage: Recovery Proxy (r:1 w:0) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn as_recovered() -> Weight { - // Minimum execution time: 10_672 nanoseconds. - Weight::from_ref_time(10_946_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `281` + // Estimated: `2555` + // Minimum execution time: 8_866 nanoseconds. + Weight::from_parts(9_065_000, 2555) + .saturating_add(T::DbWeight::get().reads(1_u64)) } - // Storage: Recovery Proxy (r:0 w:1) + /// Storage: Recovery Proxy (r:0 w:1) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn set_recovered() -> Weight { - // Minimum execution time: 17_092 nanoseconds. - Weight::from_ref_time(17_660_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_893 nanoseconds. + Weight::from_ref_time(9_177_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Recovery Recoverable (r:1 w:1) + /// Storage: Recovery Recoverable (r:1 w:1) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn create_recovery(n: u32, ) -> Weight { - // Minimum execution time: 32_800 nanoseconds. - Weight::from_ref_time(33_769_078 as u64) - // Standard Error: 4_075 - .saturating_add(Weight::from_ref_time(252_382 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Recovery Recoverable (r:1 w:0) - // Storage: Recovery ActiveRecoveries (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `175` + // Estimated: `2826` + // Minimum execution time: 20_662 nanoseconds. + Weight::from_parts(21_378_064, 2826) + // Standard Error: 3_350 + .saturating_add(Weight::from_ref_time(83_738).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Recovery Recoverable (r:1 w:0) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) fn initiate_recovery() -> Weight { - // Minimum execution time: 39_224 nanoseconds. - Weight::from_ref_time(39_663_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `272` + // Estimated: `5690` + // Minimum execution time: 24_805 nanoseconds. + Weight::from_parts(25_273_000, 5690) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Recovery Recoverable (r:1 w:0) - // Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Storage: Recovery Recoverable (r:1 w:0) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn vouch_recovery(n: u32, ) -> Weight { - // Minimum execution time: 27_158 nanoseconds. - Weight::from_ref_time(28_130_506 as u64) - // Standard Error: 4_523 - .saturating_add(Weight::from_ref_time(321_436 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Recovery Recoverable (r:1 w:0) - // Storage: Recovery ActiveRecoveries (r:1 w:0) - // Storage: Recovery Proxy (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `423 + n * (64 ±0)` + // Estimated: `5690` + // Minimum execution time: 17_837 nanoseconds. + Weight::from_parts(18_429_664, 5690) + // Standard Error: 3_187 + .saturating_add(Weight::from_ref_time(143_648).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Recovery Recoverable (r:1 w:0) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: Recovery ActiveRecoveries (r:1 w:0) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: Recovery Proxy (r:1 w:1) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn claim_recovery(n: u32, ) -> Weight { - // Minimum execution time: 36_269 nanoseconds. - Weight::from_ref_time(36_966_173 as u64) - // Standard Error: 5_016 - .saturating_add(Weight::from_ref_time(223_069 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Recovery ActiveRecoveries (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `455 + n * (64 ±0)` + // Estimated: `8245` + // Minimum execution time: 21_960 nanoseconds. + Weight::from_parts(22_529_644, 8245) + // Standard Error: 2_945 + .saturating_add(Weight::from_ref_time(85_604).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn close_recovery(n: u32, ) -> Weight { - // Minimum execution time: 40_213 nanoseconds. - Weight::from_ref_time(41_140_968 as u64) - // Standard Error: 3_822 - .saturating_add(Weight::from_ref_time(163_217 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Recovery ActiveRecoveries (r:1 w:0) - // Storage: Recovery Recoverable (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `576 + n * (32 ±0)` + // Estimated: `5467` + // Minimum execution time: 26_054 nanoseconds. + Weight::from_parts(26_724_866, 5467) + // Standard Error: 2_645 + .saturating_add(Weight::from_ref_time(104_301).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Recovery ActiveRecoveries (r:1 w:0) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: Recovery Recoverable (r:1 w:1) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn remove_recovery(n: u32, ) -> Weight { - // Minimum execution time: 38_740 nanoseconds. - Weight::from_ref_time(39_710_400 as u64) - // Standard Error: 5_554 - .saturating_add(Weight::from_ref_time(224_200 as u64).saturating_mul(n as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Recovery Proxy (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `302 + n * (32 ±0)` + // Estimated: `5690` + // Minimum execution time: 25_110 nanoseconds. + Weight::from_parts(25_805_837, 5690) + // Standard Error: 2_732 + .saturating_add(Weight::from_ref_time(73_458).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Recovery Proxy (r:1 w:1) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn cancel_recovered() -> Weight { - // Minimum execution time: 20_316 nanoseconds. - Weight::from_ref_time(20_912_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `281` + // Estimated: `2555` + // Minimum execution time: 11_061 nanoseconds. + Weight::from_parts(11_291_000, 2555) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Recovery Proxy (r:1 w:0) + /// Storage: Recovery Proxy (r:1 w:0) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn as_recovered() -> Weight { - // Minimum execution time: 10_672 nanoseconds. - Weight::from_ref_time(10_946_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `281` + // Estimated: `2555` + // Minimum execution time: 8_866 nanoseconds. + Weight::from_parts(9_065_000, 2555) + .saturating_add(RocksDbWeight::get().reads(1_u64)) } - // Storage: Recovery Proxy (r:0 w:1) + /// Storage: Recovery Proxy (r:0 w:1) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn set_recovered() -> Weight { - // Minimum execution time: 17_092 nanoseconds. - Weight::from_ref_time(17_660_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_893 nanoseconds. + Weight::from_ref_time(9_177_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Recovery Recoverable (r:1 w:1) + /// Storage: Recovery Recoverable (r:1 w:1) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn create_recovery(n: u32, ) -> Weight { - // Minimum execution time: 32_800 nanoseconds. - Weight::from_ref_time(33_769_078 as u64) - // Standard Error: 4_075 - .saturating_add(Weight::from_ref_time(252_382 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Recovery Recoverable (r:1 w:0) - // Storage: Recovery ActiveRecoveries (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `175` + // Estimated: `2826` + // Minimum execution time: 20_662 nanoseconds. + Weight::from_parts(21_378_064, 2826) + // Standard Error: 3_350 + .saturating_add(Weight::from_ref_time(83_738).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Recovery Recoverable (r:1 w:0) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) fn initiate_recovery() -> Weight { - // Minimum execution time: 39_224 nanoseconds. - Weight::from_ref_time(39_663_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `272` + // Estimated: `5690` + // Minimum execution time: 24_805 nanoseconds. + Weight::from_parts(25_273_000, 5690) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Recovery Recoverable (r:1 w:0) - // Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Storage: Recovery Recoverable (r:1 w:0) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn vouch_recovery(n: u32, ) -> Weight { - // Minimum execution time: 27_158 nanoseconds. - Weight::from_ref_time(28_130_506 as u64) - // Standard Error: 4_523 - .saturating_add(Weight::from_ref_time(321_436 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Recovery Recoverable (r:1 w:0) - // Storage: Recovery ActiveRecoveries (r:1 w:0) - // Storage: Recovery Proxy (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `423 + n * (64 ±0)` + // Estimated: `5690` + // Minimum execution time: 17_837 nanoseconds. + Weight::from_parts(18_429_664, 5690) + // Standard Error: 3_187 + .saturating_add(Weight::from_ref_time(143_648).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Recovery Recoverable (r:1 w:0) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) + /// Storage: Recovery ActiveRecoveries (r:1 w:0) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: Recovery Proxy (r:1 w:1) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn claim_recovery(n: u32, ) -> Weight { - // Minimum execution time: 36_269 nanoseconds. - Weight::from_ref_time(36_966_173 as u64) - // Standard Error: 5_016 - .saturating_add(Weight::from_ref_time(223_069 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Recovery ActiveRecoveries (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `455 + n * (64 ±0)` + // Estimated: `8245` + // Minimum execution time: 21_960 nanoseconds. + Weight::from_parts(22_529_644, 8245) + // Standard Error: 2_945 + .saturating_add(Weight::from_ref_time(85_604).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Recovery ActiveRecoveries (r:1 w:1) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn close_recovery(n: u32, ) -> Weight { - // Minimum execution time: 40_213 nanoseconds. - Weight::from_ref_time(41_140_968 as u64) - // Standard Error: 3_822 - .saturating_add(Weight::from_ref_time(163_217 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Recovery ActiveRecoveries (r:1 w:0) - // Storage: Recovery Recoverable (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `576 + n * (32 ±0)` + // Estimated: `5467` + // Minimum execution time: 26_054 nanoseconds. + Weight::from_parts(26_724_866, 5467) + // Standard Error: 2_645 + .saturating_add(Weight::from_ref_time(104_301).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Recovery ActiveRecoveries (r:1 w:0) + /// Proof: Recovery ActiveRecoveries (max_values: None, max_size: Some(389), added: 2864, mode: MaxEncodedLen) + /// Storage: Recovery Recoverable (r:1 w:1) + /// Proof: Recovery Recoverable (max_values: None, max_size: Some(351), added: 2826, mode: MaxEncodedLen) /// The range of component `n` is `[1, 9]`. fn remove_recovery(n: u32, ) -> Weight { - // Minimum execution time: 38_740 nanoseconds. - Weight::from_ref_time(39_710_400 as u64) - // Standard Error: 5_554 - .saturating_add(Weight::from_ref_time(224_200 as u64).saturating_mul(n as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Recovery Proxy (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `302 + n * (32 ±0)` + // Estimated: `5690` + // Minimum execution time: 25_110 nanoseconds. + Weight::from_parts(25_805_837, 5690) + // Standard Error: 2_732 + .saturating_add(Weight::from_ref_time(73_458).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Recovery Proxy (r:1 w:1) + /// Proof: Recovery Proxy (max_values: None, max_size: Some(80), added: 2555, mode: MaxEncodedLen) fn cancel_recovered() -> Weight { - // Minimum execution time: 20_316 nanoseconds. - Weight::from_ref_time(20_912_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `281` + // Estimated: `2555` + // Minimum execution time: 11_061 nanoseconds. + Weight::from_parts(11_291_000, 2555) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index e957027e56..82ae508d52 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -62,7 +62,7 @@ impl Contains for BaseFilter { } parameter_types! { - pub MaxWeight: Weight = Weight::from_ref_time(2_000_000_000_000); + pub MaxWeight: Weight = Weight::from_parts(2_000_000_000_000, u64::MAX); } impl frame_system::Config for Test { type BaseCallFilter = BaseFilter; diff --git a/frame/referenda/src/weights.rs b/frame/referenda/src/weights.rs index f0eae517af..68b44e8bef 100644 --- a/frame/referenda/src/weights.rs +++ b/frame/referenda/src/weights.rs @@ -1,3 +1,8 @@ +// This file is part of Substrate. + +// Copyright (C) 2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -13,22 +18,25 @@ //! Autogenerated weights for pallet_referenda //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-27, STEPS: `20`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/substrate +// ./target/production/substrate // benchmark // pallet // --chain=dev -// --steps=20 -// --repeat=1 -// --pallet=pallet-referenda +// --steps=50 +// --repeat=20 +// --pallet=pallet_referenda // --extrinsic=* +// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/referenda/src/._weights.rs +// --output=./frame/referenda/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -73,482 +81,788 @@ pub trait WeightInfo { /// Weights for pallet_referenda using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Referenda ReferendumCount (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:0 w:1) + /// Storage: Referenda ReferendumCount (r:1 w:1) + /// Proof: Referenda ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:0 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn submit() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `251` + // Estimated: `109996` + // Minimum execution time: 32_207 nanoseconds. + Weight::from_parts(32_639_000, 109996) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_preparing() -> Weight { - // Minimum execution time: 35_000 nanoseconds. - Weight::from_ref_time(35_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `536` + // Estimated: `221835` + // Minimum execution time: 43_766 nanoseconds. + Weight::from_parts(44_494_000, 221835) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_queued() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(40_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3203` + // Estimated: `9817` + // Minimum execution time: 41_561 nanoseconds. + Weight::from_parts(42_180_000, 9817) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_not_queued() -> Weight { - // Minimum execution time: 39_000 nanoseconds. - Weight::from_ref_time(39_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `3223` + // Estimated: `9817` + // Minimum execution time: 41_039 nanoseconds. + Weight::from_parts(41_673_000, 9817) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_passing() -> Weight { - // Minimum execution time: 43_000 nanoseconds. - Weight::from_ref_time(43_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `536` + // Estimated: `224324` + // Minimum execution time: 52_922 nanoseconds. + Weight::from_parts(53_395_000, 224324) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_failing() -> Weight { - // Minimum execution time: 84_000 nanoseconds. - Weight::from_ref_time(84_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `536` + // Estimated: `224324` + // Minimum execution time: 51_050 nanoseconds. + Weight::from_parts(51_736_000, 224324) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_decision_deposit() -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(25_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `415` + // Estimated: `2841` + // Minimum execution time: 24_102 nanoseconds. + Weight::from_parts(24_372_000, 2841) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_submission_deposit() -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(25_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `405` + // Estimated: `2841` + // Minimum execution time: 24_162 nanoseconds. + Weight::from_parts(24_547_000, 2841) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn cancel() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(26_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `221835` + // Minimum execution time: 32_247 nanoseconds. + Weight::from_parts(32_731_000, 221835) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn kill() -> Weight { - // Minimum execution time: 47_000 nanoseconds. - Weight::from_ref_time(47_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda TrackQueue (r:1 w:0) - // Storage: Referenda DecidingCount (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `717` + // Estimated: `221835` + // Minimum execution time: 59_900 nanoseconds. + Weight::from_parts(60_659_000, 221835) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda TrackQueue (r:1 w:0) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) fn one_fewer_deciding_queue_empty() -> Weight { - // Minimum execution time: 8_000 nanoseconds. - Weight::from_ref_time(8_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `174` + // Estimated: `6976` + // Minimum execution time: 9_322 nanoseconds. + Weight::from_parts(9_638_000, 6976) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_failing() -> Weight { - // Minimum execution time: 88_000 nanoseconds. - Weight::from_ref_time(88_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `4661` + // Estimated: `226322` + // Minimum execution time: 76_976 nanoseconds. + Weight::from_parts(77_597_000, 226322) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_passing() -> Weight { - // Minimum execution time: 75_000 nanoseconds. - Weight::from_ref_time(75_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4661` + // Estimated: `226322` + // Minimum execution time: 78_405 nanoseconds. + Weight::from_parts(78_972_000, 226322) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_insertion() -> Weight { - // Minimum execution time: 72_000 nanoseconds. - Weight::from_ref_time(72_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4682` + // Estimated: `116825` + // Minimum execution time: 51_360 nanoseconds. + Weight::from_parts(51_737_000, 116825) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_slide() -> Weight { - // Minimum execution time: 56_000 nanoseconds. - Weight::from_ref_time(56_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4668` + // Estimated: `116825` + // Minimum execution time: 50_485 nanoseconds. + Weight::from_parts(51_601_000, 116825) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_queued() -> Weight { - // Minimum execution time: 55_000 nanoseconds. - Weight::from_ref_time(55_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4642` + // Estimated: `119314` + // Minimum execution time: 53_075 nanoseconds. + Weight::from_parts(54_014_000, 119314) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_not_queued() -> Weight { - // Minimum execution time: 60_000 nanoseconds. - Weight::from_ref_time(60_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4676` + // Estimated: `119314` + // Minimum execution time: 52_916 nanoseconds. + Weight::from_parts(53_716_000, 119314) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_no_deposit() -> Weight { - // Minimum execution time: 22_000 nanoseconds. - Weight::from_ref_time(22_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `364` + // Estimated: `112338` + // Minimum execution time: 21_920 nanoseconds. + Weight::from_parts(22_172_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_preparing() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(21_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `112338` + // Minimum execution time: 22_094 nanoseconds. + Weight::from_parts(22_314_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn nudge_referendum_timed_out() -> Weight { - // Minimum execution time: 17_000 nanoseconds. - Weight::from_ref_time(17_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `310` + // Estimated: `2841` + // Minimum execution time: 15_696 nanoseconds. + Weight::from_parts(15_964_000, 2841) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_failing() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `114827` + // Minimum execution time: 30_604 nanoseconds. + Weight::from_parts(31_126_000, 114827) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_passing() -> Weight { - // Minimum execution time: 39_000 nanoseconds. - Weight::from_ref_time(39_000_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `114827` + // Minimum execution time: 32_961 nanoseconds. + Weight::from_parts(33_295_000, 114827) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_confirming() -> Weight { - // Minimum execution time: 31_000 nanoseconds. - Weight::from_ref_time(31_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `465` + // Estimated: `112338` + // Minimum execution time: 27_072 nanoseconds. + Weight::from_parts(27_405_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_end_confirming() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(30_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `448` + // Estimated: `112338` + // Minimum execution time: 27_056 nanoseconds. + Weight::from_parts(27_768_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_not_confirming() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(28_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `465` + // Estimated: `112338` + // Minimum execution time: 24_599 nanoseconds. + Weight::from_parts(25_170_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_confirming() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(30_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Scheduler Lookup (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `469` + // Estimated: `112338` + // Minimum execution time: 23_737 nanoseconds. + Weight::from_parts(24_184_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn nudge_referendum_approved() -> Weight { - // Minimum execution time: 45_000 nanoseconds. - Weight::from_ref_time(45_000_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `469` + // Estimated: `224358` + // Minimum execution time: 37_880 nanoseconds. + Weight::from_parts(38_537_000, 224358) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_rejected() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(30_000_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `465` + // Estimated: `112338` + // Minimum execution time: 26_898 nanoseconds. + Weight::from_parts(27_496_000, 112338) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Referenda ReferendumCount (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:0 w:1) + /// Storage: Referenda ReferendumCount (r:1 w:1) + /// Proof: Referenda ReferendumCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:0 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn submit() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `251` + // Estimated: `109996` + // Minimum execution time: 32_207 nanoseconds. + Weight::from_parts(32_639_000, 109996) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_preparing() -> Weight { - // Minimum execution time: 35_000 nanoseconds. - Weight::from_ref_time(35_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `536` + // Estimated: `221835` + // Minimum execution time: 43_766 nanoseconds. + Weight::from_parts(44_494_000, 221835) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_queued() -> Weight { - // Minimum execution time: 40_000 nanoseconds. - Weight::from_ref_time(40_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `3203` + // Estimated: `9817` + // Minimum execution time: 41_561 nanoseconds. + Weight::from_parts(42_180_000, 9817) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) fn place_decision_deposit_not_queued() -> Weight { - // Minimum execution time: 39_000 nanoseconds. - Weight::from_ref_time(39_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `3223` + // Estimated: `9817` + // Minimum execution time: 41_039 nanoseconds. + Weight::from_parts(41_673_000, 9817) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_passing() -> Weight { - // Minimum execution time: 43_000 nanoseconds. - Weight::from_ref_time(43_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `536` + // Estimated: `224324` + // Minimum execution time: 52_922 nanoseconds. + Weight::from_parts(53_395_000, 224324) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn place_decision_deposit_failing() -> Weight { - // Minimum execution time: 84_000 nanoseconds. - Weight::from_ref_time(84_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `536` + // Estimated: `224324` + // Minimum execution time: 51_050 nanoseconds. + Weight::from_parts(51_736_000, 224324) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_decision_deposit() -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(25_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `415` + // Estimated: `2841` + // Minimum execution time: 24_102 nanoseconds. + Weight::from_parts(24_372_000, 2841) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn refund_submission_deposit() -> Weight { - // Minimum execution time: 25_000 nanoseconds. - Weight::from_ref_time(25_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `405` + // Estimated: `2841` + // Minimum execution time: 24_162 nanoseconds. + Weight::from_parts(24_547_000, 2841) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn cancel() -> Weight { - // Minimum execution time: 26_000 nanoseconds. - Weight::from_ref_time(26_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `221835` + // Minimum execution time: 32_247 nanoseconds. + Weight::from_parts(32_731_000, 221835) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn kill() -> Weight { - // Minimum execution time: 47_000 nanoseconds. - Weight::from_ref_time(47_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda TrackQueue (r:1 w:0) - // Storage: Referenda DecidingCount (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `717` + // Estimated: `221835` + // Minimum execution time: 59_900 nanoseconds. + Weight::from_parts(60_659_000, 221835) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda TrackQueue (r:1 w:0) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) fn one_fewer_deciding_queue_empty() -> Weight { - // Minimum execution time: 8_000 nanoseconds. - Weight::from_ref_time(8_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `174` + // Estimated: `6976` + // Minimum execution time: 9_322 nanoseconds. + Weight::from_parts(9_638_000, 6976) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_failing() -> Weight { - // Minimum execution time: 88_000 nanoseconds. - Weight::from_ref_time(88_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `4661` + // Estimated: `226322` + // Minimum execution time: 76_976 nanoseconds. + Weight::from_parts(77_597_000, 226322) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn one_fewer_deciding_passing() -> Weight { - // Minimum execution time: 75_000 nanoseconds. - Weight::from_ref_time(75_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4661` + // Estimated: `226322` + // Minimum execution time: 78_405 nanoseconds. + Weight::from_parts(78_972_000, 226322) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_insertion() -> Weight { - // Minimum execution time: 72_000 nanoseconds. - Weight::from_ref_time(72_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4682` + // Estimated: `116825` + // Minimum execution time: 51_360 nanoseconds. + Weight::from_parts(51_737_000, 116825) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_requeued_slide() -> Weight { - // Minimum execution time: 56_000 nanoseconds. - Weight::from_ref_time(56_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4668` + // Estimated: `116825` + // Minimum execution time: 50_485 nanoseconds. + Weight::from_parts(51_601_000, 116825) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_queued() -> Weight { - // Minimum execution time: 55_000 nanoseconds. - Weight::from_ref_time(55_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:0) - // Storage: Referenda TrackQueue (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4642` + // Estimated: `119314` + // Minimum execution time: 53_075 nanoseconds. + Weight::from_parts(54_014_000, 119314) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:0) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Referenda TrackQueue (r:1 w:1) + /// Proof: Referenda TrackQueue (max_values: None, max_size: Some(2012), added: 4487, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_not_queued() -> Weight { - // Minimum execution time: 60_000 nanoseconds. - Weight::from_ref_time(60_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `4676` + // Estimated: `119314` + // Minimum execution time: 52_916 nanoseconds. + Weight::from_parts(53_716_000, 119314) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_no_deposit() -> Weight { - // Minimum execution time: 22_000 nanoseconds. - Weight::from_ref_time(22_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `364` + // Estimated: `112338` + // Minimum execution time: 21_920 nanoseconds. + Weight::from_parts(22_172_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_preparing() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_ref_time(21_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `112338` + // Minimum execution time: 22_094 nanoseconds. + Weight::from_parts(22_314_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) fn nudge_referendum_timed_out() -> Weight { - // Minimum execution time: 17_000 nanoseconds. - Weight::from_ref_time(17_000_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `310` + // Estimated: `2841` + // Minimum execution time: 15_696 nanoseconds. + Weight::from_parts(15_964_000, 2841) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_failing() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_ref_time(29_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Referenda DecidingCount (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `114827` + // Minimum execution time: 30_604 nanoseconds. + Weight::from_parts(31_126_000, 114827) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Referenda DecidingCount (r:1 w:1) + /// Proof: Referenda DecidingCount (max_values: None, max_size: Some(14), added: 2489, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_deciding_passing() -> Weight { - // Minimum execution time: 39_000 nanoseconds. - Weight::from_ref_time(39_000_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `412` + // Estimated: `114827` + // Minimum execution time: 32_961 nanoseconds. + Weight::from_parts(33_295_000, 114827) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_begin_confirming() -> Weight { - // Minimum execution time: 31_000 nanoseconds. - Weight::from_ref_time(31_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `465` + // Estimated: `112338` + // Minimum execution time: 27_072 nanoseconds. + Weight::from_parts(27_405_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_end_confirming() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(30_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `448` + // Estimated: `112338` + // Minimum execution time: 27_056 nanoseconds. + Weight::from_parts(27_768_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_not_confirming() -> Weight { - // Minimum execution time: 28_000 nanoseconds. - Weight::from_ref_time(28_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `465` + // Estimated: `112338` + // Minimum execution time: 24_599 nanoseconds. + Weight::from_parts(25_170_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_continue_confirming() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(30_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: Scheduler Lookup (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `469` + // Estimated: `112338` + // Minimum execution time: 23_737 nanoseconds. + Weight::from_parts(24_184_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:2 w:2) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn nudge_referendum_approved() -> Weight { - // Minimum execution time: 45_000 nanoseconds. - Weight::from_ref_time(45_000_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Referenda ReferendumInfoFor (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `469` + // Estimated: `224358` + // Minimum execution time: 37_880 nanoseconds. + Weight::from_parts(38_537_000, 224358) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Referenda ReferendumInfoFor (r:1 w:1) + /// Proof: Referenda ReferendumInfoFor (max_values: None, max_size: Some(366), added: 2841, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) fn nudge_referendum_rejected() -> Weight { - // Minimum execution time: 30_000 nanoseconds. - Weight::from_ref_time(30_000_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `465` + // Estimated: `112338` + // Minimum execution time: 26_898 nanoseconds. + Weight::from_parts(27_496_000, 112338) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/remark/src/weights.rs b/frame/remark/src/weights.rs index 0d739657c8..9142ed04c5 100644 --- a/frame/remark/src/weights.rs +++ b/frame/remark/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_remark //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -53,26 +54,28 @@ pub trait WeightInfo { /// Weights for pallet_remark using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `l` is `[1, 1048576]`. fn store(l: u32, ) -> Weight { - // Minimum execution time: 17_017 nanoseconds. - Weight::from_ref_time(8_269_935 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_404 nanoseconds. + Weight::from_ref_time(343_031) // Standard Error: 1 - .saturating_add(Weight::from_ref_time(1_407 as u64).saturating_mul(l as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) + .saturating_add(Weight::from_ref_time(1_404).saturating_mul(l.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) /// The range of component `l` is `[1, 1048576]`. fn store(l: u32, ) -> Weight { - // Minimum execution time: 17_017 nanoseconds. - Weight::from_ref_time(8_269_935 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_404 nanoseconds. + Weight::from_ref_time(343_031) // Standard Error: 1 - .saturating_add(Weight::from_ref_time(1_407 as u64).saturating_mul(l as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) + .saturating_add(Weight::from_ref_time(1_404).saturating_mul(l.into())) } } diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index ca98cabc3c..8e2876290b 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -160,6 +160,10 @@ benchmarks! { // `service_task` when the task is a non-periodic, non-named, fetched call (with a known // preimage length) and which is not dispatched (e.g. due to being overweight). + #[pov_mode = MaxEncodedLen { + // Use measured PoV size for the Preimages since we pass in a length witness. + Preimage::PreimageFor: Measured + }] service_task_fetched { let s in (BoundedInline::bound() as u32) .. (T::Preimages::MAX_LENGTH as u32); let now = BLOCK_NUMBER.into(); diff --git a/frame/scheduler/src/weights.rs b/frame/scheduler/src/weights.rs index 5b86e7a143..9be3bfaef5 100644 --- a/frame/scheduler/src/weights.rs +++ b/frame/scheduler/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_scheduler //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -64,194 +65,292 @@ pub trait WeightInfo { /// Weights for pallet_scheduler using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Scheduler IncompleteSince (r:1 w:1) + /// Storage: Scheduler IncompleteSince (r:1 w:1) + /// Proof: Scheduler IncompleteSince (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn service_agendas_base() -> Weight { - // Minimum execution time: 5_131 nanoseconds. - Weight::from_ref_time(5_286_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `30` + // Estimated: `499` + // Minimum execution time: 3_670 nanoseconds. + Weight::from_parts(3_838_000, 499) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 512]`. fn service_agenda_base(s: u32, ) -> Weight { - // Minimum execution time: 4_111 nanoseconds. - Weight::from_ref_time(8_763_440 as u64) - // Standard Error: 783 - .saturating_add(Weight::from_ref_time(372_339 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `112 + s * (177 ±0)` + // Estimated: `109497` + // Minimum execution time: 3_079 nanoseconds. + Weight::from_parts(7_087_647, 109497) + // Standard Error: 658 + .saturating_add(Weight::from_ref_time(279_320).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn service_task_base() -> Weight { - // Minimum execution time: 10_880 nanoseconds. - Weight::from_ref_time(11_194_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_192 nanoseconds. + Weight::from_ref_time(5_528_000) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `s` is `[128, 4194304]`. fn service_task_fetched(s: u32, ) -> Weight { - // Minimum execution time: 25_347 nanoseconds. - Weight::from_ref_time(25_717_000 as u64) + // Proof Size summary in bytes: + // Measured: `211 + s * (1 ±0)` + // Estimated: `5252 + s * (1 ±0)` + // Minimum execution time: 17_284 nanoseconds. + Weight::from_parts(17_574_000, 5252) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_128 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_126).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(s.into())) } - // Storage: Scheduler Lookup (r:0 w:1) + /// Storage: Scheduler Lookup (r:0 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn service_task_named() -> Weight { - // Minimum execution time: 12_894 nanoseconds. - Weight::from_ref_time(13_108_000 as u64) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_020 nanoseconds. + Weight::from_ref_time(7_262_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn service_task_periodic() -> Weight { - // Minimum execution time: 10_667 nanoseconds. - Weight::from_ref_time(10_908_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_187 nanoseconds. + Weight::from_ref_time(5_368_000) } fn execute_dispatch_signed() -> Weight { - // Minimum execution time: 4_124 nanoseconds. - Weight::from_ref_time(4_680_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_313 nanoseconds. + Weight::from_ref_time(2_404_000) } fn execute_dispatch_unsigned() -> Weight { - // Minimum execution time: 4_156 nanoseconds. - Weight::from_ref_time(4_361_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_187 nanoseconds. + Weight::from_ref_time(2_362_000) } - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 511]`. fn schedule(s: u32, ) -> Weight { - // Minimum execution time: 20_504 nanoseconds. - Weight::from_ref_time(27_066_818 as u64) - // Standard Error: 1_114 - .saturating_add(Weight::from_ref_time(372_897 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `112 + s * (177 ±0)` + // Estimated: `109497` + // Minimum execution time: 11_971 nanoseconds. + Weight::from_parts(16_060_361, 109497) + // Standard Error: 665 + .saturating_add(Weight::from_ref_time(286_324).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Scheduler Lookup (r:0 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// The range of component `s` is `[1, 512]`. fn cancel(s: u32, ) -> Weight { - // Minimum execution time: 21_686 nanoseconds. - Weight::from_ref_time(25_696_496 as u64) - // Standard Error: 1_261 - .saturating_add(Weight::from_ref_time(362_498 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `112 + s * (177 ±0)` + // Estimated: `109497` + // Minimum execution time: 15_594 nanoseconds. + Weight::from_parts(17_191_501, 109497) + // Standard Error: 626 + .saturating_add(Weight::from_ref_time(425_572).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 511]`. fn schedule_named(s: u32, ) -> Weight { - // Minimum execution time: 23_084 nanoseconds. - Weight::from_ref_time(31_255_518 as u64) - // Standard Error: 1_258 - .saturating_add(Weight::from_ref_time(382_534 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `627 + s * (178 ±0)` + // Estimated: `112020` + // Minimum execution time: 15_127 nanoseconds. + Weight::from_parts(20_932_642, 112020) + // Standard Error: 692 + .saturating_add(Weight::from_ref_time(288_344).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[1, 512]`. fn cancel_named(s: u32, ) -> Weight { - // Minimum execution time: 23_862 nanoseconds. - Weight::from_ref_time(28_591_336 as u64) - // Standard Error: 742 - .saturating_add(Weight::from_ref_time(369_305 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `740 + s * (177 ±0)` + // Estimated: `112020` + // Minimum execution time: 16_859 nanoseconds. + Weight::from_parts(19_736_937, 112020) + // Standard Error: 676 + .saturating_add(Weight::from_ref_time(429_770).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Scheduler IncompleteSince (r:1 w:1) + /// Storage: Scheduler IncompleteSince (r:1 w:1) + /// Proof: Scheduler IncompleteSince (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn service_agendas_base() -> Weight { - // Minimum execution time: 5_131 nanoseconds. - Weight::from_ref_time(5_286_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `30` + // Estimated: `499` + // Minimum execution time: 3_670 nanoseconds. + Weight::from_parts(3_838_000, 499) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 512]`. fn service_agenda_base(s: u32, ) -> Weight { - // Minimum execution time: 4_111 nanoseconds. - Weight::from_ref_time(8_763_440 as u64) - // Standard Error: 783 - .saturating_add(Weight::from_ref_time(372_339 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `112 + s * (177 ±0)` + // Estimated: `109497` + // Minimum execution time: 3_079 nanoseconds. + Weight::from_parts(7_087_647, 109497) + // Standard Error: 658 + .saturating_add(Weight::from_ref_time(279_320).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn service_task_base() -> Weight { - // Minimum execution time: 10_880 nanoseconds. - Weight::from_ref_time(11_194_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_192 nanoseconds. + Weight::from_ref_time(5_528_000) } - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `s` is `[128, 4194304]`. fn service_task_fetched(s: u32, ) -> Weight { - // Minimum execution time: 25_347 nanoseconds. - Weight::from_ref_time(25_717_000 as u64) + // Proof Size summary in bytes: + // Measured: `211 + s * (1 ±0)` + // Estimated: `5252 + s * (1 ±0)` + // Minimum execution time: 17_284 nanoseconds. + Weight::from_parts(17_574_000, 5252) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_128 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(Weight::from_ref_time(1_126).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(s.into())) } - // Storage: Scheduler Lookup (r:0 w:1) + /// Storage: Scheduler Lookup (r:0 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) fn service_task_named() -> Weight { - // Minimum execution time: 12_894 nanoseconds. - Weight::from_ref_time(13_108_000 as u64) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_020 nanoseconds. + Weight::from_ref_time(7_262_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn service_task_periodic() -> Weight { - // Minimum execution time: 10_667 nanoseconds. - Weight::from_ref_time(10_908_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 5_187 nanoseconds. + Weight::from_ref_time(5_368_000) } fn execute_dispatch_signed() -> Weight { - // Minimum execution time: 4_124 nanoseconds. - Weight::from_ref_time(4_680_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_313 nanoseconds. + Weight::from_ref_time(2_404_000) } fn execute_dispatch_unsigned() -> Weight { - // Minimum execution time: 4_156 nanoseconds. - Weight::from_ref_time(4_361_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_187 nanoseconds. + Weight::from_ref_time(2_362_000) } - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 511]`. fn schedule(s: u32, ) -> Weight { - // Minimum execution time: 20_504 nanoseconds. - Weight::from_ref_time(27_066_818 as u64) - // Standard Error: 1_114 - .saturating_add(Weight::from_ref_time(372_897 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `112 + s * (177 ±0)` + // Estimated: `109497` + // Minimum execution time: 11_971 nanoseconds. + Weight::from_parts(16_060_361, 109497) + // Standard Error: 665 + .saturating_add(Weight::from_ref_time(286_324).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: Scheduler Lookup (r:0 w:1) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) + /// Storage: Scheduler Lookup (r:0 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) /// The range of component `s` is `[1, 512]`. fn cancel(s: u32, ) -> Weight { - // Minimum execution time: 21_686 nanoseconds. - Weight::from_ref_time(25_696_496 as u64) - // Standard Error: 1_261 - .saturating_add(Weight::from_ref_time(362_498 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `112 + s * (177 ±0)` + // Estimated: `109497` + // Minimum execution time: 15_594 nanoseconds. + Weight::from_parts(17_191_501, 109497) + // Standard Error: 626 + .saturating_add(Weight::from_ref_time(425_572).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[0, 511]`. fn schedule_named(s: u32, ) -> Weight { - // Minimum execution time: 23_084 nanoseconds. - Weight::from_ref_time(31_255_518 as u64) - // Standard Error: 1_258 - .saturating_add(Weight::from_ref_time(382_534 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `627 + s * (178 ±0)` + // Estimated: `112020` + // Minimum execution time: 15_127 nanoseconds. + Weight::from_parts(20_932_642, 112020) + // Standard Error: 692 + .saturating_add(Weight::from_ref_time(288_344).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) + /// Storage: Scheduler Lookup (r:1 w:1) + /// Proof: Scheduler Lookup (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Scheduler Agenda (r:1 w:1) + /// Proof: Scheduler Agenda (max_values: None, max_size: Some(107022), added: 109497, mode: MaxEncodedLen) /// The range of component `s` is `[1, 512]`. fn cancel_named(s: u32, ) -> Weight { - // Minimum execution time: 23_862 nanoseconds. - Weight::from_ref_time(28_591_336 as u64) - // Standard Error: 742 - .saturating_add(Weight::from_ref_time(369_305 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `740 + s * (177 ±0)` + // Estimated: `112020` + // Minimum execution time: 16_859 nanoseconds. + Weight::from_parts(19_736_937, 112020) + // Standard Error: 676 + .saturating_add(Weight::from_ref_time(429_770).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/session/src/weights.rs b/frame/session/src/weights.rs index d29413a33d..aea9d9dbf5 100644 --- a/frame/session/src/weights.rs +++ b/frame/session/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_session //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -54,44 +55,68 @@ pub trait WeightInfo { /// Weights for pallet_session using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Staking Ledger (r:1 w:0) - // Storage: Session NextKeys (r:1 w:1) - // Storage: Session KeyOwner (r:4 w:4) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:1) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: Session KeyOwner (r:4 w:4) + /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { - // Minimum execution time: 59_046 nanoseconds. - Weight::from_ref_time(59_934_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1955` + // Estimated: `19851` + // Minimum execution time: 40_867 nanoseconds. + Weight::from_parts(41_319_000, 19851) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Session NextKeys (r:1 w:1) - // Storage: Session KeyOwner (r:0 w:4) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:1) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: Session KeyOwner (r:0 w:4) + /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { - // Minimum execution time: 48_872 nanoseconds. - Weight::from_ref_time(49_666_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1854` + // Estimated: `9749` + // Minimum execution time: 30_286 nanoseconds. + Weight::from_parts(30_620_000, 9749) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Staking Ledger (r:1 w:0) - // Storage: Session NextKeys (r:1 w:1) - // Storage: Session KeyOwner (r:4 w:4) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:1) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: Session KeyOwner (r:4 w:4) + /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { - // Minimum execution time: 59_046 nanoseconds. - Weight::from_ref_time(59_934_000 as u64) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1955` + // Estimated: `19851` + // Minimum execution time: 40_867 nanoseconds. + Weight::from_parts(41_319_000, 19851) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Session NextKeys (r:1 w:1) - // Storage: Session KeyOwner (r:0 w:4) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Session NextKeys (r:1 w:1) + /// Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) + /// Storage: Session KeyOwner (r:0 w:4) + /// Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { - // Minimum execution time: 48_872 nanoseconds. - Weight::from_ref_time(49_666_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + // Proof Size summary in bytes: + // Measured: `1854` + // Estimated: `9749` + // Minimum execution time: 30_286 nanoseconds. + Weight::from_parts(30_620_000, 9749) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } } diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 9c283f5a06..af2afa2b53 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_staking // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_staking -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/staking/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -83,838 +83,1404 @@ pub trait WeightInfo { /// Weights for pallet_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn bond() -> Weight { - // Minimum execution time: 54_884 nanoseconds. - Weight::from_ref_time(55_487_000) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1079` + // Estimated: `10386` + // Minimum execution time: 40_015 nanoseconds. + Weight::from_parts(40_601_000, 10386) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra() -> Weight { - // Minimum execution time: 95_115 nanoseconds. - Weight::from_ref_time(96_213_000) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(7)) - } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListBags (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `2252` + // Estimated: `22888` + // Minimum execution time: 74_781 nanoseconds. + Weight::from_parts(75_188_000, 22888) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + } + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn unbond() -> Weight { - // Minimum execution time: 102_031 nanoseconds. - Weight::from_ref_time(102_842_000) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(8)) - } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `2457` + // Estimated: `29534` + // Minimum execution time: 81_299 nanoseconds. + Weight::from_parts(82_242_000, 29534) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + } + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - // Minimum execution time: 46_569 nanoseconds. - Weight::from_ref_time(48_034_493) - // Standard Error: 654 - .saturating_add(Weight::from_ref_time(63_628).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SpanSlash (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `1085` + // Estimated: `10442` + // Minimum execution time: 31_479 nanoseconds. + Weight::from_parts(32_410_035, 10442) + // Standard Error: 313 + .saturating_add(Weight::from_ref_time(9_090).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:1) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Staking SpanSlash (r:0 w:100) + /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { - // Minimum execution time: 90_154 nanoseconds. - Weight::from_ref_time(95_725_631) - // Standard Error: 2_491 - .saturating_add(Weight::from_ref_time(1_110_795).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(13)) - .saturating_add(T::DbWeight::get().writes(12)) + // Proof Size summary in bytes: + // Measured: `2486 + s * (4 ±0)` + // Estimated: `32303 + s * (4 ±0)` + // Minimum execution time: 71_968 nanoseconds. + Weight::from_parts(76_631_804, 32303) + // Standard Error: 1_613 + .saturating_add(Weight::from_ref_time(1_058_968).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(4).saturating_mul(s.into())) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking MinCommission (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinValidatorBond (r:1 w:0) + /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking MinCommission (r:1 w:0) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:1) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking MaxValidatorsCount (r:1 w:0) + /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForValidators (r:1 w:1) + /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn validate() -> Weight { - // Minimum execution time: 67_978 nanoseconds. - Weight::from_ref_time(69_153_000) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `1446` + // Estimated: `19359` + // Minimum execution time: 51_963 nanoseconds. + Weight::from_parts(52_418_000, 19359) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:128 w:128) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - // Minimum execution time: 45_328 nanoseconds. - Weight::from_ref_time(47_719_103) - // Standard Error: 14_458 - .saturating_add(Weight::from_ref_time(6_999_252).saturating_mul(k.into())) - .saturating_add(T::DbWeight::get().reads(1)) + // Proof Size summary in bytes: + // Measured: `1292 + k * (601 ±0)` + // Estimated: `3566 + k * (3033 ±0)` + // Minimum execution time: 25_685 nanoseconds. + Weight::from_parts(25_290_286, 3566) + // Standard Error: 5_164 + .saturating_add(Weight::from_ref_time(6_445_608).saturating_mul(k.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) + .saturating_add(Weight::from_proof_size(3033).saturating_mul(k.into())) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:1 w:0) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:17 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - // Minimum execution time: 74_650 nanoseconds. - Weight::from_ref_time(74_350_075) - // Standard Error: 10_527 - .saturating_add(Weight::from_ref_time(2_878_737).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(12)) + // Proof Size summary in bytes: + // Measured: `1984 + n * (105 ±0)` + // Estimated: `21988 + n * (2520 ±0)` + // Minimum execution time: 59_542 nanoseconds. + Weight::from_parts(57_558_678, 21988) + // Standard Error: 10_364 + .saturating_add(Weight::from_ref_time(2_759_713).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(6)) - } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) + .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(Weight::from_proof_size(2520).saturating_mul(n.into())) + } + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { - // Minimum execution time: 67_790 nanoseconds. - Weight::from_ref_time(68_738_000) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `1876` + // Estimated: `17932` + // Minimum execution time: 52_132 nanoseconds. + Weight::from_parts(52_648_000, 17932) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn set_payee() -> Weight { - // Minimum execution time: 19_237 nanoseconds. - Weight::from_ref_time(19_534_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `840` + // Estimated: `3566` + // Minimum execution time: 13_399 nanoseconds. + Weight::from_parts(13_567_000, 3566) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:2 w:2) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:2 w:2) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_controller() -> Weight { - // Minimum execution time: 27_288 nanoseconds. - Weight::from_ref_time(27_667_000) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `939` + // Estimated: `9679` + // Minimum execution time: 20_425 nanoseconds. + Weight::from_parts(20_713_000, 9679) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Staking ValidatorCount (r:0 w:1) + /// Storage: Staking ValidatorCount (r:0 w:1) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_validator_count() -> Weight { - // Minimum execution time: 5_155 nanoseconds. - Weight::from_ref_time(5_464_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_069 nanoseconds. + Weight::from_ref_time(3_176_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Staking ForceEra (r:0 w:1) + /// Storage: Staking ForceEra (r:0 w:1) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn force_no_eras() -> Weight { - // Minimum execution time: 5_405 nanoseconds. - Weight::from_ref_time(5_670_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_386 nanoseconds. + Weight::from_ref_time(11_672_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Staking ForceEra (r:0 w:1) + /// Storage: Staking ForceEra (r:0 w:1) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn force_new_era() -> Weight { - // Minimum execution time: 5_459 nanoseconds. - Weight::from_ref_time(5_616_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_591 nanoseconds. + Weight::from_ref_time(11_799_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Staking ForceEra (r:0 w:1) + /// Storage: Staking ForceEra (r:0 w:1) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn force_new_era_always() -> Weight { - // Minimum execution time: 5_476 nanoseconds. - Weight::from_ref_time(5_692_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_553 nanoseconds. + Weight::from_ref_time(11_871_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Staking Invulnerables (r:0 w:1) + /// Storage: Staking Invulnerables (r:0 w:1) + /// Proof Skipped: Staking Invulnerables (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - // Minimum execution time: 5_544 nanoseconds. - Weight::from_ref_time(6_513_190) - // Standard Error: 76 - .saturating_add(Weight::from_ref_time(9_975).saturating_mul(v.into())) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SpanSlash (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_292 nanoseconds. + Weight::from_ref_time(3_754_352) + // Standard Error: 40 + .saturating_add(Weight::from_ref_time(9_838).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:1) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:0 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Staking SpanSlash (r:0 w:100) + /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - // Minimum execution time: 82_414 nanoseconds. - Weight::from_ref_time(88_511_246) - // Standard Error: 2_622 - .saturating_add(Weight::from_ref_time(1_131_814).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(12)) + // Proof Size summary in bytes: + // Measured: `2178 + s * (4 ±0)` + // Estimated: `27930 + s * (4 ±0)` + // Minimum execution time: 65_307 nanoseconds. + Weight::from_parts(70_227_980, 27930) + // Standard Error: 2_113 + .saturating_add(Weight::from_ref_time(1_059_856).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(4).saturating_mul(s.into())) } - // Storage: Staking UnappliedSlashes (r:1 w:1) + /// Storage: Staking UnappliedSlashes (r:1 w:1) + /// Proof Skipped: Staking UnappliedSlashes (max_values: None, max_size: None, mode: Measured) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - // Minimum execution time: 94_197 nanoseconds. - Weight::from_ref_time(903_418_326) - // Standard Error: 59_354 - .saturating_add(Weight::from_ref_time(4_948_354).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `66671` + // Estimated: `69146` + // Minimum execution time: 89_123 nanoseconds. + Weight::from_parts(890_989_741, 69146) + // Standard Error: 58_282 + .saturating_add(Weight::from_ref_time(4_920_413).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasValidatorReward (r:1 w:0) + /// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:257 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking ErasStakersClipped (r:1 w:0) + /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasRewardPoints (r:1 w:0) + /// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasValidatorPrefs (r:1 w:0) + /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:257 w:0) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: System Account (r:257 w:257) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - // Minimum execution time: 133_065 nanoseconds. - Weight::from_ref_time(197_555_906) - // Standard Error: 19_561 - .saturating_add(Weight::from_ref_time(22_683_426).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(9)) + // Proof Size summary in bytes: + // Measured: `20345 + n * (143 ±0)` + // Estimated: `54756 + n * (8024 ±1)` + // Minimum execution time: 73_652 nanoseconds. + Weight::from_parts(127_839_483, 54756) + // Standard Error: 14_195 + .saturating_add(Weight::from_ref_time(21_932_079).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes(2_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(8024).saturating_mul(n.into())) } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasValidatorReward (r:1 w:0) + /// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:257 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:257 w:257) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking ErasStakersClipped (r:1 w:0) + /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasRewardPoints (r:1 w:0) + /// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasValidatorPrefs (r:1 w:0) + /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:257 w:0) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: System Account (r:257 w:257) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:257 w:257) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - // Minimum execution time: 164_719 nanoseconds. - Weight::from_ref_time(226_304_276) - // Standard Error: 31_675 - .saturating_add(Weight::from_ref_time(32_622_427).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(10)) + // Proof Size summary in bytes: + // Measured: `35099 + n * (465 ±0)` + // Estimated: `83594 + n * (16026 ±0)` + // Minimum execution time: 94_560 nanoseconds. + Weight::from_parts(154_033_219, 83594) + // Standard Error: 26_663 + .saturating_add(Weight::from_ref_time(31_269_223).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(3_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(16026).saturating_mul(n.into())) } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - // Minimum execution time: 95_631 nanoseconds. - Weight::from_ref_time(96_861_556) - // Standard Error: 2_114 - .saturating_add(Weight::from_ref_time(37_543).saturating_mul(l.into())) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(8)) - } - // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SpanSlash (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `2253 + l * (7 ±0)` + // Estimated: `25491` + // Minimum execution time: 74_764 nanoseconds. + Weight::from_parts(75_814_067, 25491) + // Standard Error: 1_217 + .saturating_add(Weight::from_ref_time(64_725).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:1) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Staking SpanSlash (r:0 w:100) + /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - // Minimum execution time: 95_251 nanoseconds. - Weight::from_ref_time(97_818_954) - // Standard Error: 2_356 - .saturating_add(Weight::from_ref_time(1_104_695).saturating_mul(s.into())) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(12)) + // Proof Size summary in bytes: + // Measured: `2486 + s * (4 ±0)` + // Estimated: `31810 + s * (4 ±0)` + // Minimum execution time: 77_611 nanoseconds. + Weight::from_parts(79_760_034, 31810) + // Standard Error: 1_597 + .saturating_add(Weight::from_ref_time(1_039_268).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(12_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(4).saturating_mul(s.into())) } - // Storage: VoterList CounterForListNodes (r:1 w:0) - // Storage: VoterList ListBags (r:200 w:0) - // Storage: VoterList ListNodes (r:101 w:0) - // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking Ledger (r:101 w:0) - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:1) - // Storage: Staking ErasValidatorPrefs (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking MinimumActiveStake (r:0 w:1) + /// Storage: VoterList CounterForListNodes (r:1 w:0) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:200 w:0) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:110 w:0) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:110 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:11 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:110 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:110 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CounterForValidators (r:1 w:0) + /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ValidatorCount (r:1 w:0) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinimumValidatorCount (r:1 w:0) + /// Proof: Staking MinimumValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:1) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasStakersClipped (r:0 w:10) + /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasValidatorPrefs (r:0 w:10) + /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen) + /// Storage: Staking ErasStakers (r:0 w:10) + /// Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasTotalStake (r:0 w:1) + /// Proof: Staking ErasTotalStake (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Staking ErasStartSessionIndex (r:0 w:1) + /// Proof: Staking ErasStartSessionIndex (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: Staking MinimumActiveStake (r:0 w:1) + /// Proof: Staking MinimumActiveStake (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// The range of component `v` is `[1, 10]`. /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 512_923 nanoseconds. - Weight::from_ref_time(514_740_000) - // Standard Error: 1_790_238 - .saturating_add(Weight::from_ref_time(59_320_539).saturating_mul(v.into())) - // Standard Error: 178_387 - .saturating_add(Weight::from_ref_time(13_902_705).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(206)) + // Proof Size summary in bytes: + // Measured: `0 + v * (3662 ±0) + n * (816 ±0)` + // Estimated: `528203 + v * (16743 ±0) + n * (12947 ±0)` + // Minimum execution time: 489_824 nanoseconds. + Weight::from_parts(491_687_000, 528203) + // Standard Error: 1_787_577 + .saturating_add(Weight::from_ref_time(58_719_498).saturating_mul(v.into())) + // Standard Error: 178_122 + .saturating_add(Weight::from_ref_time(13_273_555).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(206_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes(4_u64)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into()))) + .saturating_add(Weight::from_proof_size(16743).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(12947).saturating_mul(n.into())) } - // Storage: VoterList CounterForListNodes (r:1 w:0) - // Storage: VoterList ListBags (r:200 w:0) - // Storage: VoterList ListNodes (r:1500 w:0) - // Storage: Staking Nominators (r:1500 w:0) - // Storage: Staking Validators (r:500 w:0) - // Storage: Staking Bonded (r:1500 w:0) - // Storage: Staking Ledger (r:1500 w:0) - // Storage: Staking MinimumActiveStake (r:0 w:1) + /// Storage: VoterList CounterForListNodes (r:1 w:0) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:200 w:0) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2000 w:0) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:2000 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1000 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:2000 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:2000 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinimumActiveStake (r:0 w:1) + /// Proof: Staking MinimumActiveStake (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// The range of component `v` is `[500, 1000]`. /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 24_913_316 nanoseconds. - Weight::from_ref_time(25_053_596_000) - // Standard Error: 324_610 - .saturating_add(Weight::from_ref_time(3_454_859).saturating_mul(v.into())) - // Standard Error: 324_610 - .saturating_add(Weight::from_ref_time(3_020_267).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(201)) + // Proof Size summary in bytes: + // Measured: `3167 + v * (459 ±0) + n * (1007 ±0)` + // Estimated: `511899 + v * (14295 ±0) + n * (11775 ±0)` + // Minimum execution time: 23_373_467 nanoseconds. + Weight::from_parts(23_497_257_000, 511899) + // Standard Error: 299_205 + .saturating_add(Weight::from_ref_time(3_434_000).saturating_mul(v.into())) + // Standard Error: 299_205 + .saturating_add(Weight::from_ref_time(2_568_954).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(201_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(14295).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(11775).saturating_mul(n.into())) } - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking Validators (r:501 w:0) + /// Storage: Staking CounterForValidators (r:1 w:0) + /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1001 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - // Minimum execution time: 4_916_401 nanoseconds. - Weight::from_ref_time(81_160_966) - // Standard Error: 23_829 - .saturating_add(Weight::from_ref_time(9_883_413).saturating_mul(v.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Proof Size summary in bytes: + // Measured: `983 + v * (50 ±0)` + // Estimated: `3019 + v * (2520 ±0)` + // Minimum execution time: 3_882_120 nanoseconds. + Weight::from_parts(3_951_993_000, 3019) + // Standard Error: 46_729 + .saturating_add(Weight::from_ref_time(2_856_043).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) + .saturating_add(Weight::from_proof_size(2520).saturating_mul(v.into())) } - // Storage: Staking MinCommission (r:0 w:1) - // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) + /// Storage: Staking MinCommission (r:0 w:1) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinValidatorBond (r:0 w:1) + /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking MaxValidatorsCount (r:0 w:1) + /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ChillThreshold (r:0 w:1) + /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:0 w:1) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:0 w:1) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) fn set_staking_configs_all_set() -> Weight { - // Minimum execution time: 10_937 nanoseconds. - Weight::from_ref_time(11_324_000) - .saturating_add(T::DbWeight::get().writes(6)) - } - // Storage: Staking MinCommission (r:0 w:1) - // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_427 nanoseconds. + Weight::from_ref_time(8_794_000) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Staking MinCommission (r:0 w:1) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinValidatorBond (r:0 w:1) + /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking MaxValidatorsCount (r:0 w:1) + /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ChillThreshold (r:0 w:1) + /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:0 w:1) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:0 w:1) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) fn set_staking_configs_all_remove() -> Weight { - // Minimum execution time: 9_424 nanoseconds. - Weight::from_ref_time(10_021_000) - .saturating_add(T::DbWeight::get().writes(6)) - } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_620 nanoseconds. + Weight::from_ref_time(7_901_000) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking ChillThreshold (r:1 w:0) + /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:1 w:0) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill_other() -> Weight { - // Minimum execution time: 84_495 nanoseconds. - Weight::from_ref_time(85_559_000) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `2031` + // Estimated: `19438` + // Minimum execution time: 66_188 nanoseconds. + Weight::from_parts(66_767_000, 19438) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - // Storage: Staking MinCommission (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) + /// Storage: Staking MinCommission (r:1 w:0) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:1) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) fn force_apply_min_commission() -> Weight { - // Minimum execution time: 20_385 nanoseconds. - Weight::from_ref_time(20_824_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `694` + // Estimated: `3019` + // Minimum execution time: 14_703 nanoseconds. + Weight::from_parts(15_031_000, 3019) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Staking MinCommission (r:0 w:1) + /// Storage: Staking MinCommission (r:0 w:1) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_min_commission() -> Weight { - // Minimum execution time: 6_995 nanoseconds. - Weight::from_ref_time(7_213_000) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_518 nanoseconds. + Weight::from_ref_time(4_656_000) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn bond() -> Weight { - // Minimum execution time: 54_884 nanoseconds. - Weight::from_ref_time(55_487_000) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: VoterList ListBags (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `1079` + // Estimated: `10386` + // Minimum execution time: 40_015 nanoseconds. + Weight::from_parts(40_601_000, 10386) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn bond_extra() -> Weight { - // Minimum execution time: 95_115 nanoseconds. - Weight::from_ref_time(96_213_000) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(7)) - } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListBags (r:2 w:2) + // Proof Size summary in bytes: + // Measured: `2252` + // Estimated: `22888` + // Minimum execution time: 74_781 nanoseconds. + Weight::from_parts(75_188_000, 22888) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) fn unbond() -> Weight { - // Minimum execution time: 102_031 nanoseconds. - Weight::from_ref_time(102_842_000) - .saturating_add(RocksDbWeight::get().reads(12)) - .saturating_add(RocksDbWeight::get().writes(8)) - } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `2457` + // Estimated: `29534` + // Minimum execution time: 81_299 nanoseconds. + Weight::from_parts(82_242_000, 29534) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + } + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - // Minimum execution time: 46_569 nanoseconds. - Weight::from_ref_time(48_034_493) - // Standard Error: 654 - .saturating_add(Weight::from_ref_time(63_628).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SpanSlash (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `1085` + // Estimated: `10442` + // Minimum execution time: 31_479 nanoseconds. + Weight::from_parts(32_410_035, 10442) + // Standard Error: 313 + .saturating_add(Weight::from_ref_time(9_090).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:1) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Staking SpanSlash (r:0 w:100) + /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { - // Minimum execution time: 90_154 nanoseconds. - Weight::from_ref_time(95_725_631) - // Standard Error: 2_491 - .saturating_add(Weight::from_ref_time(1_110_795).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(13)) - .saturating_add(RocksDbWeight::get().writes(12)) + // Proof Size summary in bytes: + // Measured: `2486 + s * (4 ±0)` + // Estimated: `32303 + s * (4 ±0)` + // Minimum execution time: 71_968 nanoseconds. + Weight::from_parts(76_631_804, 32303) + // Standard Error: 1_613 + .saturating_add(Weight::from_ref_time(1_058_968).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(4).saturating_mul(s.into())) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MinValidatorBond (r:1 w:0) - // Storage: Staking MinCommission (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) - // Storage: Staking MaxValidatorsCount (r:1 w:0) - // Storage: Staking Nominators (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListNodes (r:1 w:1) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CounterForValidators (r:1 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinValidatorBond (r:1 w:0) + /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking MinCommission (r:1 w:0) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:1) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking MaxValidatorsCount (r:1 w:0) + /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:1 w:1) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForValidators (r:1 w:1) + /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn validate() -> Weight { - // Minimum execution time: 67_978 nanoseconds. - Weight::from_ref_time(69_153_000) - .saturating_add(RocksDbWeight::get().reads(11)) - .saturating_add(RocksDbWeight::get().writes(5)) + // Proof Size summary in bytes: + // Measured: `1446` + // Estimated: `19359` + // Minimum execution time: 51_963 nanoseconds. + Weight::from_parts(52_418_000, 19359) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:128 w:128) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - // Minimum execution time: 45_328 nanoseconds. - Weight::from_ref_time(47_719_103) - // Standard Error: 14_458 - .saturating_add(Weight::from_ref_time(6_999_252).saturating_mul(k.into())) - .saturating_add(RocksDbWeight::get().reads(1)) + // Proof Size summary in bytes: + // Measured: `1292 + k * (601 ±0)` + // Estimated: `3566 + k * (3033 ±0)` + // Minimum execution time: 25_685 nanoseconds. + Weight::from_parts(25_290_286, 3566) + // Standard Error: 5_164 + .saturating_add(Weight::from_ref_time(6_445_608).saturating_mul(k.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) + .saturating_add(Weight::from_proof_size(3033).saturating_mul(k.into())) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:1 w:0) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:17 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - // Minimum execution time: 74_650 nanoseconds. - Weight::from_ref_time(74_350_075) - // Standard Error: 10_527 - .saturating_add(Weight::from_ref_time(2_878_737).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(12)) + // Proof Size summary in bytes: + // Measured: `1984 + n * (105 ±0)` + // Estimated: `21988 + n * (2520 ±0)` + // Minimum execution time: 59_542 nanoseconds. + Weight::from_parts(57_558_678, 21988) + // Standard Error: 10_364 + .saturating_add(Weight::from_ref_time(2_759_713).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(6)) - } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(Weight::from_proof_size(2520).saturating_mul(n.into())) + } + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill() -> Weight { - // Minimum execution time: 67_790 nanoseconds. - Weight::from_ref_time(68_738_000) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `1876` + // Estimated: `17932` + // Minimum execution time: 52_132 nanoseconds. + Weight::from_parts(52_648_000, 17932) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Payee (r:0 w:1) + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) fn set_payee() -> Weight { - // Minimum execution time: 19_237 nanoseconds. - Weight::from_ref_time(19_534_000) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `840` + // Estimated: `3566` + // Minimum execution time: 13_399 nanoseconds. + Weight::from_parts(13_567_000, 3566) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:2 w:2) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:2 w:2) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) fn set_controller() -> Weight { - // Minimum execution time: 27_288 nanoseconds. - Weight::from_ref_time(27_667_000) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `939` + // Estimated: `9679` + // Minimum execution time: 20_425 nanoseconds. + Weight::from_parts(20_713_000, 9679) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Staking ValidatorCount (r:0 w:1) + /// Storage: Staking ValidatorCount (r:0 w:1) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_validator_count() -> Weight { - // Minimum execution time: 5_155 nanoseconds. - Weight::from_ref_time(5_464_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_069 nanoseconds. + Weight::from_ref_time(3_176_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Staking ForceEra (r:0 w:1) + /// Storage: Staking ForceEra (r:0 w:1) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn force_no_eras() -> Weight { - // Minimum execution time: 5_405 nanoseconds. - Weight::from_ref_time(5_670_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_386 nanoseconds. + Weight::from_ref_time(11_672_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Staking ForceEra (r:0 w:1) + /// Storage: Staking ForceEra (r:0 w:1) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn force_new_era() -> Weight { - // Minimum execution time: 5_459 nanoseconds. - Weight::from_ref_time(5_616_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_591 nanoseconds. + Weight::from_ref_time(11_799_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Staking ForceEra (r:0 w:1) + /// Storage: Staking ForceEra (r:0 w:1) + /// Proof: Staking ForceEra (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) fn force_new_era_always() -> Weight { - // Minimum execution time: 5_476 nanoseconds. - Weight::from_ref_time(5_692_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 11_553 nanoseconds. + Weight::from_ref_time(11_871_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Staking Invulnerables (r:0 w:1) + /// Storage: Staking Invulnerables (r:0 w:1) + /// Proof Skipped: Staking Invulnerables (max_values: Some(1), max_size: None, mode: Measured) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - // Minimum execution time: 5_544 nanoseconds. - Weight::from_ref_time(6_513_190) - // Standard Error: 76 - .saturating_add(Weight::from_ref_time(9_975).saturating_mul(v.into())) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Ledger (r:0 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SpanSlash (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_292 nanoseconds. + Weight::from_ref_time(3_754_352) + // Standard Error: 40 + .saturating_add(Weight::from_ref_time(9_838).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:1) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:0 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Staking SpanSlash (r:0 w:100) + /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - // Minimum execution time: 82_414 nanoseconds. - Weight::from_ref_time(88_511_246) - // Standard Error: 2_622 - .saturating_add(Weight::from_ref_time(1_131_814).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(11)) - .saturating_add(RocksDbWeight::get().writes(12)) + // Proof Size summary in bytes: + // Measured: `2178 + s * (4 ±0)` + // Estimated: `27930 + s * (4 ±0)` + // Minimum execution time: 65_307 nanoseconds. + Weight::from_parts(70_227_980, 27930) + // Standard Error: 2_113 + .saturating_add(Weight::from_ref_time(1_059_856).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(4).saturating_mul(s.into())) } - // Storage: Staking UnappliedSlashes (r:1 w:1) + /// Storage: Staking UnappliedSlashes (r:1 w:1) + /// Proof Skipped: Staking UnappliedSlashes (max_values: None, max_size: None, mode: Measured) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - // Minimum execution time: 94_197 nanoseconds. - Weight::from_ref_time(903_418_326) - // Standard Error: 59_354 - .saturating_add(Weight::from_ref_time(4_948_354).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `66671` + // Estimated: `69146` + // Minimum execution time: 89_123 nanoseconds. + Weight::from_parts(890_989_741, 69146) + // Standard Error: 58_282 + .saturating_add(Weight::from_ref_time(4_920_413).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasValidatorReward (r:1 w:0) + /// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:257 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking ErasStakersClipped (r:1 w:0) + /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasRewardPoints (r:1 w:0) + /// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasValidatorPrefs (r:1 w:0) + /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:257 w:0) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: System Account (r:257 w:257) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - // Minimum execution time: 133_065 nanoseconds. - Weight::from_ref_time(197_555_906) - // Standard Error: 19_561 - .saturating_add(Weight::from_ref_time(22_683_426).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(9)) + // Proof Size summary in bytes: + // Measured: `20345 + n * (143 ±0)` + // Estimated: `54756 + n * (8024 ±1)` + // Minimum execution time: 73_652 nanoseconds. + Weight::from_parts(127_839_483, 54756) + // Standard Error: 14_195 + .saturating_add(Weight::from_ref_time(21_932_079).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(8024).saturating_mul(n.into())) } - // Storage: Staking CurrentEra (r:1 w:0) - // Storage: Staking ErasValidatorReward (r:1 w:0) - // Storage: Staking Bonded (r:1 w:0) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:1 w:0) - // Storage: Staking ErasRewardPoints (r:1 w:0) - // Storage: Staking ErasValidatorPrefs (r:1 w:0) - // Storage: Staking Payee (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Staking CurrentEra (r:1 w:0) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasValidatorReward (r:1 w:0) + /// Proof: Staking ErasValidatorReward (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:257 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:257 w:257) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking ErasStakersClipped (r:1 w:0) + /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasRewardPoints (r:1 w:0) + /// Proof Skipped: Staking ErasRewardPoints (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasValidatorPrefs (r:1 w:0) + /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:257 w:0) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: System Account (r:257 w:257) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:257 w:257) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - // Minimum execution time: 164_719 nanoseconds. - Weight::from_ref_time(226_304_276) - // Standard Error: 31_675 - .saturating_add(Weight::from_ref_time(32_622_427).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(10)) + // Proof Size summary in bytes: + // Measured: `35099 + n * (465 ±0)` + // Estimated: `83594 + n * (16026 ±0)` + // Minimum execution time: 94_560 nanoseconds. + Weight::from_parts(154_033_219, 83594) + // Standard Error: 26_663 + .saturating_add(Weight::from_ref_time(31_269_223).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(n.into()))) + .saturating_add(Weight::from_proof_size(16026).saturating_mul(n.into())) } - // Storage: Staking Ledger (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: VoterList ListNodes (r:3 w:3) - // Storage: Staking Bonded (r:1 w:0) - // Storage: VoterList ListBags (r:2 w:2) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:3 w:3) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:2 w:2) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - // Minimum execution time: 95_631 nanoseconds. - Weight::from_ref_time(96_861_556) - // Standard Error: 2_114 - .saturating_add(Weight::from_ref_time(37_543).saturating_mul(l.into())) - .saturating_add(RocksDbWeight::get().reads(9)) - .saturating_add(RocksDbWeight::get().writes(8)) - } - // Storage: System Account (r:1 w:1) - // Storage: Staking Bonded (r:1 w:1) - // Storage: Staking Ledger (r:1 w:1) - // Storage: Staking SlashingSpans (r:1 w:1) - // Storage: Staking Validators (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: Staking Payee (r:0 w:1) - // Storage: Staking SpanSlash (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `2253 + l * (7 ±0)` + // Estimated: `25491` + // Minimum execution time: 74_764 nanoseconds. + Weight::from_parts(75_814_067, 25491) + // Standard Error: 1_217 + .saturating_add(Weight::from_ref_time(64_725).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:1 w:1) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:1 w:1) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking SlashingSpans (r:1 w:1) + /// Proof Skipped: Staking SlashingSpans (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: Staking Payee (r:0 w:1) + /// Proof: Staking Payee (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen) + /// Storage: Staking SpanSlash (r:0 w:100) + /// Proof: Staking SpanSlash (max_values: None, max_size: Some(76), added: 2551, mode: MaxEncodedLen) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - // Minimum execution time: 95_251 nanoseconds. - Weight::from_ref_time(97_818_954) - // Standard Error: 2_356 - .saturating_add(Weight::from_ref_time(1_104_695).saturating_mul(s.into())) - .saturating_add(RocksDbWeight::get().reads(12)) - .saturating_add(RocksDbWeight::get().writes(12)) + // Proof Size summary in bytes: + // Measured: `2486 + s * (4 ±0)` + // Estimated: `31810 + s * (4 ±0)` + // Minimum execution time: 77_611 nanoseconds. + Weight::from_parts(79_760_034, 31810) + // Standard Error: 1_597 + .saturating_add(Weight::from_ref_time(1_039_268).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(12_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) + .saturating_add(Weight::from_proof_size(4).saturating_mul(s.into())) } - // Storage: VoterList CounterForListNodes (r:1 w:0) - // Storage: VoterList ListBags (r:200 w:0) - // Storage: VoterList ListNodes (r:101 w:0) - // Storage: Staking Nominators (r:101 w:0) - // Storage: Staking Validators (r:2 w:0) - // Storage: Staking Bonded (r:101 w:0) - // Storage: Staking Ledger (r:101 w:0) - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking ValidatorCount (r:1 w:0) - // Storage: Staking MinimumValidatorCount (r:1 w:0) - // Storage: Staking CurrentEra (r:1 w:1) - // Storage: Staking ErasStakersClipped (r:0 w:1) - // Storage: Staking ErasValidatorPrefs (r:0 w:1) - // Storage: Staking ErasStakers (r:0 w:1) - // Storage: Staking ErasTotalStake (r:0 w:1) - // Storage: Staking ErasStartSessionIndex (r:0 w:1) - // Storage: Staking MinimumActiveStake (r:0 w:1) + /// Storage: VoterList CounterForListNodes (r:1 w:0) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:200 w:0) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:110 w:0) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:110 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:11 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:110 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:110 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking CounterForValidators (r:1 w:0) + /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ValidatorCount (r:1 w:0) + /// Proof: Staking ValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinimumValidatorCount (r:1 w:0) + /// Proof: Staking MinimumValidatorCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CurrentEra (r:1 w:1) + /// Proof: Staking CurrentEra (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ErasStakersClipped (r:0 w:10) + /// Proof Skipped: Staking ErasStakersClipped (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasValidatorPrefs (r:0 w:10) + /// Proof: Staking ErasValidatorPrefs (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen) + /// Storage: Staking ErasStakers (r:0 w:10) + /// Proof Skipped: Staking ErasStakers (max_values: None, max_size: None, mode: Measured) + /// Storage: Staking ErasTotalStake (r:0 w:1) + /// Proof: Staking ErasTotalStake (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + /// Storage: Staking ErasStartSessionIndex (r:0 w:1) + /// Proof: Staking ErasStartSessionIndex (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen) + /// Storage: Staking MinimumActiveStake (r:0 w:1) + /// Proof: Staking MinimumActiveStake (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// The range of component `v` is `[1, 10]`. /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 512_923 nanoseconds. - Weight::from_ref_time(514_740_000) - // Standard Error: 1_790_238 - .saturating_add(Weight::from_ref_time(59_320_539).saturating_mul(v.into())) - // Standard Error: 178_387 - .saturating_add(Weight::from_ref_time(13_902_705).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(206)) + // Proof Size summary in bytes: + // Measured: `0 + v * (3662 ±0) + n * (816 ±0)` + // Estimated: `528203 + v * (16743 ±0) + n * (12947 ±0)` + // Minimum execution time: 489_824 nanoseconds. + Weight::from_parts(491_687_000, 528203) + // Standard Error: 1_787_577 + .saturating_add(Weight::from_ref_time(58_719_498).saturating_mul(v.into())) + // Standard Error: 178_122 + .saturating_add(Weight::from_ref_time(13_273_555).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(206_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(v.into()))) + .saturating_add(Weight::from_proof_size(16743).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(12947).saturating_mul(n.into())) } - // Storage: VoterList CounterForListNodes (r:1 w:0) - // Storage: VoterList ListBags (r:200 w:0) - // Storage: VoterList ListNodes (r:1500 w:0) - // Storage: Staking Nominators (r:1500 w:0) - // Storage: Staking Validators (r:500 w:0) - // Storage: Staking Bonded (r:1500 w:0) - // Storage: Staking Ledger (r:1500 w:0) - // Storage: Staking MinimumActiveStake (r:0 w:1) + /// Storage: VoterList CounterForListNodes (r:1 w:0) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:200 w:0) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2000 w:0) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:2000 w:0) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1000 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: Staking Bonded (r:2000 w:0) + /// Proof: Staking Bonded (max_values: None, max_size: Some(72), added: 2547, mode: MaxEncodedLen) + /// Storage: Staking Ledger (r:2000 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking MinimumActiveStake (r:0 w:1) + /// Proof: Staking MinimumActiveStake (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// The range of component `v` is `[500, 1000]`. /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 24_913_316 nanoseconds. - Weight::from_ref_time(25_053_596_000) - // Standard Error: 324_610 - .saturating_add(Weight::from_ref_time(3_454_859).saturating_mul(v.into())) - // Standard Error: 324_610 - .saturating_add(Weight::from_ref_time(3_020_267).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(201)) + // Proof Size summary in bytes: + // Measured: `3167 + v * (459 ±0) + n * (1007 ±0)` + // Estimated: `511899 + v * (14295 ±0) + n * (11775 ±0)` + // Minimum execution time: 23_373_467 nanoseconds. + Weight::from_parts(23_497_257_000, 511899) + // Standard Error: 299_205 + .saturating_add(Weight::from_ref_time(3_434_000).saturating_mul(v.into())) + // Standard Error: 299_205 + .saturating_add(Weight::from_ref_time(2_568_954).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(201_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(1)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(14295).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(11775).saturating_mul(n.into())) } - // Storage: Staking CounterForValidators (r:1 w:0) - // Storage: Staking Validators (r:501 w:0) + /// Storage: Staking CounterForValidators (r:1 w:0) + /// Proof: Staking CounterForValidators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1001 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - // Minimum execution time: 4_916_401 nanoseconds. - Weight::from_ref_time(81_160_966) - // Standard Error: 23_829 - .saturating_add(Weight::from_ref_time(9_883_413).saturating_mul(v.into())) - .saturating_add(RocksDbWeight::get().reads(2)) + // Proof Size summary in bytes: + // Measured: `983 + v * (50 ±0)` + // Estimated: `3019 + v * (2520 ±0)` + // Minimum execution time: 3_882_120 nanoseconds. + Weight::from_parts(3_951_993_000, 3019) + // Standard Error: 46_729 + .saturating_add(Weight::from_ref_time(2_856_043).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) + .saturating_add(Weight::from_proof_size(2520).saturating_mul(v.into())) } - // Storage: Staking MinCommission (r:0 w:1) - // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) + /// Storage: Staking MinCommission (r:0 w:1) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinValidatorBond (r:0 w:1) + /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking MaxValidatorsCount (r:0 w:1) + /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ChillThreshold (r:0 w:1) + /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:0 w:1) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:0 w:1) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) fn set_staking_configs_all_set() -> Weight { - // Minimum execution time: 10_937 nanoseconds. - Weight::from_ref_time(11_324_000) - .saturating_add(RocksDbWeight::get().writes(6)) - } - // Storage: Staking MinCommission (r:0 w:1) - // Storage: Staking MinValidatorBond (r:0 w:1) - // Storage: Staking MaxValidatorsCount (r:0 w:1) - // Storage: Staking ChillThreshold (r:0 w:1) - // Storage: Staking MaxNominatorsCount (r:0 w:1) - // Storage: Staking MinNominatorBond (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_427 nanoseconds. + Weight::from_ref_time(8_794_000) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Staking MinCommission (r:0 w:1) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinValidatorBond (r:0 w:1) + /// Proof: Staking MinValidatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking MaxValidatorsCount (r:0 w:1) + /// Proof: Staking MaxValidatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking ChillThreshold (r:0 w:1) + /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:0 w:1) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:0 w:1) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) fn set_staking_configs_all_remove() -> Weight { - // Minimum execution time: 9_424 nanoseconds. - Weight::from_ref_time(10_021_000) - .saturating_add(RocksDbWeight::get().writes(6)) - } - // Storage: Staking Ledger (r:1 w:0) - // Storage: Staking Nominators (r:1 w:1) - // Storage: Staking ChillThreshold (r:1 w:0) - // Storage: Staking MaxNominatorsCount (r:1 w:0) - // Storage: Staking CounterForNominators (r:1 w:1) - // Storage: Staking MinNominatorBond (r:1 w:0) - // Storage: Staking Validators (r:1 w:0) - // Storage: VoterList ListNodes (r:2 w:2) - // Storage: VoterList ListBags (r:1 w:1) - // Storage: VoterList CounterForListNodes (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_620 nanoseconds. + Weight::from_ref_time(7_901_000) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: Staking Ledger (r:1 w:0) + /// Proof: Staking Ledger (max_values: None, max_size: Some(1091), added: 3566, mode: MaxEncodedLen) + /// Storage: Staking Nominators (r:1 w:1) + /// Proof: Staking Nominators (max_values: None, max_size: Some(558), added: 3033, mode: MaxEncodedLen) + /// Storage: Staking ChillThreshold (r:1 w:0) + /// Proof: Staking ChillThreshold (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: Staking MaxNominatorsCount (r:1 w:0) + /// Proof: Staking MaxNominatorsCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking CounterForNominators (r:1 w:1) + /// Proof: Staking CounterForNominators (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking MinNominatorBond (r:1 w:0) + /// Proof: Staking MinNominatorBond (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:0) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) + /// Storage: VoterList ListNodes (r:2 w:2) + /// Proof: VoterList ListNodes (max_values: None, max_size: Some(154), added: 2629, mode: MaxEncodedLen) + /// Storage: VoterList ListBags (r:1 w:1) + /// Proof: VoterList ListBags (max_values: None, max_size: Some(82), added: 2557, mode: MaxEncodedLen) + /// Storage: VoterList CounterForListNodes (r:1 w:1) + /// Proof: VoterList CounterForListNodes (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn chill_other() -> Weight { - // Minimum execution time: 84_495 nanoseconds. - Weight::from_ref_time(85_559_000) - .saturating_add(RocksDbWeight::get().reads(11)) - .saturating_add(RocksDbWeight::get().writes(6)) + // Proof Size summary in bytes: + // Measured: `2031` + // Estimated: `19438` + // Minimum execution time: 66_188 nanoseconds. + Weight::from_parts(66_767_000, 19438) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } - // Storage: Staking MinCommission (r:1 w:0) - // Storage: Staking Validators (r:1 w:1) + /// Storage: Staking MinCommission (r:1 w:0) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Staking Validators (r:1 w:1) + /// Proof: Staking Validators (max_values: None, max_size: Some(45), added: 2520, mode: MaxEncodedLen) fn force_apply_min_commission() -> Weight { - // Minimum execution time: 20_385 nanoseconds. - Weight::from_ref_time(20_824_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `694` + // Estimated: `3019` + // Minimum execution time: 14_703 nanoseconds. + Weight::from_parts(15_031_000, 3019) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Staking MinCommission (r:0 w:1) + /// Storage: Staking MinCommission (r:0 w:1) + /// Proof: Staking MinCommission (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_min_commission() -> Weight { - // Minimum execution time: 6_995 nanoseconds. - Weight::from_ref_time(7_213_000) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_518 nanoseconds. + Weight::from_ref_time(4_656_000) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/state-trie-migration/src/weights.rs b/frame/state-trie-migration/src/weights.rs index 7414bb9038..29b7f7ad47 100644 --- a/frame/state-trie-migration/src/weights.rs +++ b/frame/state-trie-migration/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_state_trie_migration //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -59,100 +60,156 @@ pub trait WeightInfo { /// Weights for pallet_state_trie_migration using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) - // Storage: StateTrieMigration MigrationProcess (r:1 w:1) + /// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) + /// Proof: StateTrieMigration SignedMigrationMaxLimits (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: StateTrieMigration MigrationProcess (r:1 w:1) + /// Proof: StateTrieMigration MigrationProcess (max_values: Some(1), max_size: Some(1042), added: 1537, mode: MaxEncodedLen) fn continue_migrate() -> Weight { - // Minimum execution time: 23_874 nanoseconds. - Weight::from_ref_time(24_127_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `108` + // Estimated: `2040` + // Minimum execution time: 15_563 nanoseconds. + Weight::from_parts(15_783_000, 2040) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) + /// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) + /// Proof: StateTrieMigration SignedMigrationMaxLimits (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn continue_migrate_wrong_witness() -> Weight { - // Minimum execution time: 6_119 nanoseconds. - Weight::from_ref_time(6_325_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `503` + // Minimum execution time: 4_347 nanoseconds. + Weight::from_parts(4_558_000, 503) + .saturating_add(T::DbWeight::get().reads(1_u64)) } fn migrate_custom_top_success() -> Weight { - // Minimum execution time: 20_365 nanoseconds. - Weight::from_ref_time(20_790_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_817 nanoseconds. + Weight::from_ref_time(9_027_000) } - // Storage: unknown [0x666f6f] (r:1 w:1) + /// Storage: unknown `0x666f6f` (r:1 w:1) + /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_top_fail() -> Weight { - // Minimum execution time: 38_979 nanoseconds. - Weight::from_ref_time(40_271_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2619` + // Minimum execution time: 23_854 nanoseconds. + Weight::from_parts(24_850_000, 2619) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn migrate_custom_child_success() -> Weight { - // Minimum execution time: 21_217 nanoseconds. - Weight::from_ref_time(21_526_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_020 nanoseconds. + Weight::from_ref_time(9_234_000) } - // Storage: unknown [0x666f6f] (r:1 w:1) + /// Storage: unknown `0x666f6f` (r:1 w:1) + /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_child_fail() -> Weight { - // Minimum execution time: 43_853 nanoseconds. - Weight::from_ref_time(44_693_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `2611` + // Minimum execution time: 24_136 nanoseconds. + Weight::from_parts(24_810_000, 2611) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: unknown [0x6b6579] (r:1 w:1) + /// Storage: unknown `0x6b6579` (r:1 w:1) + /// Proof Skipped: unknown `0x6b6579` (r:1 w:1) /// The range of component `v` is `[1, 4194304]`. fn process_top_key(v: u32, ) -> Weight { - // Minimum execution time: 5_575 nanoseconds. - Weight::from_ref_time(5_719_000 as u64) - // Standard Error: 3 - .saturating_add(Weight::from_ref_time(1_404 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `228 + v * (1 ±0)` + // Estimated: `2700 + v * (1 ±0)` + // Minimum execution time: 5_279 nanoseconds. + Weight::from_parts(5_517_000, 2700) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(1_230).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(v.into())) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) - // Storage: StateTrieMigration MigrationProcess (r:1 w:1) + /// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) + /// Proof: StateTrieMigration SignedMigrationMaxLimits (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: StateTrieMigration MigrationProcess (r:1 w:1) + /// Proof: StateTrieMigration MigrationProcess (max_values: Some(1), max_size: Some(1042), added: 1537, mode: MaxEncodedLen) fn continue_migrate() -> Weight { - // Minimum execution time: 23_874 nanoseconds. - Weight::from_ref_time(24_127_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `108` + // Estimated: `2040` + // Minimum execution time: 15_563 nanoseconds. + Weight::from_parts(15_783_000, 2040) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) + /// Storage: StateTrieMigration SignedMigrationMaxLimits (r:1 w:0) + /// Proof: StateTrieMigration SignedMigrationMaxLimits (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn continue_migrate_wrong_witness() -> Weight { - // Minimum execution time: 6_119 nanoseconds. - Weight::from_ref_time(6_325_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) + // Proof Size summary in bytes: + // Measured: `76` + // Estimated: `503` + // Minimum execution time: 4_347 nanoseconds. + Weight::from_parts(4_558_000, 503) + .saturating_add(RocksDbWeight::get().reads(1_u64)) } fn migrate_custom_top_success() -> Weight { - // Minimum execution time: 20_365 nanoseconds. - Weight::from_ref_time(20_790_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_817 nanoseconds. + Weight::from_ref_time(9_027_000) } - // Storage: unknown [0x666f6f] (r:1 w:1) + /// Storage: unknown `0x666f6f` (r:1 w:1) + /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_top_fail() -> Weight { - // Minimum execution time: 38_979 nanoseconds. - Weight::from_ref_time(40_271_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `144` + // Estimated: `2619` + // Minimum execution time: 23_854 nanoseconds. + Weight::from_parts(24_850_000, 2619) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn migrate_custom_child_success() -> Weight { - // Minimum execution time: 21_217 nanoseconds. - Weight::from_ref_time(21_526_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_020 nanoseconds. + Weight::from_ref_time(9_234_000) } - // Storage: unknown [0x666f6f] (r:1 w:1) + /// Storage: unknown `0x666f6f` (r:1 w:1) + /// Proof Skipped: unknown `0x666f6f` (r:1 w:1) fn migrate_custom_child_fail() -> Weight { - // Minimum execution time: 43_853 nanoseconds. - Weight::from_ref_time(44_693_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `136` + // Estimated: `2611` + // Minimum execution time: 24_136 nanoseconds. + Weight::from_parts(24_810_000, 2611) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: unknown [0x6b6579] (r:1 w:1) + /// Storage: unknown `0x6b6579` (r:1 w:1) + /// Proof Skipped: unknown `0x6b6579` (r:1 w:1) /// The range of component `v` is `[1, 4194304]`. fn process_top_key(v: u32, ) -> Weight { - // Minimum execution time: 5_575 nanoseconds. - Weight::from_ref_time(5_719_000 as u64) - // Standard Error: 3 - .saturating_add(Weight::from_ref_time(1_404 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `228 + v * (1 ±0)` + // Estimated: `2700 + v * (1 ±0)` + // Minimum execution time: 5_279 nanoseconds. + Weight::from_parts(5_517_000, 2700) + // Standard Error: 1 + .saturating_add(Weight::from_ref_time(1_230).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(v.into())) } } diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index 43e3e47de5..f3bd5c2cfe 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -438,6 +438,9 @@ pub fn benchmarks( #krate::BenchmarkMetadata { name: benchmark.as_bytes().to_vec(), components, + // TODO: Not supported by V2 syntax as of yet. + // https://github.com/paritytech/substrate/issues/13132 + pov_modes: vec![], } }).collect::<#krate::Vec<_>>() } diff --git a/frame/support/src/storage/transactional.rs b/frame/support/src/storage/transactional.rs index 909d5909ed..b7ae22d867 100644 --- a/frame/support/src/storage/transactional.rs +++ b/frame/support/src/storage/transactional.rs @@ -32,6 +32,8 @@ use sp_runtime::{DispatchError, TransactionOutcome, TransactionalError}; /// The type that is being used to store the current number of active layers. pub type Layer = u32; /// The key that is holds the current number of active layers. +/// +/// Encodes to `0x3a7472616e73616374696f6e5f6c6576656c3a`. pub const TRANSACTION_LEVEL_KEY: &[u8] = b":transaction_level:"; /// The maximum number of nested layers. pub const TRANSACTIONAL_LIMIT: Layer = 255; diff --git a/frame/support/src/weights/block_weights.rs b/frame/support/src/weights/block_weights.rs index b68c1fb508..dc01107cec 100644 --- a/frame/support/src/weights/block_weights.rs +++ b/frame/support/src/weights/block_weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,7 +16,7 @@ // limitations under the License. //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07 (Y/M/D) +//! DATE: 2023-01-25 (Y/M/D) //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development` @@ -44,17 +44,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 351_000, 392_617 - /// Average: 358_523 - /// Median: 359_836 - /// Std-Dev: 6698.67 + /// Min, Max: 377_722, 414_752 + /// Average: 381_015 + /// Median: 379_751 + /// Std-Dev: 5462.64 /// /// Percentiles nanoseconds: - /// 99th: 390_723 - /// 95th: 365_799 - /// 75th: 361_582 + /// 99th: 413_074 + /// 95th: 384_876 + /// 75th: 380_642 pub const BlockExecutionWeight: Weight = - Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(358_523)); + Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(381_015)); } #[cfg(test)] diff --git a/frame/support/src/weights/extrinsic_weights.rs b/frame/support/src/weights/extrinsic_weights.rs index ced1fb9162..3d25d5a402 100644 --- a/frame/support/src/weights/extrinsic_weights.rs +++ b/frame/support/src/weights/extrinsic_weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,7 +16,7 @@ // limitations under the License. //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07 (Y/M/D) +//! DATE: 2023-01-25 (Y/M/D) //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development` @@ -44,17 +44,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 98_722, 101_420 - /// Average: 98_974 - /// Median: 98_951 - /// Std-Dev: 271.62 + /// Min, Max: 99_481, 103_304 + /// Average: 99_840 + /// Median: 99_795 + /// Std-Dev: 376.17 /// /// Percentiles nanoseconds: - /// 99th: 99_202 - /// 95th: 99_163 - /// 75th: 99_030 + /// 99th: 100_078 + /// 95th: 100_051 + /// 75th: 99_916 pub const ExtrinsicBaseWeight: Weight = - Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(98_974)); + Weight::from_ref_time(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(99_840)); } #[cfg(test)] diff --git a/frame/system/src/weights.rs b/frame/system/src/weights.rs index 696a6a09b8..d189afd4a5 100644 --- a/frame/system/src/weights.rs +++ b/frame/system/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for frame_system //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -60,52 +61,76 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// The range of component `b` is `[0, 3932160]`. fn remark(b: u32, ) -> Weight { - // Minimum execution time: 3_951 nanoseconds. - Weight::from_ref_time(1_307_232 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_018 nanoseconds. + Weight::from_ref_time(2_091_000) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(363 as u64).saturating_mul(b as u64)) + .saturating_add(Weight::from_ref_time(362).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - // Minimum execution time: 14_880 nanoseconds. - Weight::from_ref_time(15_173_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_449 nanoseconds. + Weight::from_ref_time(7_748_000) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_424 as u64).saturating_mul(b as u64)) + .saturating_add(Weight::from_ref_time(1_423).saturating_mul(b.into())) } - // Storage: System Digest (r:1 w:1) - // Storage: unknown [0x3a686561707061676573] (r:0 w:1) + /// Storage: System Digest (r:1 w:1) + /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: unknown `0x3a686561707061676573` (r:0 w:1) + /// Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { - // Minimum execution time: 9_819 nanoseconds. - Weight::from_ref_time(10_513_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `495` + // Minimum execution time: 4_440 nanoseconds. + Weight::from_parts(4_605_000, 495) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32, ) -> Weight { - // Minimum execution time: 4_038 nanoseconds. - Weight::from_ref_time(4_098_000 as u64) - // Standard Error: 710 - .saturating_add(Weight::from_ref_time(620_813 as u64).saturating_mul(i as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_981 nanoseconds. + Weight::from_ref_time(2_114_000) + // Standard Error: 804 + .saturating_add(Weight::from_ref_time(631_438).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32, ) -> Weight { - // Minimum execution time: 3_972 nanoseconds. - Weight::from_ref_time(4_082_000 as u64) - // Standard Error: 884 - .saturating_add(Weight::from_ref_time(536_923 as u64).saturating_mul(i as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_061 nanoseconds. + Weight::from_ref_time(2_153_000) + // Standard Error: 952 + .saturating_add(Weight::from_ref_time(502_629).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - // Minimum execution time: 5_703 nanoseconds. - Weight::from_ref_time(5_763_000 as u64) - // Standard Error: 1_248 - .saturating_add(Weight::from_ref_time(1_126_062 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + // Proof Size summary in bytes: + // Measured: `116 + p * (69 ±0)` + // Estimated: `121 + p * (70 ±0)` + // Minimum execution time: 4_026 nanoseconds. + Weight::from_parts(4_174_000, 121) + // Standard Error: 1_148 + .saturating_add(Weight::from_ref_time(1_093_099).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_proof_size(70).saturating_mul(p.into())) } } @@ -113,51 +138,75 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { /// The range of component `b` is `[0, 3932160]`. fn remark(b: u32, ) -> Weight { - // Minimum execution time: 3_951 nanoseconds. - Weight::from_ref_time(1_307_232 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_018 nanoseconds. + Weight::from_ref_time(2_091_000) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(363 as u64).saturating_mul(b as u64)) + .saturating_add(Weight::from_ref_time(362).saturating_mul(b.into())) } /// The range of component `b` is `[0, 3932160]`. fn remark_with_event(b: u32, ) -> Weight { - // Minimum execution time: 14_880 nanoseconds. - Weight::from_ref_time(15_173_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_449 nanoseconds. + Weight::from_ref_time(7_748_000) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_424 as u64).saturating_mul(b as u64)) + .saturating_add(Weight::from_ref_time(1_423).saturating_mul(b.into())) } - // Storage: System Digest (r:1 w:1) - // Storage: unknown [0x3a686561707061676573] (r:0 w:1) + /// Storage: System Digest (r:1 w:1) + /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: unknown `0x3a686561707061676573` (r:0 w:1) + /// Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { - // Minimum execution time: 9_819 nanoseconds. - Weight::from_ref_time(10_513_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `495` + // Minimum execution time: 4_440 nanoseconds. + Weight::from_parts(4_605_000, 495) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. fn set_storage(i: u32, ) -> Weight { - // Minimum execution time: 4_038 nanoseconds. - Weight::from_ref_time(4_098_000 as u64) - // Standard Error: 710 - .saturating_add(Weight::from_ref_time(620_813 as u64).saturating_mul(i as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_981 nanoseconds. + Weight::from_ref_time(2_114_000) + // Standard Error: 804 + .saturating_add(Weight::from_ref_time(631_438).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `i` is `[0, 1000]`. fn kill_storage(i: u32, ) -> Weight { - // Minimum execution time: 3_972 nanoseconds. - Weight::from_ref_time(4_082_000 as u64) - // Standard Error: 884 - .saturating_add(Weight::from_ref_time(536_923 as u64).saturating_mul(i as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_061 nanoseconds. + Weight::from_ref_time(2_153_000) + // Standard Error: 952 + .saturating_add(Weight::from_ref_time(502_629).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) } - // Storage: Skipped Metadata (r:0 w:0) + /// Storage: Skipped Metadata (r:0 w:0) + /// Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) /// The range of component `p` is `[0, 1000]`. fn kill_prefix(p: u32, ) -> Weight { - // Minimum execution time: 5_703 nanoseconds. - Weight::from_ref_time(5_763_000 as u64) - // Standard Error: 1_248 - .saturating_add(Weight::from_ref_time(1_126_062 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(p as u64))) + // Proof Size summary in bytes: + // Measured: `116 + p * (69 ±0)` + // Estimated: `121 + p * (70 ±0)` + // Minimum execution time: 4_026 nanoseconds. + Weight::from_parts(4_174_000, 121) + // Standard Error: 1_148 + .saturating_add(Weight::from_ref_time(1_093_099).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_proof_size(70).saturating_mul(p.into())) } } diff --git a/frame/timestamp/src/weights.rs b/frame/timestamp/src/weights.rs index 5212392097..4c7dfd5ed1 100644 --- a/frame/timestamp/src/weights.rs +++ b/frame/timestamp/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_timestamp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -54,32 +55,48 @@ pub trait WeightInfo { /// Weights for pallet_timestamp using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Timestamp Now (r:1 w:1) - // Storage: Babe CurrentSlot (r:1 w:0) + /// Storage: Timestamp Now (r:1 w:1) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Babe CurrentSlot (r:1 w:0) + /// Proof: Babe CurrentSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn set() -> Weight { - // Minimum execution time: 11_331 nanoseconds. - Weight::from_ref_time(11_584_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `312` + // Estimated: `1006` + // Minimum execution time: 9_106 nanoseconds. + Weight::from_parts(9_258_000, 1006) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } fn on_finalize() -> Weight { - // Minimum execution time: 5_280 nanoseconds. - Weight::from_ref_time(5_412_000 as u64) + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `0` + // Minimum execution time: 3_927 nanoseconds. + Weight::from_ref_time(4_078_000) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Timestamp Now (r:1 w:1) - // Storage: Babe CurrentSlot (r:1 w:0) + /// Storage: Timestamp Now (r:1 w:1) + /// Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: Babe CurrentSlot (r:1 w:0) + /// Proof: Babe CurrentSlot (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn set() -> Weight { - // Minimum execution time: 11_331 nanoseconds. - Weight::from_ref_time(11_584_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `312` + // Estimated: `1006` + // Minimum execution time: 9_106 nanoseconds. + Weight::from_parts(9_258_000, 1006) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } fn on_finalize() -> Weight { - // Minimum execution time: 5_280 nanoseconds. - Weight::from_ref_time(5_412_000 as u64) + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `0` + // Minimum execution time: 3_927 nanoseconds. + Weight::from_ref_time(4_078_000) } } diff --git a/frame/tips/src/weights.rs b/frame/tips/src/weights.rs index 1aa3fd8fa2..a568aaa870 100644 --- a/frame/tips/src/weights.rs +++ b/frame/tips/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_tips //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -58,146 +59,218 @@ pub trait WeightInfo { /// Weights for pallet_tips using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Tips Reasons (r:1 w:1) - // Storage: Tips Tips (r:1 w:1) + /// Storage: Tips Reasons (r:1 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 300]`. fn report_awesome(r: u32, ) -> Weight { - // Minimum execution time: 35_458 nanoseconds. - Weight::from_ref_time(36_920_009 as u64) - // Standard Error: 252 - .saturating_add(Weight::from_ref_time(1_835 as u64).saturating_mul(r as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `4958` + // Minimum execution time: 23_262 nanoseconds. + Weight::from_parts(24_104_224, 4958) + // Standard Error: 148 + .saturating_add(Weight::from_ref_time(1_963).saturating_mul(r.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Tips Tips (r:1 w:1) - // Storage: Tips Reasons (r:0 w:1) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Reasons (r:0 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) fn retract_tip() -> Weight { - // Minimum execution time: 34_322 nanoseconds. - Weight::from_ref_time(35_292_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `2981` + // Minimum execution time: 22_282 nanoseconds. + Weight::from_parts(22_737_000, 2981) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Elections Members (r:1 w:0) - // Storage: Tips Reasons (r:1 w:1) - // Storage: Tips Tips (r:0 w:1) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Tips Reasons (r:1 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Tips (r:0 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 300]`. /// The range of component `t` is `[1, 13]`. fn tip_new(r: u32, t: u32, ) -> Weight { - // Minimum execution time: 26_691 nanoseconds. - Weight::from_ref_time(27_313_497 as u64) - // Standard Error: 141 - .saturating_add(Weight::from_ref_time(818 as u64).saturating_mul(r as u64)) - // Standard Error: 3_352 - .saturating_add(Weight::from_ref_time(108_557 as u64).saturating_mul(t as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `558 + t * (64 ±0)` + // Estimated: `4644 + t * (192 ±0)` + // Minimum execution time: 18_382 nanoseconds. + Weight::from_parts(18_195_288, 4644) + // Standard Error: 103 + .saturating_add(Weight::from_ref_time(2_096).saturating_mul(r.into())) + // Standard Error: 2_469 + .saturating_add(Weight::from_ref_time(97_092).saturating_mul(t.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(t.into())) } - // Storage: Elections Members (r:1 w:0) - // Storage: Tips Tips (r:1 w:1) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. fn tip(t: u32, ) -> Weight { - // Minimum execution time: 17_464 nanoseconds. - Weight::from_ref_time(17_621_090 as u64) - // Standard Error: 3_702 - .saturating_add(Weight::from_ref_time(269_919 as u64).saturating_mul(t as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `811 + t * (112 ±0)` + // Estimated: `4592 + t * (224 ±0)` + // Minimum execution time: 13_564 nanoseconds. + Weight::from_parts(13_867_280, 4592) + // Standard Error: 4_245 + .saturating_add(Weight::from_ref_time(206_587).saturating_mul(t.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(224).saturating_mul(t.into())) } - // Storage: Tips Tips (r:1 w:1) - // Storage: Elections Members (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Tips Reasons (r:0 w:1) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Tips Reasons (r:0 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. fn close_tip(t: u32, ) -> Weight { - // Minimum execution time: 52_221 nanoseconds. - Weight::from_ref_time(53_168_303 as u64) - // Standard Error: 6_591 - .saturating_add(Weight::from_ref_time(243_706 as u64).saturating_mul(t as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `850 + t * (112 ±0)` + // Estimated: `8096 + t * (336 ±0)` + // Minimum execution time: 39_902 nanoseconds. + Weight::from_parts(40_747_650, 8096) + // Standard Error: 5_322 + .saturating_add(Weight::from_ref_time(144_298).saturating_mul(t.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(336).saturating_mul(t.into())) } - // Storage: Tips Tips (r:1 w:1) - // Storage: Tips Reasons (r:0 w:1) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Reasons (r:0 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. fn slash_tip(t: u32, ) -> Weight { - // Minimum execution time: 22_911 nanoseconds. - Weight::from_ref_time(23_750_488 as u64) - // Standard Error: 2_561 - .saturating_add(Weight::from_ref_time(12_282 as u64).saturating_mul(t as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `301` + // Estimated: `3077` + // Minimum execution time: 13_511 nanoseconds. + Weight::from_parts(14_114_101, 3077) + // Standard Error: 1_815 + .saturating_add(Weight::from_ref_time(7_825).saturating_mul(t.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Tips Reasons (r:1 w:1) - // Storage: Tips Tips (r:1 w:1) + /// Storage: Tips Reasons (r:1 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 300]`. fn report_awesome(r: u32, ) -> Weight { - // Minimum execution time: 35_458 nanoseconds. - Weight::from_ref_time(36_920_009 as u64) - // Standard Error: 252 - .saturating_add(Weight::from_ref_time(1_835 as u64).saturating_mul(r as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `4` + // Estimated: `4958` + // Minimum execution time: 23_262 nanoseconds. + Weight::from_parts(24_104_224, 4958) + // Standard Error: 148 + .saturating_add(Weight::from_ref_time(1_963).saturating_mul(r.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Tips Tips (r:1 w:1) - // Storage: Tips Reasons (r:0 w:1) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Reasons (r:0 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) fn retract_tip() -> Weight { - // Minimum execution time: 34_322 nanoseconds. - Weight::from_ref_time(35_292_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `253` + // Estimated: `2981` + // Minimum execution time: 22_282 nanoseconds. + Weight::from_parts(22_737_000, 2981) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Elections Members (r:1 w:0) - // Storage: Tips Reasons (r:1 w:1) - // Storage: Tips Tips (r:0 w:1) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Tips Reasons (r:1 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Tips (r:0 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `r` is `[0, 300]`. /// The range of component `t` is `[1, 13]`. fn tip_new(r: u32, t: u32, ) -> Weight { - // Minimum execution time: 26_691 nanoseconds. - Weight::from_ref_time(27_313_497 as u64) - // Standard Error: 141 - .saturating_add(Weight::from_ref_time(818 as u64).saturating_mul(r as u64)) - // Standard Error: 3_352 - .saturating_add(Weight::from_ref_time(108_557 as u64).saturating_mul(t as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `558 + t * (64 ±0)` + // Estimated: `4644 + t * (192 ±0)` + // Minimum execution time: 18_382 nanoseconds. + Weight::from_parts(18_195_288, 4644) + // Standard Error: 103 + .saturating_add(Weight::from_ref_time(2_096).saturating_mul(r.into())) + // Standard Error: 2_469 + .saturating_add(Weight::from_ref_time(97_092).saturating_mul(t.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_proof_size(192).saturating_mul(t.into())) } - // Storage: Elections Members (r:1 w:0) - // Storage: Tips Tips (r:1 w:1) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. fn tip(t: u32, ) -> Weight { - // Minimum execution time: 17_464 nanoseconds. - Weight::from_ref_time(17_621_090 as u64) - // Standard Error: 3_702 - .saturating_add(Weight::from_ref_time(269_919 as u64).saturating_mul(t as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `811 + t * (112 ±0)` + // Estimated: `4592 + t * (224 ±0)` + // Minimum execution time: 13_564 nanoseconds. + Weight::from_parts(13_867_280, 4592) + // Standard Error: 4_245 + .saturating_add(Weight::from_ref_time(206_587).saturating_mul(t.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_proof_size(224).saturating_mul(t.into())) } - // Storage: Tips Tips (r:1 w:1) - // Storage: Elections Members (r:1 w:0) - // Storage: System Account (r:1 w:1) - // Storage: Tips Reasons (r:0 w:1) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) + /// Storage: Elections Members (r:1 w:0) + /// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Tips Reasons (r:0 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. fn close_tip(t: u32, ) -> Weight { - // Minimum execution time: 52_221 nanoseconds. - Weight::from_ref_time(53_168_303 as u64) - // Standard Error: 6_591 - .saturating_add(Weight::from_ref_time(243_706 as u64).saturating_mul(t as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `850 + t * (112 ±0)` + // Estimated: `8096 + t * (336 ±0)` + // Minimum execution time: 39_902 nanoseconds. + Weight::from_parts(40_747_650, 8096) + // Standard Error: 5_322 + .saturating_add(Weight::from_ref_time(144_298).saturating_mul(t.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(336).saturating_mul(t.into())) } - // Storage: Tips Tips (r:1 w:1) - // Storage: Tips Reasons (r:0 w:1) + /// Storage: Tips Tips (r:1 w:1) + /// Proof Skipped: Tips Tips (max_values: None, max_size: None, mode: Measured) + /// Storage: Tips Reasons (r:0 w:1) + /// Proof Skipped: Tips Reasons (max_values: None, max_size: None, mode: Measured) /// The range of component `t` is `[1, 13]`. fn slash_tip(t: u32, ) -> Weight { - // Minimum execution time: 22_911 nanoseconds. - Weight::from_ref_time(23_750_488 as u64) - // Standard Error: 2_561 - .saturating_add(Weight::from_ref_time(12_282 as u64).saturating_mul(t as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `301` + // Estimated: `3077` + // Minimum execution time: 13_511 nanoseconds. + Weight::from_parts(14_114_101, 3077) + // Standard Error: 1_815 + .saturating_add(Weight::from_ref_time(7_825).saturating_mul(t.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/frame/transaction-storage/src/weights.rs b/frame/transaction-storage/src/weights.rs index 16d12aa75a..9ee7b37b3d 100644 --- a/frame/transaction-storage/src/weights.rs +++ b/frame/transaction-storage/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_transaction_storage //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -55,78 +56,116 @@ pub trait WeightInfo { /// Weights for pallet_transaction_storage using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: TransactionStorage ByteFee (r:1 w:0) - // Storage: TransactionStorage EntryFee (r:1 w:0) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - // Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Storage: TransactionStorage ByteFee (r:1 w:0) + /// Proof: TransactionStorage ByteFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage EntryFee (r:1 w:0) + /// Proof: TransactionStorage EntryFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Proof: TransactionStorage BlockTransactions (max_values: Some(1), max_size: Some(36866), added: 37361, mode: MaxEncodedLen) /// The range of component `l` is `[1, 8388608]`. fn store(l: u32, ) -> Weight { - // Minimum execution time: 46_730 nanoseconds. - Weight::from_ref_time(46_922_000 as u64) + // Proof Size summary in bytes: + // Measured: `176` + // Estimated: `38383` + // Minimum execution time: 28_702 nanoseconds. + Weight::from_parts(29_164_000, 38383) // Standard Error: 2 - .saturating_add(Weight::from_ref_time(5_601 as u64).saturating_mul(l as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + .saturating_add(Weight::from_ref_time(5_601).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: TransactionStorage Transactions (r:1 w:0) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - // Storage: TransactionStorage ByteFee (r:1 w:0) - // Storage: TransactionStorage EntryFee (r:1 w:0) - // Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Storage: TransactionStorage Transactions (r:1 w:0) + /// Proof: TransactionStorage Transactions (max_values: None, max_size: Some(36886), added: 39361, mode: MaxEncodedLen) + /// Storage: TransactionStorage ByteFee (r:1 w:0) + /// Proof: TransactionStorage ByteFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage EntryFee (r:1 w:0) + /// Proof: TransactionStorage EntryFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Proof: TransactionStorage BlockTransactions (max_values: Some(1), max_size: Some(36866), added: 37361, mode: MaxEncodedLen) fn renew() -> Weight { - // Minimum execution time: 56_802 nanoseconds. - Weight::from_ref_time(58_670_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `358` + // Estimated: `77744` + // Minimum execution time: 36_219 nanoseconds. + Weight::from_parts(36_979_000, 77744) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: TransactionStorage ProofChecked (r:1 w:1) - // Storage: TransactionStorage StoragePeriod (r:1 w:0) - // Storage: TransactionStorage ChunkCount (r:1 w:0) - // Storage: System ParentHash (r:1 w:0) - // Storage: TransactionStorage Transactions (r:1 w:0) + /// Storage: TransactionStorage ProofChecked (r:1 w:1) + /// Proof: TransactionStorage ProofChecked (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: TransactionStorage StoragePeriod (r:1 w:0) + /// Proof: TransactionStorage StoragePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: TransactionStorage ChunkCount (r:1 w:0) + /// Proof: TransactionStorage ChunkCount (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: System ParentHash (r:1 w:0) + /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TransactionStorage Transactions (r:1 w:0) + /// Proof: TransactionStorage Transactions (max_values: None, max_size: Some(36886), added: 39361, mode: MaxEncodedLen) fn check_proof_max() -> Weight { - // Minimum execution time: 74_016 nanoseconds. - Weight::from_ref_time(94_111_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `37177` + // Estimated: `43382` + // Minimum execution time: 55_793 nanoseconds. + Weight::from_parts(57_128_000, 43382) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: TransactionStorage ByteFee (r:1 w:0) - // Storage: TransactionStorage EntryFee (r:1 w:0) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - // Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Storage: TransactionStorage ByteFee (r:1 w:0) + /// Proof: TransactionStorage ByteFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage EntryFee (r:1 w:0) + /// Proof: TransactionStorage EntryFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Proof: TransactionStorage BlockTransactions (max_values: Some(1), max_size: Some(36866), added: 37361, mode: MaxEncodedLen) /// The range of component `l` is `[1, 8388608]`. fn store(l: u32, ) -> Weight { - // Minimum execution time: 46_730 nanoseconds. - Weight::from_ref_time(46_922_000 as u64) + // Proof Size summary in bytes: + // Measured: `176` + // Estimated: `38383` + // Minimum execution time: 28_702 nanoseconds. + Weight::from_parts(29_164_000, 38383) // Standard Error: 2 - .saturating_add(Weight::from_ref_time(5_601 as u64).saturating_mul(l as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + .saturating_add(Weight::from_ref_time(5_601).saturating_mul(l.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: TransactionStorage Transactions (r:1 w:0) - // Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0) - // Storage: TransactionStorage ByteFee (r:1 w:0) - // Storage: TransactionStorage EntryFee (r:1 w:0) - // Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Storage: TransactionStorage Transactions (r:1 w:0) + /// Proof: TransactionStorage Transactions (max_values: None, max_size: Some(36886), added: 39361, mode: MaxEncodedLen) + /// Storage: TransactionStorage ByteFee (r:1 w:0) + /// Proof: TransactionStorage ByteFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage EntryFee (r:1 w:0) + /// Proof: TransactionStorage EntryFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: TransactionStorage BlockTransactions (r:1 w:1) + /// Proof: TransactionStorage BlockTransactions (max_values: Some(1), max_size: Some(36866), added: 37361, mode: MaxEncodedLen) fn renew() -> Weight { - // Minimum execution time: 56_802 nanoseconds. - Weight::from_ref_time(58_670_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `358` + // Estimated: `77744` + // Minimum execution time: 36_219 nanoseconds. + Weight::from_parts(36_979_000, 77744) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: TransactionStorage ProofChecked (r:1 w:1) - // Storage: TransactionStorage StoragePeriod (r:1 w:0) - // Storage: TransactionStorage ChunkCount (r:1 w:0) - // Storage: System ParentHash (r:1 w:0) - // Storage: TransactionStorage Transactions (r:1 w:0) + /// Storage: TransactionStorage ProofChecked (r:1 w:1) + /// Proof: TransactionStorage ProofChecked (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: TransactionStorage StoragePeriod (r:1 w:0) + /// Proof: TransactionStorage StoragePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: TransactionStorage ChunkCount (r:1 w:0) + /// Proof: TransactionStorage ChunkCount (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: System ParentHash (r:1 w:0) + /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: TransactionStorage Transactions (r:1 w:0) + /// Proof: TransactionStorage Transactions (max_values: None, max_size: Some(36886), added: 39361, mode: MaxEncodedLen) fn check_proof_max() -> Weight { - // Minimum execution time: 74_016 nanoseconds. - Weight::from_ref_time(94_111_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `37177` + // Estimated: `43382` + // Minimum execution time: 55_793 nanoseconds. + Weight::from_parts(57_128_000, 43382) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } } diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 3ee071ac70..aff593d88a 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_treasury //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -58,114 +59,194 @@ pub trait WeightInfo { /// Weights for pallet_treasury using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + /// Storage: Treasury ProposalCount (r:1 w:1) + /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:0 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn spend() -> Weight { - // Minimum execution time: 137 nanoseconds. - Weight::from_ref_time(153_000 as u64) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `1396` + // Minimum execution time: 14_277 nanoseconds. + Weight::from_parts(14_749_000, 1396) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Treasury ProposalCount (r:1 w:1) - // Storage: Treasury Proposals (r:0 w:1) + /// Storage: Treasury ProposalCount (r:1 w:1) + /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:0 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { - // Minimum execution time: 31_437 nanoseconds. - Weight::from_ref_time(32_241_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `175` + // Estimated: `499` + // Minimum execution time: 23_297 nanoseconds. + Weight::from_parts(23_585_000, 499) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Treasury Proposals (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Treasury Proposals (r:1 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn reject_proposal() -> Weight { - // Minimum execution time: 38_351 nanoseconds. - Weight::from_ref_time(38_828_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `365` + // Estimated: `5186` + // Minimum execution time: 23_996 nanoseconds. + Weight::from_parts(24_548_000, 5186) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Treasury Proposals (r:1 w:0) - // Storage: Treasury Approvals (r:1 w:1) + /// Storage: Treasury Proposals (r:1 w:0) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32, ) -> Weight { - // Minimum execution time: 11_937 nanoseconds. - Weight::from_ref_time(15_541_763 as u64) - // Standard Error: 1_036 - .saturating_add(Weight::from_ref_time(128_326 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `501 + p * (8 ±0)` + // Estimated: `3480` + // Minimum execution time: 9_366 nanoseconds. + Weight::from_parts(11_731_455, 3480) + // Standard Error: 761 + .saturating_add(Weight::from_ref_time(21_665).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Treasury Approvals (r:1 w:1) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn remove_approval() -> Weight { - // Minimum execution time: 9_611 nanoseconds. - Weight::from_ref_time(10_012_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `127` + // Estimated: `897` + // Minimum execution time: 7_012 nanoseconds. + Weight::from_parts(7_270_000, 897) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Treasury Approvals (r:1 w:1) - // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Treasury Proposals (r:2 w:2) - // Storage: System Account (r:4 w:4) + /// Storage: Treasury Deactivated (r:1 w:1) + /// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:100 w:100) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: System Account (r:200 w:200) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32, ) -> Weight { - // Minimum execution time: 43_016 nanoseconds. - Weight::from_ref_time(56_538_751 as u64) - // Standard Error: 14_890 - .saturating_add(Weight::from_ref_time(26_789_120 as u64).saturating_mul(p as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(p as u64))) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - .saturating_add(T::DbWeight::get().writes((3 as u64).saturating_mul(p as u64))) + // Proof Size summary in bytes: + // Measured: `415 + p * (314 ±0)` + // Estimated: `2305 + p * (7789 ±0)` + // Minimum execution time: 37_834 nanoseconds. + Weight::from_parts(47_496_917, 2305) + // Standard Error: 12_505 + .saturating_add(Weight::from_ref_time(26_902_474).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_proof_size(7789).saturating_mul(p.into())) } } // For backwards compatibility and tests impl WeightInfo for () { + /// Storage: Treasury ProposalCount (r:1 w:1) + /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:0 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn spend() -> Weight { - // Minimum execution time: 137 nanoseconds. - Weight::from_ref_time(153_000 as u64) + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `1396` + // Minimum execution time: 14_277 nanoseconds. + Weight::from_parts(14_749_000, 1396) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Treasury ProposalCount (r:1 w:1) - // Storage: Treasury Proposals (r:0 w:1) + /// Storage: Treasury ProposalCount (r:1 w:1) + /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:0 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { - // Minimum execution time: 31_437 nanoseconds. - Weight::from_ref_time(32_241_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `175` + // Estimated: `499` + // Minimum execution time: 23_297 nanoseconds. + Weight::from_parts(23_585_000, 499) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Treasury Proposals (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Treasury Proposals (r:1 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) fn reject_proposal() -> Weight { - // Minimum execution time: 38_351 nanoseconds. - Weight::from_ref_time(38_828_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `365` + // Estimated: `5186` + // Minimum execution time: 23_996 nanoseconds. + Weight::from_parts(24_548_000, 5186) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Treasury Proposals (r:1 w:0) - // Storage: Treasury Approvals (r:1 w:1) + /// Storage: Treasury Proposals (r:1 w:0) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) /// The range of component `p` is `[0, 99]`. fn approve_proposal(p: u32, ) -> Weight { - // Minimum execution time: 11_937 nanoseconds. - Weight::from_ref_time(15_541_763 as u64) - // Standard Error: 1_036 - .saturating_add(Weight::from_ref_time(128_326 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `501 + p * (8 ±0)` + // Estimated: `3480` + // Minimum execution time: 9_366 nanoseconds. + Weight::from_parts(11_731_455, 3480) + // Standard Error: 761 + .saturating_add(Weight::from_ref_time(21_665).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Treasury Approvals (r:1 w:1) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn remove_approval() -> Weight { - // Minimum execution time: 9_611 nanoseconds. - Weight::from_ref_time(10_012_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Proof Size summary in bytes: + // Measured: `127` + // Estimated: `897` + // Minimum execution time: 7_012 nanoseconds. + Weight::from_parts(7_270_000, 897) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Treasury Approvals (r:1 w:1) - // Storage: Bounties BountyApprovals (r:1 w:1) - // Storage: Treasury Proposals (r:2 w:2) - // Storage: System Account (r:4 w:4) + /// Storage: Treasury Deactivated (r:1 w:1) + /// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:100 w:100) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: System Account (r:200 w:200) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) /// The range of component `p` is `[0, 100]`. fn on_initialize_proposals(p: u32, ) -> Weight { - // Minimum execution time: 43_016 nanoseconds. - Weight::from_ref_time(56_538_751 as u64) - // Standard Error: 14_890 - .saturating_add(Weight::from_ref_time(26_789_120 as u64).saturating_mul(p as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(p as u64))) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - .saturating_add(RocksDbWeight::get().writes((3 as u64).saturating_mul(p as u64))) + // Proof Size summary in bytes: + // Measured: `415 + p * (314 ±0)` + // Estimated: `2305 + p * (7789 ±0)` + // Minimum execution time: 37_834 nanoseconds. + Weight::from_parts(47_496_917, 2305) + // Standard Error: 12_505 + .saturating_add(Weight::from_ref_time(26_902_474).saturating_mul(p.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(p.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_proof_size(7789).saturating_mul(p.into())) } } diff --git a/frame/uniques/src/weights.rs b/frame/uniques/src/weights.rs index 8a8e1090bb..3c1b102ba0 100644 --- a/frame/uniques/src/weights.rs +++ b/frame/uniques/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_uniques //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -78,486 +79,776 @@ pub trait WeightInfo { /// Weights for pallet_uniques using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:1) + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 35_358 nanoseconds. - Weight::from_ref_time(35_935_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `281` + // Estimated: `2653` + // Minimum execution time: 24_242 nanoseconds. + Weight::from_parts(24_682_000, 2653) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_create() -> Weight { - // Minimum execution time: 22_767 nanoseconds. - Weight::from_ref_time(23_235_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques Asset (r:1 w:0) - // Storage: Uniques ClassAccount (r:0 w:1) - // Storage: Uniques Attribute (r:0 w:1000) - // Storage: Uniques ClassMetadataOf (r:0 w:1) - // Storage: Uniques InstanceMetadataOf (r:0 w:1000) - // Storage: Uniques CollectionMaxSupply (r:0 w:1) - // Storage: Uniques Account (r:0 w:20) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `2653` + // Minimum execution time: 14_145 nanoseconds. + Weight::from_parts(14_598_000, 2653) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1001 w:1000) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:0 w:1000) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) + /// Storage: Uniques ClassMetadataOf (r:0 w:1) + /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:0 w:1000) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:1000) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques CollectionMaxSupply (r:0 w:1) + /// Proof: Uniques CollectionMaxSupply (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - // Minimum execution time: 2_453_194 nanoseconds. - Weight::from_ref_time(2_469_109_000 as u64) - // Standard Error: 27_900 - .saturating_add(Weight::from_ref_time(8_974_176 as u64).saturating_mul(n as u64)) - // Standard Error: 27_900 - .saturating_add(Weight::from_ref_time(344_842 as u64).saturating_mul(m as u64)) - // Standard Error: 27_900 - .saturating_add(Weight::from_ref_time(185_438 as u64).saturating_mul(a as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(n as u64))) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(n as u64))) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(m as u64))) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(a as u64))) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques CollectionMaxSupply (r:1 w:0) - // Storage: Uniques Account (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `450 + n * (108 ±0) + m * (56 ±0) + a * (107 ±0)` + // Estimated: `5250 + n * (2597 ±0)` + // Minimum execution time: 2_404_081 nanoseconds. + Weight::from_parts(2_419_004_000, 5250) + // Standard Error: 27_175 + .saturating_add(Weight::from_ref_time(8_616_904).saturating_mul(n.into())) + // Standard Error: 27_175 + .saturating_add(Weight::from_ref_time(334_249).saturating_mul(m.into())) + // Standard Error: 27_175 + .saturating_add(Weight::from_ref_time(213_038).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(m.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_proof_size(2597).saturating_mul(n.into())) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques CollectionMaxSupply (r:1 w:0) + /// Proof: Uniques CollectionMaxSupply (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:1) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { - // Minimum execution time: 45_115 nanoseconds. - Weight::from_ref_time(45_746_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Account (r:0 w:1) - // Storage: Uniques ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `7749` + // Minimum execution time: 29_326 nanoseconds. + Weight::from_parts(29_671_000, 7749) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:1) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:0 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn burn() -> Weight { - // Minimum execution time: 46_447 nanoseconds. - Weight::from_ref_time(46_994_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Account (r:0 w:2) - // Storage: Uniques ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 30_497 nanoseconds. + Weight::from_parts(30_714_000, 5250) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:2) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:0 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 35_953 nanoseconds. - Weight::from_ref_time(36_375_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques Asset (r:102 w:102) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 24_212 nanoseconds. + Weight::from_parts(24_681_000, 5250) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:5000 w:5000) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - // Minimum execution time: 24_238 nanoseconds. - Weight::from_ref_time(24_788_000 as u64) - // Standard Error: 9_232 - .saturating_add(Weight::from_ref_time(11_322_011 as u64).saturating_mul(i as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(i as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `837 + i * (108 ±0)` + // Estimated: `2653 + i * (2597 ±0)` + // Minimum execution time: 13_633 nanoseconds. + Weight::from_parts(13_797_000, 2653) + // Standard Error: 9_293 + .saturating_add(Weight::from_ref_time(11_163_914).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_proof_size(2597).saturating_mul(i.into())) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze() -> Weight { - // Minimum execution time: 28_595 nanoseconds. - Weight::from_ref_time(29_280_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 17_126 nanoseconds. + Weight::from_parts(17_572_000, 5250) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw() -> Weight { - // Minimum execution time: 28_581 nanoseconds. - Weight::from_ref_time(29_038_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 17_209 nanoseconds. + Weight::from_parts(17_411_000, 5250) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze_collection() -> Weight { - // Minimum execution time: 24_298 nanoseconds. - Weight::from_ref_time(24_742_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 13_048 nanoseconds. + Weight::from_parts(13_589_000, 2653) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw_collection() -> Weight { - // Minimum execution time: 24_004 nanoseconds. - Weight::from_ref_time(24_536_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques OwnershipAcceptance (r:1 w:1) - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 12_908 nanoseconds. + Weight::from_parts(13_098_000, 2653) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques OwnershipAcceptance (r:1 w:1) + /// Proof: Uniques OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:2) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { - // Minimum execution time: 32_599 nanoseconds. - Weight::from_ref_time(33_201_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - } - // Storage: Uniques Class (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `455` + // Estimated: `5180` + // Minimum execution time: 20_629 nanoseconds. + Weight::from_parts(21_448_000, 5180) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_team() -> Weight { - // Minimum execution time: 25_137 nanoseconds. - Weight::from_ref_time(25_877_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 13_740 nanoseconds. + Weight::from_parts(14_020_000, 2653) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_item_status() -> Weight { - // Minimum execution time: 27_736 nanoseconds. - Weight::from_ref_time(28_279_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:0) - // Storage: Uniques Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 16_293 nanoseconds. + Weight::from_parts(16_509_000, 2653) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:0) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:1 w:1) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn set_attribute() -> Weight { - // Minimum execution time: 51_195 nanoseconds. - Weight::from_ref_time(51_674_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:0) - // Storage: Uniques Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `611` + // Estimated: `8075` + // Minimum execution time: 33_560 nanoseconds. + Weight::from_parts(34_263_000, 8075) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:0) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:1 w:1) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn clear_attribute() -> Weight { - // Minimum execution time: 50_159 nanoseconds. - Weight::from_ref_time(51_412_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `1031` + // Estimated: `8075` + // Minimum execution time: 31_955 nanoseconds. + Weight::from_parts(32_447_000, 8075) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:1) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn set_metadata() -> Weight { - // Minimum execution time: 42_608 nanoseconds. - Weight::from_ref_time(42_880_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `5236` + // Minimum execution time: 25_520 nanoseconds. + Weight::from_parts(25_843_000, 5236) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:1) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 43_239 nanoseconds. - Weight::from_ref_time(43_752_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `611` + // Estimated: `5236` + // Minimum execution time: 25_812 nanoseconds. + Weight::from_parts(26_141_000, 5236) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassMetadataOf (r:1 w:1) + /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { - // Minimum execution time: 41_224 nanoseconds. - Weight::from_ref_time(41_974_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques ClassMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `5216` + // Minimum execution time: 25_055 nanoseconds. + Weight::from_parts(25_244_000, 5216) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassMetadataOf (r:1 w:1) + /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { - // Minimum execution time: 40_836 nanoseconds. - Weight::from_ref_time(41_864_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `525` + // Estimated: `5216` + // Minimum execution time: 23_311 nanoseconds. + Weight::from_parts(23_682_000, 5216) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn approve_transfer() -> Weight { - // Minimum execution time: 29_558 nanoseconds. - Weight::from_ref_time(29_948_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 17_709 nanoseconds. + Weight::from_parts(18_308_000, 5250) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn cancel_approval() -> Weight { - // Minimum execution time: 29_694 nanoseconds. - Weight::from_ref_time(30_156_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques OwnershipAcceptance (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `592` + // Estimated: `5250` + // Minimum execution time: 17_656 nanoseconds. + Weight::from_parts(18_039_000, 5250) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques OwnershipAcceptance (r:1 w:1) + /// Proof: Uniques OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_accept_ownership() -> Weight { - // Minimum execution time: 27_819 nanoseconds. - Weight::from_ref_time(28_245_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques CollectionMaxSupply (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `2527` + // Minimum execution time: 14_615 nanoseconds. + Weight::from_parts(14_931_000, 2527) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques CollectionMaxSupply (r:1 w:1) + /// Proof: Uniques CollectionMaxSupply (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { - // Minimum execution time: 26_317 nanoseconds. - Weight::from_ref_time(26_893_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Asset (r:1 w:0) - // Storage: Uniques ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `5152` + // Minimum execution time: 14_974 nanoseconds. + Weight::from_parts(15_314_000, 5152) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Asset (r:1 w:0) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:0 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { - // Minimum execution time: 26_546 nanoseconds. - Weight::from_ref_time(27_142_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques ItemPriceOf (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Account (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `358` + // Estimated: `2597` + // Minimum execution time: 15_444 nanoseconds. + Weight::from_parts(15_886_000, 2597) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:1 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:2) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn buy_item() -> Weight { - // Minimum execution time: 49_238 nanoseconds. - Weight::from_ref_time(50_444_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `703` + // Estimated: `7814` + // Minimum execution time: 35_628 nanoseconds. + Weight::from_parts(35_886_000, 7814) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:1) + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn create() -> Weight { - // Minimum execution time: 35_358 nanoseconds. - Weight::from_ref_time(35_935_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `281` + // Estimated: `2653` + // Minimum execution time: 24_242 nanoseconds. + Weight::from_parts(24_682_000, 2653) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_create() -> Weight { - // Minimum execution time: 22_767 nanoseconds. - Weight::from_ref_time(23_235_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques Asset (r:1 w:0) - // Storage: Uniques ClassAccount (r:0 w:1) - // Storage: Uniques Attribute (r:0 w:1000) - // Storage: Uniques ClassMetadataOf (r:0 w:1) - // Storage: Uniques InstanceMetadataOf (r:0 w:1000) - // Storage: Uniques CollectionMaxSupply (r:0 w:1) - // Storage: Uniques Account (r:0 w:20) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `2653` + // Minimum execution time: 14_145 nanoseconds. + Weight::from_parts(14_598_000, 2653) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1001 w:1000) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:0 w:1000) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) + /// Storage: Uniques ClassMetadataOf (r:0 w:1) + /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:0 w:1000) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:1000) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques CollectionMaxSupply (r:0 w:1) + /// Proof: Uniques CollectionMaxSupply (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) /// The range of component `n` is `[0, 1000]`. /// The range of component `m` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. fn destroy(n: u32, m: u32, a: u32, ) -> Weight { - // Minimum execution time: 2_453_194 nanoseconds. - Weight::from_ref_time(2_469_109_000 as u64) - // Standard Error: 27_900 - .saturating_add(Weight::from_ref_time(8_974_176 as u64).saturating_mul(n as u64)) - // Standard Error: 27_900 - .saturating_add(Weight::from_ref_time(344_842 as u64).saturating_mul(m as u64)) - // Standard Error: 27_900 - .saturating_add(Weight::from_ref_time(185_438 as u64).saturating_mul(a as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(n as u64))) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(n as u64))) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(m as u64))) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(a as u64))) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques CollectionMaxSupply (r:1 w:0) - // Storage: Uniques Account (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `450 + n * (108 ±0) + m * (56 ±0) + a * (107 ±0)` + // Estimated: `5250 + n * (2597 ±0)` + // Minimum execution time: 2_404_081 nanoseconds. + Weight::from_parts(2_419_004_000, 5250) + // Standard Error: 27_175 + .saturating_add(Weight::from_ref_time(8_616_904).saturating_mul(n.into())) + // Standard Error: 27_175 + .saturating_add(Weight::from_ref_time(334_249).saturating_mul(m.into())) + // Standard Error: 27_175 + .saturating_add(Weight::from_ref_time(213_038).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(m.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_proof_size(2597).saturating_mul(n.into())) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques CollectionMaxSupply (r:1 w:0) + /// Proof: Uniques CollectionMaxSupply (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:1) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn mint() -> Weight { - // Minimum execution time: 45_115 nanoseconds. - Weight::from_ref_time(45_746_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Account (r:0 w:1) - // Storage: Uniques ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `7749` + // Minimum execution time: 29_326 nanoseconds. + Weight::from_parts(29_671_000, 7749) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:1) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:0 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn burn() -> Weight { - // Minimum execution time: 46_447 nanoseconds. - Weight::from_ref_time(46_994_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Account (r:0 w:2) - // Storage: Uniques ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 30_497 nanoseconds. + Weight::from_parts(30_714_000, 5250) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:2) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:0 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn transfer() -> Weight { - // Minimum execution time: 35_953 nanoseconds. - Weight::from_ref_time(36_375_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques Asset (r:102 w:102) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 24_212 nanoseconds. + Weight::from_parts(24_681_000, 5250) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:5000 w:5000) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { - // Minimum execution time: 24_238 nanoseconds. - Weight::from_ref_time(24_788_000 as u64) - // Standard Error: 9_232 - .saturating_add(Weight::from_ref_time(11_322_011 as u64).saturating_mul(i as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(i as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `837 + i * (108 ±0)` + // Estimated: `2653 + i * (2597 ±0)` + // Minimum execution time: 13_633 nanoseconds. + Weight::from_parts(13_797_000, 2653) + // Standard Error: 9_293 + .saturating_add(Weight::from_ref_time(11_163_914).saturating_mul(i.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) + .saturating_add(Weight::from_proof_size(2597).saturating_mul(i.into())) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze() -> Weight { - // Minimum execution time: 28_595 nanoseconds. - Weight::from_ref_time(29_280_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 17_126 nanoseconds. + Weight::from_parts(17_572_000, 5250) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw() -> Weight { - // Minimum execution time: 28_581 nanoseconds. - Weight::from_ref_time(29_038_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 17_209 nanoseconds. + Weight::from_parts(17_411_000, 5250) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn freeze_collection() -> Weight { - // Minimum execution time: 24_298 nanoseconds. - Weight::from_ref_time(24_742_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 13_048 nanoseconds. + Weight::from_parts(13_589_000, 2653) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn thaw_collection() -> Weight { - // Minimum execution time: 24_004 nanoseconds. - Weight::from_ref_time(24_536_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques OwnershipAcceptance (r:1 w:1) - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 12_908 nanoseconds. + Weight::from_parts(13_098_000, 2653) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques OwnershipAcceptance (r:1 w:1) + /// Proof: Uniques OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:2) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn transfer_ownership() -> Weight { - // Minimum execution time: 32_599 nanoseconds. - Weight::from_ref_time(33_201_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - } - // Storage: Uniques Class (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `455` + // Estimated: `5180` + // Minimum execution time: 20_629 nanoseconds. + Weight::from_parts(21_448_000, 5180) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_team() -> Weight { - // Minimum execution time: 25_137 nanoseconds. - Weight::from_ref_time(25_877_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassAccount (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 13_740 nanoseconds. + Weight::from_parts(14_020_000, 2653) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassAccount (r:0 w:1) + /// Proof: Uniques ClassAccount (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) fn force_item_status() -> Weight { - // Minimum execution time: 27_736 nanoseconds. - Weight::from_ref_time(28_279_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:0) - // Storage: Uniques Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `2653` + // Minimum execution time: 16_293 nanoseconds. + Weight::from_parts(16_509_000, 2653) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:0) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:1 w:1) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn set_attribute() -> Weight { - // Minimum execution time: 51_195 nanoseconds. - Weight::from_ref_time(51_674_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:0) - // Storage: Uniques Attribute (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `611` + // Estimated: `8075` + // Minimum execution time: 33_560 nanoseconds. + Weight::from_parts(34_263_000, 8075) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:0) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Uniques Attribute (r:1 w:1) + /// Proof: Uniques Attribute (max_values: None, max_size: Some(364), added: 2839, mode: MaxEncodedLen) fn clear_attribute() -> Weight { - // Minimum execution time: 50_159 nanoseconds. - Weight::from_ref_time(51_412_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `1031` + // Estimated: `8075` + // Minimum execution time: 31_955 nanoseconds. + Weight::from_parts(32_447_000, 8075) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:1) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn set_metadata() -> Weight { - // Minimum execution time: 42_608 nanoseconds. - Weight::from_ref_time(42_880_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques InstanceMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `447` + // Estimated: `5236` + // Minimum execution time: 25_520 nanoseconds. + Weight::from_parts(25_843_000, 5236) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques InstanceMetadataOf (r:1 w:1) + /// Proof: Uniques InstanceMetadataOf (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn clear_metadata() -> Weight { - // Minimum execution time: 43_239 nanoseconds. - Weight::from_ref_time(43_752_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:1) - // Storage: Uniques ClassMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `611` + // Estimated: `5236` + // Minimum execution time: 25_812 nanoseconds. + Weight::from_parts(26_141_000, 5236) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:1) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassMetadataOf (r:1 w:1) + /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn set_collection_metadata() -> Weight { - // Minimum execution time: 41_224 nanoseconds. - Weight::from_ref_time(41_974_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques ClassMetadataOf (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `5216` + // Minimum execution time: 25_055 nanoseconds. + Weight::from_parts(25_244_000, 5216) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques ClassMetadataOf (r:1 w:1) + /// Proof: Uniques ClassMetadataOf (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn clear_collection_metadata() -> Weight { - // Minimum execution time: 40_836 nanoseconds. - Weight::from_ref_time(41_864_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `525` + // Estimated: `5216` + // Minimum execution time: 23_311 nanoseconds. + Weight::from_parts(23_682_000, 5216) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn approve_transfer() -> Weight { - // Minimum execution time: 29_558 nanoseconds. - Weight::from_ref_time(29_948_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Asset (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `559` + // Estimated: `5250` + // Minimum execution time: 17_709 nanoseconds. + Weight::from_parts(18_308_000, 5250) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) fn cancel_approval() -> Weight { - // Minimum execution time: 29_694 nanoseconds. - Weight::from_ref_time(30_156_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques OwnershipAcceptance (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `592` + // Estimated: `5250` + // Minimum execution time: 17_656 nanoseconds. + Weight::from_parts(18_039_000, 5250) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques OwnershipAcceptance (r:1 w:1) + /// Proof: Uniques OwnershipAcceptance (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) fn set_accept_ownership() -> Weight { - // Minimum execution time: 27_819 nanoseconds. - Weight::from_ref_time(28_245_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques CollectionMaxSupply (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `109` + // Estimated: `2527` + // Minimum execution time: 14_615 nanoseconds. + Weight::from_parts(14_931_000, 2527) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques CollectionMaxSupply (r:1 w:1) + /// Proof: Uniques CollectionMaxSupply (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) fn set_collection_max_supply() -> Weight { - // Minimum execution time: 26_317 nanoseconds. - Weight::from_ref_time(26_893_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Asset (r:1 w:0) - // Storage: Uniques ItemPriceOf (r:0 w:1) + // Proof Size summary in bytes: + // Measured: `381` + // Estimated: `5152` + // Minimum execution time: 14_974 nanoseconds. + Weight::from_parts(15_314_000, 5152) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Asset (r:1 w:0) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:0 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) fn set_price() -> Weight { - // Minimum execution time: 26_546 nanoseconds. - Weight::from_ref_time(27_142_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - // Storage: Uniques Asset (r:1 w:1) - // Storage: Uniques ItemPriceOf (r:1 w:1) - // Storage: Uniques Class (r:1 w:0) - // Storage: Uniques Account (r:0 w:2) + // Proof Size summary in bytes: + // Measured: `358` + // Estimated: `2597` + // Minimum execution time: 15_444 nanoseconds. + Weight::from_parts(15_886_000, 2597) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Uniques Asset (r:1 w:1) + /// Proof: Uniques Asset (max_values: None, max_size: Some(122), added: 2597, mode: MaxEncodedLen) + /// Storage: Uniques ItemPriceOf (r:1 w:1) + /// Proof: Uniques ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen) + /// Storage: Uniques Class (r:1 w:0) + /// Proof: Uniques Class (max_values: None, max_size: Some(178), added: 2653, mode: MaxEncodedLen) + /// Storage: Uniques Account (r:0 w:2) + /// Proof: Uniques Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen) fn buy_item() -> Weight { - // Minimum execution time: 49_238 nanoseconds. - Weight::from_ref_time(50_444_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `703` + // Estimated: `7814` + // Minimum execution time: 35_628 nanoseconds. + Weight::from_parts(35_886_000, 7814) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } } diff --git a/frame/utility/src/weights.rs b/frame/utility/src/weights.rs index eac94e44b8..7b8c261d1d 100644 --- a/frame/utility/src/weights.rs +++ b/frame/utility/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_utility //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -59,32 +60,47 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - // Minimum execution time: 14_470 nanoseconds. - Weight::from_ref_time(17_443_346 as u64) - // Standard Error: 2_037 - .saturating_add(Weight::from_ref_time(3_510_555 as u64).saturating_mul(c as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_742 nanoseconds. + Weight::from_ref_time(16_087_635) + // Standard Error: 2_411 + .saturating_add(Weight::from_ref_time(3_665_506).saturating_mul(c.into())) } fn as_derivative() -> Weight { - // Minimum execution time: 6_799 nanoseconds. - Weight::from_ref_time(6_976_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_802 nanoseconds. + Weight::from_ref_time(5_269_000) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - // Minimum execution time: 14_630 nanoseconds. - Weight::from_ref_time(24_580_656 as u64) - // Standard Error: 2_202 - .saturating_add(Weight::from_ref_time(3_584_516 as u64).saturating_mul(c as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_100 nanoseconds. + Weight::from_ref_time(14_090_381) + // Standard Error: 1_917 + .saturating_add(Weight::from_ref_time(3_744_891).saturating_mul(c.into())) } fn dispatch_as() -> Weight { - // Minimum execution time: 16_597 nanoseconds. - Weight::from_ref_time(16_950_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_840 nanoseconds. + Weight::from_ref_time(9_280_000) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - // Minimum execution time: 13_885 nanoseconds. - Weight::from_ref_time(20_147_978 as u64) - // Standard Error: 2_232 - .saturating_add(Weight::from_ref_time(3_516_969 as u64).saturating_mul(c as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_245 nanoseconds. + Weight::from_ref_time(14_292_923) + // Standard Error: 1_803 + .saturating_add(Weight::from_ref_time(3_645_950).saturating_mul(c.into())) } } @@ -92,31 +108,46 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { /// The range of component `c` is `[0, 1000]`. fn batch(c: u32, ) -> Weight { - // Minimum execution time: 14_470 nanoseconds. - Weight::from_ref_time(17_443_346 as u64) - // Standard Error: 2_037 - .saturating_add(Weight::from_ref_time(3_510_555 as u64).saturating_mul(c as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_742 nanoseconds. + Weight::from_ref_time(16_087_635) + // Standard Error: 2_411 + .saturating_add(Weight::from_ref_time(3_665_506).saturating_mul(c.into())) } fn as_derivative() -> Weight { - // Minimum execution time: 6_799 nanoseconds. - Weight::from_ref_time(6_976_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_802 nanoseconds. + Weight::from_ref_time(5_269_000) } /// The range of component `c` is `[0, 1000]`. fn batch_all(c: u32, ) -> Weight { - // Minimum execution time: 14_630 nanoseconds. - Weight::from_ref_time(24_580_656 as u64) - // Standard Error: 2_202 - .saturating_add(Weight::from_ref_time(3_584_516 as u64).saturating_mul(c as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_100 nanoseconds. + Weight::from_ref_time(14_090_381) + // Standard Error: 1_917 + .saturating_add(Weight::from_ref_time(3_744_891).saturating_mul(c.into())) } fn dispatch_as() -> Weight { - // Minimum execution time: 16_597 nanoseconds. - Weight::from_ref_time(16_950_000 as u64) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 8_840 nanoseconds. + Weight::from_ref_time(9_280_000) } /// The range of component `c` is `[0, 1000]`. fn force_batch(c: u32, ) -> Weight { - // Minimum execution time: 13_885 nanoseconds. - Weight::from_ref_time(20_147_978 as u64) - // Standard Error: 2_232 - .saturating_add(Weight::from_ref_time(3_516_969 as u64).saturating_mul(c as u64)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 7_245 nanoseconds. + Weight::from_ref_time(14_292_923) + // Standard Error: 1_803 + .saturating_add(Weight::from_ref_time(3_645_950).saturating_mul(c.into())) } } diff --git a/frame/vesting/src/weights.rs b/frame/vesting/src/weights.rs index 5462445414..a6a70fb56f 100644 --- a/frame/vesting/src/weights.rs +++ b/frame/vesting/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,7 +18,8 @@ //! Autogenerated weights for pallet_vesting //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -60,244 +61,336 @@ pub trait WeightInfo { /// Weights for pallet_vesting using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 45_113 nanoseconds. - Weight::from_ref_time(44_114_539 as u64) - // Standard Error: 958 - .saturating_add(Weight::from_ref_time(56_239 as u64).saturating_mul(l as u64)) - // Standard Error: 1_704 - .saturating_add(Weight::from_ref_time(64_926 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `444 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `7306` + // Minimum execution time: 28_062 nanoseconds. + Weight::from_parts(26_857_563, 7306) + // Standard Error: 623 + .saturating_add(Weight::from_ref_time(55_988).saturating_mul(l.into())) + // Standard Error: 1_109 + .saturating_add(Weight::from_ref_time(59_714).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 43_918 nanoseconds. - Weight::from_ref_time(43_452_573 as u64) - // Standard Error: 984 - .saturating_add(Weight::from_ref_time(50_162 as u64).saturating_mul(l as u64)) - // Standard Error: 1_752 - .saturating_add(Weight::from_ref_time(42_080 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `444 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `7306` + // Minimum execution time: 27_027 nanoseconds. + Weight::from_parts(26_509_364, 7306) + // Standard Error: 815 + .saturating_add(Weight::from_ref_time(54_711).saturating_mul(l.into())) + // Standard Error: 1_451 + .saturating_add(Weight::from_ref_time(32_792).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 43_603 nanoseconds. - Weight::from_ref_time(42_696_097 as u64) - // Standard Error: 996 - .saturating_add(Weight::from_ref_time(65_316 as u64).saturating_mul(l as u64)) - // Standard Error: 1_772 - .saturating_add(Weight::from_ref_time(65_862 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `579 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 29_554 nanoseconds. + Weight::from_parts(28_269_203, 9909) + // Standard Error: 623 + .saturating_add(Weight::from_ref_time(59_058).saturating_mul(l.into())) + // Standard Error: 1_108 + .saturating_add(Weight::from_ref_time(63_429).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 43_099 nanoseconds. - Weight::from_ref_time(42_937_914 as u64) - // Standard Error: 884 - .saturating_add(Weight::from_ref_time(52_079 as u64).saturating_mul(l as u64)) - // Standard Error: 1_573 - .saturating_add(Weight::from_ref_time(36_274 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `579 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 28_546 nanoseconds. + Weight::from_parts(28_299_251, 9909) + // Standard Error: 786 + .saturating_add(Weight::from_ref_time(53_401).saturating_mul(l.into())) + // Standard Error: 1_399 + .saturating_add(Weight::from_ref_time(29_713).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 59_023 nanoseconds. - Weight::from_ref_time(59_606_862 as u64) - // Standard Error: 2_078 - .saturating_add(Weight::from_ref_time(55_335 as u64).saturating_mul(l as u64)) - // Standard Error: 3_698 - .saturating_add(Weight::from_ref_time(26_743 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `650 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 43_436 nanoseconds. + Weight::from_parts(44_885_707, 9909) + // Standard Error: 1_516 + .saturating_add(Weight::from_ref_time(59_066).saturating_mul(l.into())) + // Standard Error: 2_698 + .saturating_add(Weight::from_ref_time(32_053).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 58_249 nanoseconds. - Weight::from_ref_time(59_025_976 as u64) - // Standard Error: 2_078 - .saturating_add(Weight::from_ref_time(55_736 as u64).saturating_mul(l as u64)) - // Standard Error: 3_697 - .saturating_add(Weight::from_ref_time(24_903 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `785 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12512` + // Minimum execution time: 45_805 nanoseconds. + Weight::from_parts(46_869_490, 12512) + // Standard Error: 1_445 + .saturating_add(Weight::from_ref_time(52_654).saturating_mul(l.into())) + // Standard Error: 2_571 + .saturating_add(Weight::from_ref_time(34_202).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 45_279 nanoseconds. - Weight::from_ref_time(44_197_440 as u64) - // Standard Error: 946 - .saturating_add(Weight::from_ref_time(62_308 as u64).saturating_mul(l as u64)) - // Standard Error: 1_747 - .saturating_add(Weight::from_ref_time(64_473 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `577 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 30_460 nanoseconds. + Weight::from_parts(29_407_637, 9909) + // Standard Error: 794 + .saturating_add(Weight::from_ref_time(63_757).saturating_mul(l.into())) + // Standard Error: 1_466 + .saturating_add(Weight::from_ref_time(56_032).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 44_925 nanoseconds. - Weight::from_ref_time(44_219_676 as u64) - // Standard Error: 889 - .saturating_add(Weight::from_ref_time(60_311 as u64).saturating_mul(l as u64)) - // Standard Error: 1_641 - .saturating_add(Weight::from_ref_time(63_095 as u64).saturating_mul(s as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `577 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 30_413 nanoseconds. + Weight::from_parts(29_350_467, 9909) + // Standard Error: 724 + .saturating_add(Weight::from_ref_time(65_366).saturating_mul(l.into())) + // Standard Error: 1_337 + .saturating_add(Weight::from_ref_time(53_799).saturating_mul(s.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_locked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 45_113 nanoseconds. - Weight::from_ref_time(44_114_539 as u64) - // Standard Error: 958 - .saturating_add(Weight::from_ref_time(56_239 as u64).saturating_mul(l as u64)) - // Standard Error: 1_704 - .saturating_add(Weight::from_ref_time(64_926 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `444 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `7306` + // Minimum execution time: 28_062 nanoseconds. + Weight::from_parts(26_857_563, 7306) + // Standard Error: 623 + .saturating_add(Weight::from_ref_time(55_988).saturating_mul(l.into())) + // Standard Error: 1_109 + .saturating_add(Weight::from_ref_time(59_714).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_unlocked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 43_918 nanoseconds. - Weight::from_ref_time(43_452_573 as u64) - // Standard Error: 984 - .saturating_add(Weight::from_ref_time(50_162 as u64).saturating_mul(l as u64)) - // Standard Error: 1_752 - .saturating_add(Weight::from_ref_time(42_080 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Proof Size summary in bytes: + // Measured: `444 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `7306` + // Minimum execution time: 27_027 nanoseconds. + Weight::from_parts(26_509_364, 7306) + // Standard Error: 815 + .saturating_add(Weight::from_ref_time(54_711).saturating_mul(l.into())) + // Standard Error: 1_451 + .saturating_add(Weight::from_ref_time(32_792).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_locked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 43_603 nanoseconds. - Weight::from_ref_time(42_696_097 as u64) - // Standard Error: 996 - .saturating_add(Weight::from_ref_time(65_316 as u64).saturating_mul(l as u64)) - // Standard Error: 1_772 - .saturating_add(Weight::from_ref_time(65_862 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `579 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 29_554 nanoseconds. + Weight::from_parts(28_269_203, 9909) + // Standard Error: 623 + .saturating_add(Weight::from_ref_time(59_058).saturating_mul(l.into())) + // Standard Error: 1_108 + .saturating_add(Weight::from_ref_time(63_429).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[1, 28]`. fn vest_other_unlocked(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 43_099 nanoseconds. - Weight::from_ref_time(42_937_914 as u64) - // Standard Error: 884 - .saturating_add(Weight::from_ref_time(52_079 as u64).saturating_mul(l as u64)) - // Standard Error: 1_573 - .saturating_add(Weight::from_ref_time(36_274 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `579 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 28_546 nanoseconds. + Weight::from_parts(28_299_251, 9909) + // Standard Error: 786 + .saturating_add(Weight::from_ref_time(53_401).saturating_mul(l.into())) + // Standard Error: 1_399 + .saturating_add(Weight::from_ref_time(29_713).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn vested_transfer(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 59_023 nanoseconds. - Weight::from_ref_time(59_606_862 as u64) - // Standard Error: 2_078 - .saturating_add(Weight::from_ref_time(55_335 as u64).saturating_mul(l as u64)) - // Standard Error: 3_698 - .saturating_add(Weight::from_ref_time(26_743 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `650 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 43_436 nanoseconds. + Weight::from_parts(44_885_707, 9909) + // Standard Error: 1_516 + .saturating_add(Weight::from_ref_time(59_066).saturating_mul(l.into())) + // Standard Error: 2_698 + .saturating_add(Weight::from_ref_time(32_053).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: System Account (r:2 w:2) - // Storage: Balances Locks (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[0, 27]`. fn force_vested_transfer(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 58_249 nanoseconds. - Weight::from_ref_time(59_025_976 as u64) - // Standard Error: 2_078 - .saturating_add(Weight::from_ref_time(55_736 as u64).saturating_mul(l as u64)) - // Standard Error: 3_697 - .saturating_add(Weight::from_ref_time(24_903 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Proof Size summary in bytes: + // Measured: `785 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `12512` + // Minimum execution time: 45_805 nanoseconds. + Weight::from_parts(46_869_490, 12512) + // Standard Error: 1_445 + .saturating_add(Weight::from_ref_time(52_654).saturating_mul(l.into())) + // Standard Error: 2_571 + .saturating_add(Weight::from_ref_time(34_202).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 45_279 nanoseconds. - Weight::from_ref_time(44_197_440 as u64) - // Standard Error: 946 - .saturating_add(Weight::from_ref_time(62_308 as u64).saturating_mul(l as u64)) - // Standard Error: 1_747 - .saturating_add(Weight::from_ref_time(64_473 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `577 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 30_460 nanoseconds. + Weight::from_parts(29_407_637, 9909) + // Standard Error: 794 + .saturating_add(Weight::from_ref_time(63_757).saturating_mul(l.into())) + // Standard Error: 1_466 + .saturating_add(Weight::from_ref_time(56_032).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Vesting Vesting (r:1 w:1) - // Storage: Balances Locks (r:1 w:1) - // Storage: System Account (r:1 w:1) + /// Storage: Vesting Vesting (r:1 w:1) + /// Proof: Vesting Vesting (max_values: None, max_size: Some(1057), added: 3532, mode: MaxEncodedLen) + /// Storage: Balances Locks (r:1 w:1) + /// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// The range of component `l` is `[0, 49]`. /// The range of component `s` is `[2, 28]`. fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight { - // Minimum execution time: 44_925 nanoseconds. - Weight::from_ref_time(44_219_676 as u64) - // Standard Error: 889 - .saturating_add(Weight::from_ref_time(60_311 as u64).saturating_mul(l as u64)) - // Standard Error: 1_641 - .saturating_add(Weight::from_ref_time(63_095 as u64).saturating_mul(s as u64)) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Proof Size summary in bytes: + // Measured: `577 + l * (25 ±0) + s * (36 ±0)` + // Estimated: `9909` + // Minimum execution time: 30_413 nanoseconds. + Weight::from_parts(29_350_467, 9909) + // Standard Error: 724 + .saturating_add(Weight::from_ref_time(65_366).saturating_mul(l.into())) + // Standard Error: 1_337 + .saturating_add(Weight::from_ref_time(53_799).saturating_mul(s.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } } diff --git a/frame/whitelist/src/benchmarking.rs b/frame/whitelist/src/benchmarking.rs index 923adc6ccf..569b13c12d 100644 --- a/frame/whitelist/src/benchmarking.rs +++ b/frame/whitelist/src/benchmarking.rs @@ -62,6 +62,10 @@ benchmarks! { // We benchmark with the maximum possible size for a call. // If the resulting weight is too big, maybe it worth having a weight which depends // on the size of the call, with a new witness in parameter. + #[pov_mode = MaxEncodedLen { + // Use measured PoV size for the Preimages since we pass in a length witness. + Preimage::PreimageFor: Measured + }] dispatch_whitelisted_call { // NOTE: we remove `10` because we need some bytes to encode the variants and vec length let n in 1 .. T::Preimages::MAX_LENGTH as u32 - 10; diff --git a/frame/whitelist/src/weights.rs b/frame/whitelist/src/weights.rs index efd48d6578..d5bc37c575 100644 --- a/frame/whitelist/src/weights.rs +++ b/frame/whitelist/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2023 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,25 +18,25 @@ //! Autogenerated weights for pallet_whitelist //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! DATE: 2023-01-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// /home/benchbot/cargo_target_dir/production/substrate +// ./target/production/substrate // benchmark // pallet +// --chain=dev // --steps=50 // --repeat=20 +// --pallet=pallet_whitelist // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/substrate/.git/.artifacts/bench.json -// --pallet=pallet_whitelist -// --chain=dev -// --header=./HEADER-APACHE2 // --output=./frame/whitelist/src/weights.rs +// --header=./HEADER-APACHE2 // --template=./.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -57,86 +57,130 @@ pub trait WeightInfo { /// Weights for pallet_whitelist using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn whitelist_call() -> Weight { - // Minimum execution time: 26_261 nanoseconds. - Weight::from_ref_time(26_842_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `217` + // Estimated: `5081` + // Minimum execution time: 18_618 nanoseconds. + Weight::from_parts(19_133_000, 5081) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn remove_whitelisted_call() -> Weight { - // Minimum execution time: 25_092 nanoseconds. - Weight::from_ref_time(25_903_000) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `346` + // Estimated: `5081` + // Minimum execution time: 16_685 nanoseconds. + Weight::from_parts(17_325_000, 5081) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `n` is `[1, 4194294]`. fn dispatch_whitelisted_call(n: u32, ) -> Weight { - // Minimum execution time: 36_685 nanoseconds. - Weight::from_ref_time(37_167_000) + // Proof Size summary in bytes: + // Measured: `454 + n * (1 ±0)` + // Estimated: `8007 + n * (1 ±0)` + // Minimum execution time: 27_539 nanoseconds. + Weight::from_parts(27_950_000, 8007) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_144).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(Weight::from_ref_time(1_134).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(n.into())) } - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `n` is `[1, 10000]`. fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { - // Minimum execution time: 29_187 nanoseconds. - Weight::from_ref_time(29_896_714) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(1_505).saturating_mul(n.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `346` + // Estimated: `5081` + // Minimum execution time: 20_581 nanoseconds. + Weight::from_parts(21_762_318, 5081) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(1_480).saturating_mul(n.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn whitelist_call() -> Weight { - // Minimum execution time: 26_261 nanoseconds. - Weight::from_ref_time(26_842_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `217` + // Estimated: `5081` + // Minimum execution time: 18_618 nanoseconds. + Weight::from_parts(19_133_000, 5081) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn remove_whitelisted_call() -> Weight { - // Minimum execution time: 25_092 nanoseconds. - Weight::from_ref_time(25_903_000) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `346` + // Estimated: `5081` + // Minimum execution time: 16_685 nanoseconds. + Weight::from_parts(17_325_000, 5081) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage PreimageFor (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage PreimageFor (r:1 w:1) + /// Proof: Preimage PreimageFor (max_values: None, max_size: Some(4194344), added: 4196819, mode: Measured) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `n` is `[1, 4194294]`. fn dispatch_whitelisted_call(n: u32, ) -> Weight { - // Minimum execution time: 36_685 nanoseconds. - Weight::from_ref_time(37_167_000) + // Proof Size summary in bytes: + // Measured: `454 + n * (1 ±0)` + // Estimated: `8007 + n * (1 ±0)` + // Minimum execution time: 27_539 nanoseconds. + Weight::from_parts(27_950_000, 8007) // Standard Error: 0 - .saturating_add(Weight::from_ref_time(1_144).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(Weight::from_ref_time(1_134).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_proof_size(1).saturating_mul(n.into())) } - // Storage: Whitelist WhitelistedCall (r:1 w:1) - // Storage: Preimage StatusFor (r:1 w:1) + /// Storage: Whitelist WhitelistedCall (r:1 w:1) + /// Proof: Whitelist WhitelistedCall (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen) + /// Storage: Preimage StatusFor (r:1 w:1) + /// Proof: Preimage StatusFor (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// The range of component `n` is `[1, 10000]`. fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight { - // Minimum execution time: 29_187 nanoseconds. - Weight::from_ref_time(29_896_714) - // Standard Error: 6 - .saturating_add(Weight::from_ref_time(1_505).saturating_mul(n.into())) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + // Proof Size summary in bytes: + // Measured: `346` + // Estimated: `5081` + // Minimum execution time: 20_581 nanoseconds. + Weight::from_parts(21_762_318, 5081) + // Standard Error: 4 + .saturating_add(Weight::from_ref_time(1_480).saturating_mul(n.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } } diff --git a/primitives/storage/src/lib.rs b/primitives/storage/src/lib.rs index 237787710a..68d7b90639 100644 --- a/primitives/storage/src/lib.rs +++ b/primitives/storage/src/lib.rs @@ -200,6 +200,8 @@ pub mod well_known_keys { pub const HEAP_PAGES: &[u8] = b":heappages"; /// Current extrinsic index (u32) is stored under this key. + /// + /// Encodes to `0x3a65787472696e7369635f696e646578`. pub const EXTRINSIC_INDEX: &[u8] = b":extrinsic_index"; /// Prefix of child storage keys. diff --git a/scripts/run_all_benchmarks.sh b/scripts/run_all_benchmarks.sh index dd5d2e182b..f122be577c 100755 --- a/scripts/run_all_benchmarks.sh +++ b/scripts/run_all_benchmarks.sh @@ -74,6 +74,8 @@ EXCLUDED_PALLETS=( "pallet_grandpa" "pallet_mmr" "pallet_offences" + # Only used for testing, does not need real weights. + "frame_benchmarking_pallet_pov" ) # Load all pallet names in an array. diff --git a/utils/frame/benchmarking-cli/src/pallet/command.rs b/utils/frame/benchmarking-cli/src/pallet/command.rs index 242f0e6852..ec1be27614 100644 --- a/utils/frame/benchmarking-cli/src/pallet/command.rs +++ b/utils/frame/benchmarking-cli/src/pallet/command.rs @@ -38,7 +38,7 @@ use sp_externalities::Extensions; use sp_keystore::{testing::KeyStore, KeystoreExt, SyncCryptoStorePtr}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_state_machine::StateMachine; -use std::{collections::HashMap, fmt::Debug, fs, sync::Arc, time}; +use std::{collections::HashMap, fmt::Debug, fs, str::FromStr, sync::Arc, time}; /// Logging target const LOG_TARGET: &'static str = "frame::benchmark::pallet"; @@ -54,6 +54,34 @@ pub(crate) struct ComponentRange { max: u32, } +/// How the PoV size of a storage item should be estimated. +#[derive(clap::ValueEnum, Debug, Eq, PartialEq, Clone, Copy)] +pub enum PovEstimationMode { + /// Use the maximal encoded length as provided by [`codec::MaxEncodedLen`]. + MaxEncodedLen, + /// Measure the accessed value size in the pallet benchmarking and add some trie overhead. + Measured, + /// Do not estimate the PoV size for this storage item or benchmark. + Ignored, +} + +impl FromStr for PovEstimationMode { + type Err = &'static str; + + fn from_str(s: &str) -> std::result::Result { + match s { + "MaxEncodedLen" => Ok(Self::MaxEncodedLen), + "Measured" => Ok(Self::Measured), + "Ignored" => Ok(Self::Ignored), + _ => unreachable!("The benchmark! macro should have prevented this"), + } + } +} + +/// Maps (pallet, benchmark) -> ((pallet, storage) -> PovEstimationMode) +pub(crate) type PovModesMap = + HashMap<(Vec, Vec), HashMap<(String, String), PovEstimationMode>>; + // This takes multiple benchmark batches and combines all the results where the pallet, instance, // and benchmark are the same. fn combine_batches( @@ -165,11 +193,19 @@ impl PalletCmd { let state_with_tracking = BenchmarkingState::::new( genesis_storage.clone(), cache_size, - self.record_proof, + // Record proof size + true, + // Enable storage tracking true, )?; - let state_without_tracking = - BenchmarkingState::::new(genesis_storage, cache_size, self.record_proof, false)?; + let state_without_tracking = BenchmarkingState::::new( + genesis_storage, + cache_size, + // Do not record proof size + false, + // Do not enable storage tracking + false, + )?; let executor = NativeElseWasmExecutor::::new( execution_method_from_cli(self.wasm_method, self.wasmtime_instantiation_strategy), self.heap_pages, @@ -222,10 +258,27 @@ impl PalletCmd { item.pallet.clone(), benchmark.name.clone(), benchmark.components.clone(), + benchmark.pov_modes.clone(), )) } } }); + // Convert `Vec` to `String` for better readability. + let benchmarks_to_run: Vec<_> = benchmarks_to_run + .into_iter() + .map(|b| { + ( + b.0, + b.1, + b.2, + b.3.into_iter() + .map(|(p, s)| { + (String::from_utf8(p).unwrap(), String::from_utf8(s).unwrap()) + }) + .collect(), + ) + }) + .collect(); if benchmarks_to_run.is_empty() { return Err("No benchmarks found which match your input.".into()) @@ -243,8 +296,9 @@ impl PalletCmd { let mut timer = time::SystemTime::now(); // Maps (pallet, extrinsic) to its component ranges. let mut component_ranges = HashMap::<(Vec, Vec), Vec>::new(); + let pov_modes = Self::parse_pov_modes(&benchmarks_to_run)?; - for (pallet, extrinsic, components) in benchmarks_to_run { + for (pallet, extrinsic, components, _) in benchmarks_to_run.clone() { log::info!( target: LOG_TARGET, "Starting benchmark: {}::{}", @@ -429,7 +483,7 @@ impl PalletCmd { // Combine all of the benchmark results, so that benchmarks of the same pallet/function // are together. let batches = combine_batches(batches, batches_db); - self.output(&batches, &storage_info, &component_ranges) + self.output(&batches, &storage_info, &component_ranges, pov_modes) } fn output( @@ -437,21 +491,31 @@ impl PalletCmd { batches: &[BenchmarkBatchSplitResults], storage_info: &[StorageInfo], component_ranges: &HashMap<(Vec, Vec), Vec>, + pov_modes: PovModesMap, ) -> Result<()> { // Jsonify the result and write it to a file or stdout if desired. if !self.jsonify(&batches)? { // Print the summary only if `jsonify` did not write to stdout. - self.print_summary(&batches, &storage_info) + self.print_summary(&batches, &storage_info, pov_modes.clone()) } // Create the weights.rs file. if let Some(output_path) = &self.output { - writer::write_results(&batches, &storage_info, &component_ranges, output_path, self)?; + writer::write_results( + &batches, + &storage_info, + &component_ranges, + pov_modes, + self.default_pov_mode, + output_path, + self, + )?; } Ok(()) } + /// Re-analyze a batch historic benchmark timing data. Will not take the PoV into account. fn output_from_results(&self, batches: &[BenchmarkBatchSplitResults]) -> Result<()> { let mut component_ranges = HashMap::<(Vec, Vec), HashMap>::new(); @@ -484,7 +548,7 @@ impl PalletCmd { }) .collect(); - self.output(batches, &[], &component_ranges) + self.output(batches, &[], &component_ranges, Default::default()) } /// Jsonifies the passed batches and writes them to stdout or into a file. @@ -507,7 +571,12 @@ impl PalletCmd { } /// Prints the results as human-readable summary without raw timing data. - fn print_summary(&self, batches: &[BenchmarkBatchSplitResults], storage_info: &[StorageInfo]) { + fn print_summary( + &self, + batches: &[BenchmarkBatchSplitResults], + storage_info: &[StorageInfo], + pov_modes: PovModesMap, + ) { for batch in batches.iter() { // Print benchmark metadata println!( @@ -526,13 +595,32 @@ impl PalletCmd { } if !self.no_storage_info { - let mut comments: Vec = Default::default(); - writer::add_storage_comments(&mut comments, &batch.db_results, storage_info); + let mut storage_per_prefix = HashMap::, Vec>::new(); + let pov_mode = pov_modes + .get(&(batch.pallet.clone(), batch.benchmark.clone())) + .cloned() + .unwrap_or_default(); + + let comments = writer::process_storage_results( + &mut storage_per_prefix, + &batch.db_results, + storage_info, + &pov_mode, + self.default_pov_mode, + self.worst_case_map_values, + self.additional_trie_layers, + ); println!("Raw Storage Info\n========"); for comment in comments { println!("{}", comment); } println!(); + + println!("-- Proof Sizes --\n"); + for result in batch.db_results.iter() { + println!("{} bytes", result.proof_size); + } + println!(); } // Conduct analysis. @@ -553,6 +641,11 @@ impl PalletCmd { { println!("Writes = {:?}", analysis); } + if let Some(analysis) = + Analysis::median_slopes(&batch.db_results, BenchmarkSelector::ProofSize) + { + println!("Recorded proof Size = {:?}", analysis); + } println!(); } if !self.no_min_squares { @@ -572,10 +665,60 @@ impl PalletCmd { { println!("Writes = {:?}", analysis); } + if let Some(analysis) = + Analysis::min_squares_iqr(&batch.db_results, BenchmarkSelector::ProofSize) + { + println!("Recorded proof Size = {:?}", analysis); + } println!(); } } } + + /// Parses the PoV modes per benchmark that were specified by the `#[pov_mode]` attribute. + fn parse_pov_modes( + benchmarks: &Vec<( + Vec, + Vec, + Vec<(BenchmarkParameter, u32, u32)>, + Vec<(String, String)>, + )>, + ) -> Result { + use std::collections::hash_map::Entry; + let mut parsed = PovModesMap::new(); + + for (pallet, call, _components, pov_modes) in benchmarks { + for (pallet_storage, mode) in pov_modes { + let mode = PovEstimationMode::from_str(&mode)?; + let splits = pallet_storage.split("::").collect::>(); + if splits.is_empty() || splits.len() > 2 { + return Err(format!( + "Expected 'Pallet::Storage' as storage name but got: {}", + pallet_storage + ) + .into()) + } + let (pov_pallet, pov_storage) = (splits[0], splits.get(1).unwrap_or(&"ALL")); + + match parsed + .entry((pallet.clone(), call.clone())) + .or_default() + .entry((pov_pallet.to_string(), pov_storage.to_string())) + { + Entry::Occupied(_) => + return Err(format!( + "Cannot specify pov_mode tag twice for the same key: {}", + pallet_storage + ) + .into()), + Entry::Vacant(e) => { + e.insert(mode); + }, + } + } + } + Ok(parsed) + } } impl CliConfiguration for PalletCmd { @@ -592,9 +735,16 @@ impl CliConfiguration for PalletCmd { } /// List the benchmarks available in the runtime, in a CSV friendly format. -fn list_benchmark(benchmarks_to_run: Vec<(Vec, Vec, Vec<(BenchmarkParameter, u32, u32)>)>) { +fn list_benchmark( + benchmarks_to_run: Vec<( + Vec, + Vec, + Vec<(BenchmarkParameter, u32, u32)>, + Vec<(String, String)>, + )>, +) { println!("pallet, benchmark"); - for (pallet, extrinsic, _components) in benchmarks_to_run { + for (pallet, extrinsic, _, _) in benchmarks_to_run { println!("{}, {}", String::from_utf8_lossy(&pallet), String::from_utf8_lossy(&extrinsic)); } } diff --git a/utils/frame/benchmarking-cli/src/pallet/mod.rs b/utils/frame/benchmarking-cli/src/pallet/mod.rs index b10f531bc0..1fcf0cc115 100644 --- a/utils/frame/benchmarking-cli/src/pallet/mod.rs +++ b/utils/frame/benchmarking-cli/src/pallet/mod.rs @@ -103,6 +103,14 @@ pub struct PalletCmd { #[arg(long)] pub output_analysis: Option, + /// Which analysis function to use when analyzing measured proof sizes. + #[arg(long, default_value("median-slopes"))] + pub output_pov_analysis: Option, + + /// The PoV estimation mode of a benchmark if no `pov_mode` attribute is present. + #[arg(long, default_value("max-encoded-len"), value_enum)] + pub default_pov_mode: command::PovEstimationMode, + /// Set the heap pages while running benchmarks. If not set, the default value from the client /// is used. #[arg(long)] @@ -117,10 +125,6 @@ pub struct PalletCmd { #[arg(long)] pub extra: bool, - /// Estimate PoV size. - #[arg(long)] - pub record_proof: bool, - #[allow(missing_docs)] #[clap(flatten)] pub shared_params: sc_cli::SharedParams, @@ -167,6 +171,25 @@ pub struct PalletCmd { #[arg(long)] pub no_storage_info: bool, + /// The assumed default maximum size of any `StorageMap`. + /// + /// When the maximum size of a map is not defined by the runtime developer, + /// this value is used as a worst case scenario. It will affect the calculated worst case + /// PoV size for accessing a value in a map, since the PoV will need to include the trie + /// nodes down to the underlying value. + #[clap(long = "map-size", default_value = "1000000")] + pub worst_case_map_values: u32, + + /// Adjust the PoV estimation by adding additional trie layers to it. + /// + /// This should be set to `log16(n)` where `n` is the number of top-level storage items in the + /// runtime, eg. `StorageMap`s and `StorageValue`s. A value of 2 to 3 is usually sufficient. + /// Each layer will result in an additional 495 bytes PoV per distinct top-level access. + /// Therefore multiple `StorageMap` accesses only suffer from this increase once. The exact + /// number of storage items depends on the runtime and the deployed pallets. + #[clap(long, default_value = "0")] + pub additional_trie_layers: u8, + /// A path to a `.json` file with existing benchmark results generated with `--json` or /// `--json-file`. When specified the benchmarks are not actually executed, and the data for /// the analysis is read from this file. diff --git a/utils/frame/benchmarking-cli/src/pallet/template.hbs b/utils/frame/benchmarking-cli/src/pallet/template.hbs index 1a69a3ae20..00dd1a3532 100644 --- a/utils/frame/benchmarking-cli/src/pallet/template.hbs +++ b/utils/frame/benchmarking-cli/src/pallet/template.hbs @@ -2,7 +2,8 @@ //! Autogenerated weights for `{{pallet}}` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} -//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}` //! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` //! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} @@ -23,7 +24,7 @@ pub struct WeightInfo(PhantomData); impl {{pallet}}::WeightInfo for WeightInfo { {{#each benchmarks as |benchmark|}} {{#each benchmark.comments as |comment|}} - // {{comment}} + /// {{comment}} {{/each}} {{#each benchmark.component_ranges as |range|}} /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. @@ -33,8 +34,15 @@ impl {{pallet}}::WeightInfo for WeightInfo { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { + // Proof Size summary in bytes: + // Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. + {{#if (ne benchmark.base_calculated_proof_size "0")}} + Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}}) + {{else}} Weight::from_ref_time({{underscore benchmark.base_weight}}) + {{/if}} {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) @@ -51,6 +59,9 @@ impl {{pallet}}::WeightInfo for WeightInfo { {{#each benchmark.component_writes as |cw|}} .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} + {{#each benchmark.component_calculated_proof_size as |cp|}} + .saturating_add(Weight::from_proof_size({{cp.slope}}).saturating_mul({{cp.name}}.into())) + {{/each}} } {{/each}} } diff --git a/utils/frame/benchmarking-cli/src/pallet/writer.rs b/utils/frame/benchmarking-cli/src/pallet/writer.rs index a52bbcd229..9359b27255 100644 --- a/utils/frame/benchmarking-cli/src/pallet/writer.rs +++ b/utils/frame/benchmarking-cli/src/pallet/writer.rs @@ -27,7 +27,11 @@ use inflector::Inflector; use itertools::Itertools; use serde::Serialize; -use crate::{pallet::command::ComponentRange, shared::UnderscoreHelper, PalletCmd}; +use crate::{ + pallet::command::{ComponentRange, PovEstimationMode, PovModesMap}, + shared::UnderscoreHelper, + PalletCmd, +}; use frame_benchmarking::{ Analysis, AnalysisChoice, BenchmarkBatchSplitResults, BenchmarkResult, BenchmarkSelector, }; @@ -54,7 +58,7 @@ struct TemplateData { } // This was the final data we have about each benchmark. -#[derive(Serialize, Default, Debug, Clone)] +#[derive(Serialize, Default, Debug, Clone, PartialEq)] struct BenchmarkData { name: String, components: Vec, @@ -64,9 +68,15 @@ struct BenchmarkData { base_reads: u128, #[serde(serialize_with = "string_serialize")] base_writes: u128, + #[serde(serialize_with = "string_serialize")] + base_calculated_proof_size: u128, + #[serde(serialize_with = "string_serialize")] + base_recorded_proof_size: u128, component_weight: Vec, component_reads: Vec, component_writes: Vec, + component_calculated_proof_size: Vec, + component_recorded_proof_size: Vec, component_ranges: Vec, comments: Vec, #[serde(serialize_with = "string_serialize")] @@ -85,6 +95,8 @@ struct CmdData { chain: String, db_cache: u32, analysis_choice: String, + worst_case_map_values: u32, + additional_trie_layers: u8, } // This encodes the component name and whether that component is used. @@ -122,7 +134,12 @@ fn map_results( batches: &[BenchmarkBatchSplitResults], storage_info: &[StorageInfo], component_ranges: &HashMap<(Vec, Vec), Vec>, + pov_modes: PovModesMap, + default_pov_mode: PovEstimationMode, analysis_choice: &AnalysisChoice, + pov_analysis_choice: &AnalysisChoice, + worst_case_map_values: u32, + additional_trie_layers: u8, ) -> Result>, std::io::Error> { // Skip if batches is empty. if batches.is_empty() { @@ -139,8 +156,17 @@ fn map_results( let pallet_string = String::from_utf8(batch.pallet.clone()).unwrap(); let instance_string = String::from_utf8(batch.instance.clone()).unwrap(); - let benchmark_data = - get_benchmark_data(batch, storage_info, &component_ranges, analysis_choice); + let benchmark_data = get_benchmark_data( + batch, + storage_info, + &component_ranges, + pov_modes.clone(), + default_pov_mode, + analysis_choice, + pov_analysis_choice, + worst_case_map_values, + additional_trie_layers, + ); let pallet_benchmarks = all_benchmarks.entry((pallet_string, instance_string)).or_default(); pallet_benchmarks.push(benchmark_data); } @@ -164,17 +190,24 @@ fn get_benchmark_data( storage_info: &[StorageInfo], // Per extrinsic component ranges. component_ranges: &HashMap<(Vec, Vec), Vec>, + pov_modes: PovModesMap, + default_pov_mode: PovEstimationMode, analysis_choice: &AnalysisChoice, + pov_analysis_choice: &AnalysisChoice, + worst_case_map_values: u32, + additional_trie_layers: u8, ) -> BenchmarkData { - // You can use this to put any additional comments with the benchmarking output. - let mut comments = Vec::::new(); - // Analyze benchmarks to get the linear regression. let analysis_function = match analysis_choice { AnalysisChoice::MinSquares => Analysis::min_squares_iqr, AnalysisChoice::MedianSlopes => Analysis::median_slopes, AnalysisChoice::Max => Analysis::max, }; + let pov_analysis_function = match pov_analysis_choice { + AnalysisChoice::MinSquares => Analysis::min_squares_iqr, + AnalysisChoice::MedianSlopes => Analysis::median_slopes, + AnalysisChoice::Max => Analysis::max, + }; let extrinsic_time = analysis_function(&batch.time_results, BenchmarkSelector::ExtrinsicTime) .expect("analysis function should return an extrinsic time for valid inputs"); @@ -182,6 +215,9 @@ fn get_benchmark_data( .expect("analysis function should return the number of reads for valid inputs"); let writes = analysis_function(&batch.db_results, BenchmarkSelector::Writes) .expect("analysis function should return the number of writes for valid inputs"); + let recorded_proof_size = + pov_analysis_function(&batch.db_results, BenchmarkSelector::ProofSize) + .expect("analysis function should return proof sizes for valid inputs"); // Analysis data may include components that are not used, this filters out anything whose value // is zero. @@ -189,6 +225,8 @@ fn get_benchmark_data( let mut used_extrinsic_time = Vec::new(); let mut used_reads = Vec::new(); let mut used_writes = Vec::new(); + let mut used_calculated_proof_size = Vec::::new(); + let mut used_recorded_proof_size = Vec::::new(); extrinsic_time .slopes @@ -229,6 +267,76 @@ fn get_benchmark_data( used_writes.push(ComponentSlope { name: name.clone(), slope, error }); } }); + recorded_proof_size + .slopes + .into_iter() + .zip(recorded_proof_size.names.iter()) + .zip(extract_errors(&recorded_proof_size.errors)) + .for_each(|((slope, name), error)| { + if !slope.is_zero() { + // These are only for comments, so don't touch the `used_components`. + used_recorded_proof_size.push(ComponentSlope { name: name.clone(), slope, error }); + } + }); + + // We add additional comments showing which storage items were touched. + // We find the worst case proof size, and use that as the final proof size result. + let mut storage_per_prefix = HashMap::, Vec>::new(); + let pov_mode = pov_modes + .get(&(batch.pallet.clone(), batch.benchmark.clone())) + .cloned() + .unwrap_or_default(); + let comments = process_storage_results( + &mut storage_per_prefix, + &batch.db_results, + storage_info, + &pov_mode, + default_pov_mode, + worst_case_map_values, + additional_trie_layers, + ); + + let proof_size_per_components = storage_per_prefix + .iter() + .map(|(prefix, results)| { + let proof_size = analysis_function(results, BenchmarkSelector::ProofSize) + .expect("analysis function should return proof sizes for valid inputs"); + let slope = proof_size + .slopes + .into_iter() + .zip(proof_size.names.iter()) + .zip(extract_errors(&proof_size.errors)) + .map(|((slope, name), error)| ComponentSlope { name: name.clone(), slope, error }) + .collect::>(); + (prefix.clone(), slope, proof_size.base) + }) + .collect::>(); + + let mut base_calculated_proof_size = 0; + // Sum up the proof sizes per component + for (_, slope, base) in proof_size_per_components.iter() { + base_calculated_proof_size += base; + for component in slope.iter() { + let mut found = false; + for used_component in used_calculated_proof_size.iter_mut() { + if used_component.name == component.name { + used_component.slope += component.slope; + found = true; + break + } + } + if !found && !component.slope.is_zero() { + if !used_components.contains(&&component.name) { + used_components.push(&component.name); + } + used_calculated_proof_size.push(ComponentSlope { + name: component.name.clone(), + slope: component.slope, + error: component.error, + }); + } + } + } // This puts a marker on any component which is entirely unused in the weight formula. let components = batch.time_results[0] @@ -241,8 +349,6 @@ fn get_benchmark_data( }) .collect::>(); - // We add additional comments showing which storage items were touched. - add_storage_comments(&mut comments, &batch.db_results, storage_info); let component_ranges = component_ranges .get(&(batch.pallet.clone(), batch.benchmark.clone())) .map(|c| c.clone()) @@ -254,9 +360,13 @@ fn get_benchmark_data( base_weight: extrinsic_time.base, base_reads: reads.base, base_writes: writes.base, + base_calculated_proof_size, + base_recorded_proof_size: recorded_proof_size.base, component_weight: used_extrinsic_time, component_reads: used_reads, component_writes: used_writes, + component_calculated_proof_size: used_calculated_proof_size, + component_recorded_proof_size: used_recorded_proof_size, component_ranges, comments, min_execution_time: extrinsic_time.minimum, @@ -268,6 +378,8 @@ pub(crate) fn write_results( batches: &[BenchmarkBatchSplitResults], storage_info: &[StorageInfo], component_ranges: &HashMap<(Vec, Vec), Vec>, + pov_modes: PovModesMap, + default_pov_mode: PovEstimationMode, path: &PathBuf, cmd: &PalletCmd, ) -> Result<(), std::io::Error> { @@ -295,6 +407,15 @@ pub(crate) fn write_results( // Which analysis function should be used when outputting benchmarks let analysis_choice: AnalysisChoice = cmd.output_analysis.clone().try_into().map_err(io_error)?; + let pov_analysis_choice: AnalysisChoice = + cmd.output_pov_analysis.clone().try_into().map_err(io_error)?; + + if cmd.additional_trie_layers > 4 { + println!( + "WARNING: `additional_trie_layers` is unexpectedly large. It assumes {} storage items.", + 16f64.powi(cmd.additional_trie_layers as i32) + ) + } // Capture individual args let cmd_data = CmdData { @@ -307,6 +428,8 @@ pub(crate) fn write_results( chain: format!("{:?}", cmd.shared_params.chain), db_cache: cmd.database_cache_size, analysis_choice: format!("{:?}", analysis_choice), + worst_case_map_values: cmd.worst_case_map_values, + additional_trie_layers: cmd.additional_trie_layers, }; // New Handlebars instance with helpers. @@ -317,7 +440,17 @@ pub(crate) fn write_results( handlebars.register_escape_fn(|s| -> String { s.to_string() }); // Organize results by pallet into a JSON map - let all_results = map_results(batches, storage_info, component_ranges, &analysis_choice)?; + let all_results = map_results( + batches, + storage_info, + component_ranges, + pov_modes, + default_pov_mode, + &analysis_choice, + &pov_analysis_choice, + cmd.worst_case_map_values, + cmd.additional_trie_layers, + )?; let mut created_files = Vec::new(); for ((pallet, instance), results) in all_results.iter() { @@ -365,14 +498,21 @@ pub(crate) fn write_results( Ok(()) } -// This function looks at the keys touched during the benchmark, and the storage info we collected -// from the pallets, and creates comments with information about the storage keys touched during -// each benchmark. -pub(crate) fn add_storage_comments( - comments: &mut Vec, +/// This function looks at the keys touched during the benchmark, and the storage info we collected +/// from the pallets, and creates comments with information about the storage keys touched during +/// each benchmark. +/// +/// It returns informational comments for human consumption. +pub(crate) fn process_storage_results( + storage_per_prefix: &mut HashMap, Vec>, results: &[BenchmarkResult], storage_info: &[StorageInfo], -) { + pov_modes: &HashMap<(String, String), PovEstimationMode>, + default_pov_mode: PovEstimationMode, + worst_case_map_values: u32, + additional_trie_layers: u8, +) -> Vec { + let mut comments = Vec::new(); let mut storage_info_map = storage_info .iter() .map(|info| (info.prefix.clone(), info)) @@ -399,48 +539,246 @@ pub(crate) fn add_storage_comments( storage_info_map.insert(benchmark_override.prefix.clone(), &benchmark_override); // This tracks the keys we already identified, so we only generate a single comment. - let mut identified = HashSet::>::new(); + let mut identified_prefix = HashSet::>::new(); + let mut identified_key = HashSet::>::new(); - for result in results { + // TODO Emit a warning for unused `pov_mode` attributes. + + // We have to iterate in reverse order to catch the largest values for read/write since the + // components start low and then increase and only the first value is used. + for result in results.iter().rev() { for (key, reads, writes, whitelisted) in &result.keys { // skip keys which are whitelisted if *whitelisted { continue } + let prefix_length = key.len().min(32); let prefix = key[0..prefix_length].to_vec(); - if identified.contains(&prefix) { - // skip adding comments for keys we already identified - continue - } else { - // track newly identified keys - identified.insert(prefix.clone()); + let is_key_identified = identified_key.contains(key); + let is_prefix_identified = identified_prefix.contains(&prefix); + + let mut prefix_result = result.clone(); + let key_info = storage_info_map.get(&prefix); + let max_size = key_info.and_then(|k| k.max_size); + + let override_pov_mode = match key_info { + Some(StorageInfo { pallet_name, storage_name, .. }) => { + let pallet_name = + String::from_utf8(pallet_name.clone()).expect("encoded from string"); + let storage_name = + String::from_utf8(storage_name.clone()).expect("encoded from string"); + + // Is there an override for the storage key? + pov_modes.get(&(pallet_name.clone(), storage_name)).or( + // .. or for the storage prefix? + pov_modes.get(&(pallet_name, "ALL".to_string())).or( + // .. or for the benchmark? + pov_modes.get(&("ALL".to_string(), "ALL".to_string())), + ), + ) + }, + None => None, + }; + let is_all_ignored = pov_modes.get(&("ALL".to_string(), "ALL".to_string())) == + Some(&PovEstimationMode::Ignored); + if is_all_ignored && override_pov_mode != Some(&PovEstimationMode::Ignored) { + panic!("The syntax currently does not allow to exclude single keys from a top-level `Ignored` pov-mode."); } - match storage_info_map.get(&prefix) { - Some(key_info) => { - let comment = format!( - "Storage: {} {} (r:{} w:{})", - String::from_utf8(key_info.pallet_name.clone()) - .expect("encoded from string"), - String::from_utf8(key_info.storage_name.clone()) - .expect("encoded from string"), - reads, - writes, - ); - comments.push(comment) + + let pov_overhead = single_read_pov_overhead( + key_info.and_then(|i| i.max_values), + worst_case_map_values, + ); + + let used_pov_mode = match (override_pov_mode, max_size, default_pov_mode) { + // All is ignored by default and no override: + (None, _, PovEstimationMode::Ignored) => { + prefix_result.proof_size = 0; + PovEstimationMode::Ignored + }, + // Some is ignored by override, maybe all: + (Some(PovEstimationMode::Ignored), _, _) => { + // If this is applied to All keys, then we also remove the base weight and just set all to zero. + if is_all_ignored { + prefix_result.proof_size = 0; + } else { + // Otherwise we just don't *increase* `proof_size` for this key. + } + PovEstimationMode::Ignored + }, + (Some(PovEstimationMode::Measured), _, _)| + (None, _, PovEstimationMode::Measured) | + // Use best effort in this case since failing would be really annoying. + (None, None, PovEstimationMode::MaxEncodedLen) => { + // We add the overhead for a single read each time. In a more advanced version + // we could take node re-using into account and over-estimate a bit less. + prefix_result.proof_size += pov_overhead * *reads; + PovEstimationMode::Measured + }, + (Some(PovEstimationMode::MaxEncodedLen), Some(max_size), _) | + (None, Some(max_size), PovEstimationMode::MaxEncodedLen) => { + prefix_result.proof_size = (pov_overhead + max_size) * *reads; + PovEstimationMode::MaxEncodedLen + }, + (Some(PovEstimationMode::MaxEncodedLen), None, _) => { + panic!("Key does not have MEL bound but MEL PoV estimation mode was specified {:?}", &key); + }, + }; + // Add the additional trie layer overhead for every new prefix. + if *reads > 0 { + prefix_result.proof_size += 15 * 33 * additional_trie_layers as u32; + } + storage_per_prefix.entry(prefix.clone()).or_default().push(prefix_result); + + match (is_key_identified, is_prefix_identified) { + // We already did everything, move on... + (true, true) => continue, + (false, true) => { + // track newly identified key + identified_key.insert(key.clone()); }, - None => { - let comment = format!( - "Storage: unknown [0x{}] (r:{} w:{})", - HexDisplay::from(key), - reads, - writes, - ); - comments.push(comment) + (false, false) => { + // track newly identified key and prefix + identified_key.insert(key.clone()); + identified_prefix.insert(prefix.clone()); }, + // Not possible. If the key is known, the prefix is too. + (true, false) => unreachable!(), + } + + // For any new prefix, we should write some comment about the number of reads and + // writes. + if !is_prefix_identified { + match key_info { + Some(key_info) => { + let comment = format!( + "Storage: {} {} (r:{} w:{})", + String::from_utf8(key_info.pallet_name.clone()) + .expect("encoded from string"), + String::from_utf8(key_info.storage_name.clone()) + .expect("encoded from string"), + reads, + writes, + ); + comments.push(comment) + }, + None => { + let comment = format!( + "Storage: unknown `0x{}` (r:{} w:{})", + HexDisplay::from(key), + reads, + writes, + ); + comments.push(comment) + }, + } + } + + // For any new key, we should add the PoV impact. + if !is_key_identified { + match key_info { + Some(key_info) => { + match worst_case_pov( + key_info.max_values, + key_info.max_size, + !is_prefix_identified, + worst_case_map_values, + ) { + Some(new_pov) => { + let comment = format!( + "Proof: {} {} (max_values: {:?}, max_size: {:?}, added: {}, mode: {:?})", + String::from_utf8(key_info.pallet_name.clone()) + .expect("encoded from string"), + String::from_utf8(key_info.storage_name.clone()) + .expect("encoded from string"), + key_info.max_values, + key_info.max_size, + new_pov, + used_pov_mode, + ); + comments.push(comment) + }, + None => { + let pallet = String::from_utf8(key_info.pallet_name.clone()) + .expect("encoded from string"); + let item = String::from_utf8(key_info.storage_name.clone()) + .expect("encoded from string"); + let comment = format!( + "Proof Skipped: {} {} (max_values: {:?}, max_size: {:?}, mode: {:?})", + pallet, item, key_info.max_values, key_info.max_size, + used_pov_mode, + ); + comments.push(comment); + }, + } + }, + None => { + let comment = format!( + "Proof Skipped: unknown `0x{}` (r:{} w:{})", + HexDisplay::from(key), + reads, + writes, + ); + comments.push(comment) + }, + } } } } + + comments +} + +/// The PoV overhead when reading a key the first time out of a map with `max_values` entries. +fn single_read_pov_overhead(max_values: Option, worst_case_map_values: u32) -> u32 { + let max_values = max_values.unwrap_or(worst_case_map_values); + let depth: u32 = easy_log_16(max_values); + // Normally we have 16 entries of 32 byte hashes per tree layer. In the new trie + // layout the hashes are prefixed by their compact length, hence 33 instead. The proof + // compaction can compress one node per layer since we send the value itself, + // therefore we end up with a size of `15 * 33` per layer. + depth * 15 * 33 +} + +/// Given the max values and max size of some storage item, calculate the worst +/// case PoV. +/// +/// # Arguments +/// * `max_values`: The maximum number of values in the storage item. `None` for unbounded items. +/// * `max_size`: The maximum size of the value in the storage. `None` for unbounded items. +fn worst_case_pov( + max_values: Option, + max_size: Option, + is_new_prefix: bool, + worst_case_map_values: u32, +) -> Option { + if let Some(max_size) = max_size { + let trie_size: u32 = if is_new_prefix { + single_read_pov_overhead(max_values, worst_case_map_values) + } else { + 0 + }; + + Some(trie_size + max_size) + } else { + None + } +} + +/// A simple match statement which outputs the log 16 of some value. +fn easy_log_16(i: u32) -> u32 { + match i { + i if i == 0 => 0, + i if i <= 16 => 1, + i if i <= 256 => 2, + i if i <= 4_096 => 3, + i if i <= 65_536 => 4, + i if i <= 1_048_576 => 5, + i if i <= 16_777_216 => 6, + i if i <= 268_435_456 => 7, + _ => 8, + } } // A helper to join a string of vectors. @@ -497,15 +835,16 @@ mod test { let mut results = Vec::new(); for i in 0..5 { results.push(BenchmarkResult { - components: vec![(param, i), (BenchmarkParameter::z, 0)], + components: vec![(param, i)], extrinsic_time: (base + slope * i).into(), storage_root_time: (base + slope * i).into(), reads: (base + slope * i).into(), repeat_reads: 0, writes: (base + slope * i).into(), repeat_writes: 0, - proof_size: 0, - keys: vec![], + proof_size: (i + 1) * 1024, + // All R/W come from this key: + keys: vec![(b"bounded".to_vec(), (base + slope * i), (base + slope * i), false)], }) } @@ -518,13 +857,31 @@ mod test { } } + fn test_storage_info() -> Vec { + vec![StorageInfo { + pallet_name: b"bounded".to_vec(), + storage_name: b"bounded".to_vec(), + prefix: b"bounded".to_vec(), + max_values: Some(1 << 20), + max_size: Some(32), + }] + } + + fn test_pov_mode() -> PovModesMap { + let mut map = PovModesMap::new(); + map.entry((b"scheduler".to_vec(), b"first_benchmark".to_vec())) + .or_default() + .insert(("scheduler".into(), "mel".into()), PovEstimationMode::MaxEncodedLen); + map.entry((b"scheduler".to_vec(), b"first_benchmark".to_vec())) + .or_default() + .insert(("scheduler".into(), "measured".into()), PovEstimationMode::Measured); + map + } + fn check_data(benchmark: &BenchmarkData, component: &str, base: u128, slope: u128) { assert_eq!( benchmark.components, - vec![ - Component { name: component.to_string(), is_used: true }, - Component { name: "z".to_string(), is_used: false }, - ], + vec![Component { name: component.to_string(), is_used: true },], ); // Weights multiplied by 1,000 assert_eq!(benchmark.base_weight, base * 1_000); @@ -543,6 +900,294 @@ mod test { benchmark.component_writes, vec![ComponentSlope { name: component.to_string(), slope, error: 0 }] ); + // Measure PoV is correct + assert_eq!(benchmark.base_recorded_proof_size, 1024); + assert_eq!( + benchmark.component_recorded_proof_size, + vec![ComponentSlope { name: component.to_string(), slope: 1024, error: 0 }] + ); + } + + /// We measure a linear proof size but select `pov_mode = MEL` with a present MEL bound for the + /// type. This should result in the measured PoV being ignored and the MEL used instead. + #[test] + fn pov_mode_mel_constant_works() { + let mut results = Vec::new(); + for i in 0..5 { + results.push(BenchmarkResult { + components: vec![(BenchmarkParameter::s, i)], + extrinsic_time: 0, + storage_root_time: 0, + reads: 1, + repeat_reads: 777, + writes: 888, + repeat_writes: 999, + proof_size: i * 1024, + keys: vec![(b"mel".to_vec(), 1, 1, false)], + }) + } + + let data = BenchmarkBatchSplitResults { + pallet: b"scheduler".to_vec(), + instance: b"instance".to_vec(), + benchmark: b"first_benchmark".to_vec(), + time_results: results.clone(), + db_results: results, + }; + + let storage_info = vec![StorageInfo { + pallet_name: b"scheduler".to_vec(), + storage_name: b"mel".to_vec(), + prefix: b"mel".to_vec(), + max_values: None, + max_size: Some(1 << 22), // MEL of 4 MiB + }]; + + let mapped_results = map_results( + &[data], + &storage_info, + &Default::default(), + test_pov_mode(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + let result = + mapped_results.get(&("scheduler".to_string(), "instance".to_string())).unwrap()[0] + .clone(); + + let base = result.base_calculated_proof_size; + assert!(result.component_calculated_proof_size.is_empty(), "There is no slope"); + // It's a map with 5 layers overhead: + assert_eq!(base, (1 << 22) + 15 * 33 * 5); + } + + /// Record a small linear proof size but since MEL is selected and available it should be used + /// instead. + #[test] + fn pov_mode_mel_linear_works() { + let mut results = Vec::new(); + for i in 0..5 { + results.push(BenchmarkResult { + components: vec![(BenchmarkParameter::s, i)], + extrinsic_time: 0, + storage_root_time: 0, + reads: 123, + repeat_reads: 777, + writes: 888, + repeat_writes: 999, + proof_size: i * 1024, + keys: vec![("mel".as_bytes().to_vec(), i, 1, false)], + }) + } + + let data = BenchmarkBatchSplitResults { + pallet: b"scheduler".to_vec(), + instance: b"instance".to_vec(), + benchmark: b"first_benchmark".to_vec(), + time_results: results.clone(), + db_results: results, + }; + + let storage_info = vec![StorageInfo { + pallet_name: b"scheduler".to_vec(), + storage_name: b"mel".to_vec(), + prefix: b"mel".to_vec(), + max_values: None, + max_size: Some(1 << 22), // MEL of 4 MiB + }]; + + let mapped_results = map_results( + &[data], + &storage_info, + &Default::default(), + test_pov_mode(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + let result = + mapped_results.get(&("scheduler".to_string(), "instance".to_string())).unwrap()[0] + .clone(); + + let base = result.base_calculated_proof_size; + assert_eq!(result.component_calculated_proof_size.len(), 1, "There is a slope"); + let slope = result.component_calculated_proof_size[0].clone().slope; + assert_eq!(base, 0); + // It's a map with 5 layers overhead: + assert_eq!(slope, (1 << 22) + 15 * 33 * 5); + } + + #[test] + fn pov_mode_measured_const_works() { + let mut results = Vec::new(); + for i in 0..5 { + results.push(BenchmarkResult { + components: vec![(BenchmarkParameter::s, i)], + extrinsic_time: 0, + storage_root_time: 0, + reads: 123, + repeat_reads: 777, + writes: 888, + repeat_writes: 999, + proof_size: 1024, + keys: vec![("measured".as_bytes().to_vec(), 1, 1, false)], + }) + } + + let data = BenchmarkBatchSplitResults { + pallet: b"scheduler".to_vec(), + instance: b"instance".to_vec(), + benchmark: b"first_benchmark".to_vec(), + time_results: results.clone(), + db_results: results, + }; + + let storage_info = vec![StorageInfo { + pallet_name: b"scheduler".to_vec(), + storage_name: b"measured".to_vec(), + prefix: b"measured".to_vec(), + max_values: None, + max_size: Some(1 << 22), // MEL of 4 MiB + }]; + + let mapped_results = map_results( + &[data], + &storage_info, + &Default::default(), + test_pov_mode(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + let result = + mapped_results.get(&("scheduler".to_string(), "instance".to_string())).unwrap()[0] + .clone(); + + let base = result.base_calculated_proof_size; + assert!(result.component_calculated_proof_size.is_empty(), "There is no slope"); + // 5 Trie layers overhead because of the 1M max elements in that map: + assert_eq!(base, 1024 + 15 * 33 * 5); + } + + #[test] + fn pov_mode_measured_linear_works() { + let mut results = Vec::new(); + for i in 0..5 { + results.push(BenchmarkResult { + components: vec![(BenchmarkParameter::s, i)], + extrinsic_time: 0, + storage_root_time: 0, + reads: 123, + repeat_reads: 777, + writes: 888, + repeat_writes: 999, + proof_size: i * 1024, + keys: vec![("measured".as_bytes().to_vec(), i, 1, false)], + }) + } + + let data = BenchmarkBatchSplitResults { + pallet: b"scheduler".to_vec(), + instance: b"instance".to_vec(), + benchmark: b"first_benchmark".to_vec(), + time_results: results.clone(), + db_results: results, + }; + + let storage_info = vec![StorageInfo { + pallet_name: b"scheduler".to_vec(), + storage_name: b"measured".to_vec(), + prefix: b"measured".to_vec(), + max_values: None, + max_size: Some(1 << 22), // MEL of 4 MiB + }]; + + let mapped_results = map_results( + &[data], + &storage_info, + &Default::default(), + test_pov_mode(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + let result = + mapped_results.get(&("scheduler".to_string(), "instance".to_string())).unwrap()[0] + .clone(); + + let base = result.base_calculated_proof_size; + assert_eq!(result.component_calculated_proof_size.len(), 1, "There is a slope"); + let slope = result.component_calculated_proof_size[0].clone().slope; + assert_eq!(base, 0); + // It's a map with 5 layers overhead: + assert_eq!(slope, 1024 + 15 * 33 * 5); + } + + #[test] + fn pov_mode_ignored_linear_works() { + let mut results = Vec::new(); + for i in 0..5 { + results.push(BenchmarkResult { + components: vec![(BenchmarkParameter::s, i)], + extrinsic_time: 0, + storage_root_time: 0, + reads: 123, + repeat_reads: 777, + writes: 888, + repeat_writes: 999, + proof_size: i * 1024, + keys: vec![("ignored".as_bytes().to_vec(), i, 1, false)], + }) + } + + let data = BenchmarkBatchSplitResults { + pallet: b"scheduler".to_vec(), + instance: b"instance".to_vec(), + benchmark: b"first_benchmark".to_vec(), + time_results: results.clone(), + db_results: results, + }; + + let storage_info = vec![StorageInfo { + pallet_name: b"scheduler".to_vec(), + storage_name: b"ignored".to_vec(), + prefix: b"ignored".to_vec(), + max_values: None, + max_size: Some(1 << 22), // MEL of 4 MiB + }]; + + let mapped_results = map_results( + &[data], + &storage_info, + &Default::default(), + test_pov_mode(), + PovEstimationMode::Ignored, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + let result = + mapped_results.get(&("scheduler".to_string(), "instance".to_string())).unwrap()[0] + .clone(); + + let base = result.base_calculated_proof_size; + assert!(result.component_calculated_proof_size.is_empty(), "There is no slope"); + assert_eq!(base, 0); } #[test] @@ -552,10 +1197,16 @@ mod test { test_data(b"first", b"first", BenchmarkParameter::a, 10, 3), test_data(b"first", b"second", BenchmarkParameter::b, 9, 2), test_data(b"second", b"first", BenchmarkParameter::c, 3, 4), + test_data(b"bounded", b"bounded", BenchmarkParameter::d, 4, 6), ], - &[], + &test_storage_info(), &Default::default(), + Default::default(), + PovEstimationMode::MaxEncodedLen, &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, ) .unwrap(); @@ -576,5 +1227,118 @@ mod test { .unwrap()[0]; assert_eq!(second_pallet_benchmark.name, "first_benchmark"); check_data(second_pallet_benchmark, "c", 3, 4); + + let bounded_pallet_benchmark = &mapped_results + .get(&("bounded_pallet".to_string(), "instance".to_string())) + .unwrap()[0]; + assert_eq!(bounded_pallet_benchmark.name, "bounded_benchmark"); + check_data(bounded_pallet_benchmark, "d", 4, 6); + // (5 * 15 * 33 + 32) * 4 = 10028 + assert_eq!(bounded_pallet_benchmark.base_calculated_proof_size, 10028); + // (5 * 15 * 33 + 32) * 6 = 15042 + assert_eq!( + bounded_pallet_benchmark.component_calculated_proof_size, + vec![ComponentSlope { name: "d".into(), slope: 15042, error: 0 }] + ); + } + + #[test] + fn additional_trie_layers_work() { + let mapped_results = map_results( + &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3)], + &test_storage_info(), + &Default::default(), + Default::default(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 2, + ) + .unwrap(); + let with_layer = &mapped_results + .get(&("first_pallet".to_string(), "instance".to_string())) + .unwrap()[0]; + let mapped_results = map_results( + &[test_data(b"first", b"first", BenchmarkParameter::a, 10, 3)], + &test_storage_info(), + &Default::default(), + Default::default(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + let without_layer = &mapped_results + .get(&("first_pallet".to_string(), "instance".to_string())) + .unwrap()[0]; + + assert_eq!( + without_layer.base_calculated_proof_size + 2 * 15 * 33, + with_layer.base_calculated_proof_size + ); + // The additional trie layers ONLY affect the base weight, not the components. + assert_eq!( + without_layer.component_calculated_proof_size, + with_layer.component_calculated_proof_size + ); + } + + #[test] + fn template_works() { + let all_results = map_results( + &[ + test_data(b"first", b"first", BenchmarkParameter::a, 10, 3), + test_data(b"first", b"second", BenchmarkParameter::b, 9, 2), + test_data(b"second", b"first", BenchmarkParameter::c, 3, 4), + ], + &test_storage_info(), + &Default::default(), + Default::default(), + PovEstimationMode::MaxEncodedLen, + &AnalysisChoice::default(), + &AnalysisChoice::MedianSlopes, + 1_000_000, + 0, + ) + .unwrap(); + + // New Handlebars instance with helpers. + let mut handlebars = handlebars::Handlebars::new(); + handlebars.register_helper("underscore", Box::new(UnderscoreHelper)); + handlebars.register_helper("join", Box::new(JoinHelper)); + // Don't HTML escape any characters. + handlebars.register_escape_fn(|s| -> String { s.to_string() }); + + for ((_pallet, _instance), results) in all_results.iter() { + let hbs_data = TemplateData { benchmarks: results.clone(), ..Default::default() }; + + let output = handlebars.render_template(&TEMPLATE, &hbs_data); + assert!(output.is_ok()); + println!("{:?}", output); + } + } + + #[test] + fn easy_log_16_works() { + assert_eq!(easy_log_16(0), 0); + assert_eq!(easy_log_16(1), 1); + assert_eq!(easy_log_16(16), 1); + assert_eq!(easy_log_16(17), 2); + assert_eq!(easy_log_16(16u32.pow(2)), 2); + assert_eq!(easy_log_16(16u32.pow(2) + 1), 3); + assert_eq!(easy_log_16(16u32.pow(3)), 3); + assert_eq!(easy_log_16(16u32.pow(3) + 1), 4); + assert_eq!(easy_log_16(16u32.pow(4)), 4); + assert_eq!(easy_log_16(16u32.pow(4) + 1), 5); + assert_eq!(easy_log_16(16u32.pow(5)), 5); + assert_eq!(easy_log_16(16u32.pow(5) + 1), 6); + assert_eq!(easy_log_16(16u32.pow(6)), 6); + assert_eq!(easy_log_16(16u32.pow(6) + 1), 7); + assert_eq!(easy_log_16(16u32.pow(7)), 7); + assert_eq!(easy_log_16(16u32.pow(7) + 1), 8); + assert_eq!(easy_log_16(u32::MAX), 8); } } From 248fdf0d4b5e3758cfdadb283b5eca5f0731e466 Mon Sep 17 00:00:00 2001 From: Dan Henton Date: Sat, 28 Jan 2023 00:31:17 +1300 Subject: [PATCH 63/80] Use non-binary pronouns in comments. (#13209) * use non binary pronouns in comments * cargo fmt * fix the use of "it" with "they" when dealing about an opperations identity --- bin/utils/subkey/README.md | 2 +- client/beefy/src/tests.rs | 7 ++++--- client/consensus/babe/src/lib.rs | 2 +- docs/README.adoc | 4 ++-- frame/contracts/src/exec.rs | 4 ++-- frame/elections-phragmen/src/benchmarking.rs | 2 +- frame/nfts/src/features/transfer.rs | 2 +- frame/nomination-pools/src/migration.rs | 2 +- frame/nomination-pools/test-staking/src/lib.rs | 2 +- frame/root-offences/src/tests.rs | 4 ++-- frame/staking/src/tests.rs | 2 +- frame/uniques/src/functions.rs | 4 ++-- 12 files changed, 19 insertions(+), 18 deletions(-) diff --git a/bin/utils/subkey/README.md b/bin/utils/subkey/README.md index e762a42c3e..768f1335cc 100644 --- a/bin/utils/subkey/README.md +++ b/bin/utils/subkey/README.md @@ -255,7 +255,7 @@ Secret Key URI `0x8c9a73097f235b84021a446bc2826a00c690ea0be3e0d81a84931cb4146d66 SS58 Address: 1bobYxBPjZWRPbVo35aSwci1u5Zmq8P6J2jpa4kkudBZMqE ``` -`Bob` now got a nice address starting with his name: 1**bob**YxBPjZWRPbVo35aSwci1u5Zmq8P6J2jpa4kkudBZMqE. +`Bob` now got a nice address starting with their name: 1**bob**YxBPjZWRPbVo35aSwci1u5Zmq8P6J2jpa4kkudBZMqE. **Note**: While `Bob`, having a short name (3 chars), got a result rather quickly, it will take much longer for `Alice` who has a much longer name, thus the chances to generate a random address that contains the chain `alice` will be much smaller. diff --git a/client/beefy/src/tests.rs b/client/beefy/src/tests.rs index 66d3a210d7..2642035ba5 100644 --- a/client/beefy/src/tests.rs +++ b/client/beefy/src/tests.rs @@ -151,7 +151,7 @@ impl BeefyTestNet { ) -> Vec { let mut all_hashes = Vec::with_capacity(count + 1); - // make sure genesis is the only block in network, so we can insert genesis at he beginning + // make sure genesis is the only block in network, so we can insert genesis at the beginning // of hashes, otherwise indexing would be broken assert!(self.peer(0).client().as_backend().blockchain().hash(1).unwrap().is_none()); @@ -926,7 +926,8 @@ async fn on_demand_beefy_justification_sync() { ) .await; - // Spawn Dave, he's now way behind voting and can only catch up through on-demand justif sync. + // Spawn Dave, they are now way behind voting and can only catch up through on-demand justif + // sync. tokio::spawn(dave_task); // give Dave a chance to spawn and init. run_for(Duration::from_millis(400), &net).await; @@ -937,7 +938,7 @@ async fn on_demand_beefy_justification_sync() { client.finalize_block(hashes[1], None).unwrap(); // Give Dave task some cpu cycles to process the finality notification, run_for(Duration::from_millis(100), &net).await; - // freshly spun up Dave now needs to listen for gossip to figure out the state of his peers. + // freshly spun up Dave now needs to listen for gossip to figure out the state of their peers. // Have the other peers do some gossip so Dave finds out about their progress. finalize_block_and_wait_for_beefy(&net, fast_peers, &[hashes[25]], &[25]).await; diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 5ba523665b..0eac4aca07 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -1494,7 +1494,7 @@ where // this way we can revert it if there's any error let mut old_epoch_changes = None; - // Use an extra scope to make the compiler happy, because otherwise he complains about the + // Use an extra scope to make the compiler happy, because otherwise it complains about the // mutex, even if we dropped it... let mut epoch_changes = { let mut epoch_changes = self.epoch_changes.shared_data_locked(); diff --git a/docs/README.adoc b/docs/README.adoc index 5d7b0b52c5..8e43757d10 100644 --- a/docs/README.adoc +++ b/docs/README.adoc @@ -297,7 +297,7 @@ Detailed logs may be shown by running the node with the following environment va If you want to see the multi-node consensus algorithm in action locally, then you can create a local testnet with two validator nodes for Alice and Bob, who are the initial authorities of the genesis chain specification that have been endowed with a testnet DOTs. We'll give each node a name and expose them so they are listed on link:https://telemetry.polkadot.io/#/Local%20Testnet[Telemetry]. You'll need two terminal windows open. -We'll start Alice's Substrate node first on default TCP port 30333 with her chain database stored locally at `/tmp/alice`. The Bootnode ID of her node is `QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR`, which is generated from the `--node-key` value that we specify below: +We'll start Alice's Substrate node first on default TCP port 30333 with their chain database stored locally at `/tmp/alice`. The Bootnode ID of Alice's node is `QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR`, which is generated from the `--node-key` value that we specify below: [source, shell] cargo run --release \-- \ @@ -308,7 +308,7 @@ cargo run --release \-- \ --telemetry-url 'ws://telemetry.polkadot.io:1024 0' \ --validator -In the second terminal, we'll run the following to start Bob's Substrate node on a different TCP port of 30334, and with his chain database stored locally at `/tmp/bob`. We'll specify a value for the `--bootnodes` option that will connect his node to Alice's Bootnode ID on TCP port 30333: +In the second terminal, we'll run the following to start Bob's Substrate node on a different TCP port of 30334, and with their chain database stored locally at `/tmp/bob`. We'll specify a value for the `--bootnodes` option that will connect Bob's node to Alice's Bootnode ID on TCP port 30333: [source, shell] cargo run --release \-- \ diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7a07b01d27..3eb59354d5 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -2056,9 +2056,9 @@ mod tests { #[test] fn code_hash_returns_proper_values() { let code_bob = MockLoader::insert(Call, |ctx, _| { - // ALICE is not a contract and hence she does not have a code_hash + // ALICE is not a contract and hence they do not have a code_hash assert!(ctx.ext.code_hash(&ALICE).is_none()); - // BOB is a contract and hence he has a code_hash + // BOB is a contract and hence it has a code_hash assert!(ctx.ext.code_hash(&BOB).is_some()); exec_success() }); diff --git a/frame/elections-phragmen/src/benchmarking.rs b/frame/elections-phragmen/src/benchmarking.rs index 06ac8d7c60..53157deaa9 100644 --- a/frame/elections-phragmen/src/benchmarking.rs +++ b/frame/elections-phragmen/src/benchmarking.rs @@ -32,7 +32,7 @@ const BALANCE_FACTOR: u32 = 250; /// grab new account with infinite balance. fn endowed_account(name: &'static str, index: u32) -> T::AccountId { let account: T::AccountId = account(name, index, 0); - // Fund each account with at-least his stake but still a sane amount as to not mess up + // Fund each account with at-least their stake but still a sane amount as to not mess up // the vote calculation. let amount = default_stake::(T::MaxVoters::get()) * BalanceOf::::from(BALANCE_FACTOR); let _ = T::Currency::make_free_balance_be(&account, amount); diff --git a/frame/nfts/src/features/transfer.rs b/frame/nfts/src/features/transfer.rs index 7d6ae3553a..3a34f0b8c9 100644 --- a/frame/nfts/src/features/transfer.rs +++ b/frame/nfts/src/features/transfer.rs @@ -64,7 +64,7 @@ impl, I: 'static> Pallet { details.owner = dest; // The approved accounts have to be reset to None, because otherwise pre-approve attack - // would be possible, where the owner can approve his second account before making the + // would be possible, where the owner can approve their second account before making the // transaction and then claiming the item back. details.approvals.clear(); diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index b73141c95f..4a9b6ca0fe 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -63,7 +63,7 @@ pub mod v1 { /// Trivial migration which makes the roles of each pool optional. /// - /// Note: The depositor is not optional since he can never change. + /// Note: The depositor is not optional since they can never change. pub struct MigrateToV1(sp_std::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToV1 { fn on_runtime_upgrade() -> Weight { diff --git a/frame/nomination-pools/test-staking/src/lib.rs b/frame/nomination-pools/test-staking/src/lib.rs index 00e0e40ce3..933e42578d 100644 --- a/frame/nomination-pools/test-staking/src/lib.rs +++ b/frame/nomination-pools/test-staking/src/lib.rs @@ -531,7 +531,7 @@ fn pool_slash_proportional() { #[test] fn pool_slash_non_proportional_only_bonded_pool() { - // A typical example where a pool member unbonds in era 99, and he can get away with a slash + // A typical example where a pool member unbonds in era 99, and they can get away with a slash // that happened in era 100, as long as the pool has enough active bond to cover the slash. If // everything else in the slashing/staking system works, this should always be the case. // Nonetheless, `ledger.slash` has been written such that it will slash greedily from any chunk diff --git a/frame/root-offences/src/tests.rs b/frame/root-offences/src/tests.rs index a8b7d0a6d6..b0df4fcee5 100644 --- a/frame/root-offences/src/tests.rs +++ b/frame/root-offences/src/tests.rs @@ -44,7 +44,7 @@ fn create_offence_works_given_root_origin() { // the slash should be applied right away. assert_eq!(Balances::free_balance(11), 500); - // the other validator should keep his balance, because we only created + // the other validator should keep their balance, because we only created // an offences for the first validator. assert_eq!(Balances::free_balance(21), 1000); }) @@ -68,7 +68,7 @@ fn create_offence_wont_slash_non_active_validators() { // so 31 didn't get slashed. assert_eq!(Balances::free_balance(31), 500); - // but 11 is an active validator so he got slashed. + // but 11 is an active validator so they got slashed. assert_eq!(Balances::free_balance(11), 800); }) } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index acd4189528..9635717d4c 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -1901,7 +1901,7 @@ fn wrong_vote_is_moot() { #[test] fn bond_with_no_staked_value() { // Behavior when someone bonds with no staked value. - // Particularly when she votes and the candidate is elected. + // Particularly when they votes and the candidate is elected. ExtBuilder::default() .validator_count(3) .existential_deposit(5) diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index 03dba16eaa..f73e5c479d 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -50,8 +50,8 @@ impl, I: 'static> Pallet { details.owner = dest; // The approved account has to be reset to None, because otherwise pre-approve attack would - // be possible, where the owner can approve his second account before making the transaction - // and then claiming the item back. + // be possible, where the owner can approve their second account before making the + // transaction and then claiming the item back. details.approved = None; Item::::insert(&collection, &item, &details); From ce2cee35f8f0fc5968ea6ffaffa6660dcd008804 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 27 Jan 2023 15:59:39 -0500 Subject: [PATCH 64/80] migrate new benchmarking syntax from `frame_support::benchmarking` to `frame_benchmarking::v2` (#13235) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * * re-export frame_support::benchmarking in frame_benchmarking:: * prefer use frame_benchmarking::*; in examples, etc * switch to frame_benchmarking::v2 * completely migrate new benchmarking code out of frame_support * fix doc links * remove unneeded return Co-authored-by: Bastian Köcher * remove another unneeded return Co-authored-by: Bastian Köcher * properly export all macros in v1 * refactor existing frame_benchmarking imports to use ::v1 --------- Co-authored-by: Bastian Köcher --- Cargo.lock | 3 +- .../pallets/template/src/benchmarking.rs | 2 +- frame/alliance/src/benchmarking.rs | 2 +- frame/assets/src/benchmarking.rs | 2 +- frame/babe/src/benchmarking.rs | 2 +- frame/bags-list/src/benchmarks.rs | 6 +- frame/balances/src/benchmarking.rs | 3 +- frame/benchmarking/Cargo.toml | 2 + frame/benchmarking/src/lib.rs | 2107 ++--------------- frame/benchmarking/src/v1.rs | 2043 ++++++++++++++++ frame/bounties/src/benchmarking.rs | 4 +- frame/child-bounties/src/benchmarking.rs | 2 +- frame/collective/src/benchmarking.rs | 2 +- frame/contracts/src/benchmarking/mod.rs | 2 +- frame/conviction-voting/src/benchmarking.rs | 2 +- frame/democracy/src/benchmarking.rs | 2 +- .../benchmarking/src/lib.rs | 2 +- frame/elections-phragmen/src/benchmarking.rs | 2 +- frame/examples/basic/src/benchmarking.rs | 7 +- frame/fast-unstake/src/benchmarking.rs | 2 +- frame/grandpa/src/benchmarking.rs | 2 +- frame/identity/src/benchmarking.rs | 2 +- frame/im-online/src/benchmarking.rs | 2 +- frame/indices/src/benchmarking.rs | 2 +- frame/lottery/src/benchmarking.rs | 2 +- frame/membership/src/lib.rs | 2 +- .../merkle-mountain-range/src/benchmarking.rs | 2 +- frame/message-queue/src/benchmarking.rs | 4 +- frame/multisig/src/benchmarking.rs | 2 +- frame/nfts/src/benchmarking.rs | 2 +- frame/nis/src/benchmarking.rs | 2 +- .../nomination-pools/benchmarking/src/lib.rs | 4 +- frame/offences/benchmarking/src/lib.rs | 2 +- frame/preimage/src/benchmarking.rs | 2 +- frame/proxy/src/benchmarking.rs | 2 +- frame/ranked-collective/src/benchmarking.rs | 2 +- frame/recovery/src/benchmarking.rs | 2 +- frame/referenda/src/benchmarking.rs | 2 +- frame/remark/src/benchmarking.rs | 2 +- frame/scheduler/src/benchmarking.rs | 2 +- frame/session/benchmarking/src/lib.rs | 2 +- frame/staking/src/benchmarking.rs | 2 +- frame/support/Cargo.toml | 1 - frame/support/procedural/src/benchmark.rs | 2 +- frame/support/procedural/src/lib.rs | 10 +- frame/support/src/lib.rs | 223 -- .../test/tests/benchmark_ui/bad_param_name.rs | 2 +- .../benchmark_ui/bad_param_name_too_long.rs | 4 +- .../benchmark_ui/bad_param_name_upper_case.rs | 2 +- .../tests/benchmark_ui/bad_param_range.rs | 2 +- .../test/tests/benchmark_ui/bad_params.rs | 2 +- .../test/tests/benchmark_ui/dup_block.rs | 2 +- .../tests/benchmark_ui/dup_extrinsic_call.rs | 2 +- .../test/tests/benchmark_ui/extra_extra.rs | 2 +- .../tests/benchmark_ui/extra_skip_meta.rs | 2 +- .../benchmark_ui/extrinsic_call_out_of_fn.rs | 2 +- .../test/tests/benchmark_ui/missing_call.rs | 2 +- .../test/tests/benchmark_ui/missing_origin.rs | 2 +- .../tests/benchmark_ui/pass/valid_basic.rs | 2 +- .../tests/benchmark_ui/unrecognized_option.rs | 2 +- frame/system/benchmarking/src/lib.rs | 2 +- frame/timestamp/src/benchmarking.rs | 2 +- frame/tips/src/benchmarking.rs | 2 +- frame/transaction-storage/src/benchmarking.rs | 2 +- frame/treasury/src/benchmarking.rs | 2 +- frame/uniques/src/benchmarking.rs | 2 +- frame/utility/src/benchmarking.rs | 2 +- frame/vesting/src/benchmarking.rs | 2 +- frame/whitelist/src/benchmarking.rs | 2 +- 69 files changed, 2291 insertions(+), 2240 deletions(-) create mode 100644 frame/benchmarking/src/v1.rs diff --git a/Cargo.lock b/Cargo.lock index 7bbe546921..6aafb0e175 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2138,6 +2138,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "frame-support", + "frame-support-procedural", "frame-system", "linregress", "log", @@ -2155,6 +2156,7 @@ dependencies = [ "sp-runtime-interface", "sp-std", "sp-storage", + "static_assertions", ] [[package]] @@ -2351,7 +2353,6 @@ dependencies = [ "sp-std", "sp-tracing", "sp-weights", - "static_assertions", "tt-call", ] diff --git a/bin/node-template/pallets/template/src/benchmarking.rs b/bin/node-template/pallets/template/src/benchmarking.rs index d496a9fc89..1790849970 100644 --- a/bin/node-template/pallets/template/src/benchmarking.rs +++ b/bin/node-template/pallets/template/src/benchmarking.rs @@ -4,7 +4,7 @@ use super::*; #[allow(unused)] use crate::Pallet as Template; -use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_system::RawOrigin; benchmarks! { diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index a34b76bd96..f312e032bb 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -25,7 +25,7 @@ use sp_std::{ prelude::*, }; -use frame_benchmarking::{account, benchmarks_instance_pallet}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::{Pallet as System, RawOrigin as SystemOrigin}; diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 235d1d9374..9acf69f1e4 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{ +use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, }; use frame_support::{ diff --git a/frame/babe/src/benchmarking.rs b/frame/babe/src/benchmarking.rs index 20002c97f8..70605e4cff 100644 --- a/frame/babe/src/benchmarking.rs +++ b/frame/babe/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v1::benchmarks; type Header = sp_runtime::generic::Header; diff --git a/frame/bags-list/src/benchmarks.rs b/frame/bags-list/src/benchmarks.rs index 1f66697cb6..74ae5f31ac 100644 --- a/frame/bags-list/src/benchmarks.rs +++ b/frame/bags-list/src/benchmarks.rs @@ -19,13 +19,15 @@ use super::*; use crate::list::List; -use frame_benchmarking::{account, whitelist_account, whitelisted_caller}; +use frame_benchmarking::v1::{ + account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, +}; use frame_election_provider_support::ScoreProvider; use frame_support::{assert_ok, traits::Get}; use frame_system::RawOrigin as SystemOrigin; use sp_runtime::traits::One; -frame_benchmarking::benchmarks_instance_pallet! { +benchmarks_instance_pallet! { rebag_non_terminal { // An expensive case for rebag-ing (rebag a non-terminal node): // diff --git a/frame/balances/src/benchmarking.rs b/frame/balances/src/benchmarking.rs index f85ff43b71..d80aa3ec8e 100644 --- a/frame/balances/src/benchmarking.rs +++ b/frame/balances/src/benchmarking.rs @@ -22,8 +22,7 @@ use super::*; use crate::Pallet as Balances; -use frame_benchmarking::{account, impl_benchmark_test_suite, whitelisted_caller}; -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; use frame_system::RawOrigin; const SEED: u32 = 0; diff --git a/frame/benchmarking/Cargo.toml b/frame/benchmarking/Cargo.toml index b2a9621ebf..4ff2077d7f 100644 --- a/frame/benchmarking/Cargo.toml +++ b/frame/benchmarking/Cargo.toml @@ -20,6 +20,7 @@ paste = "1.0" scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } +frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "../support/procedural" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" } sp-application-crypto = { version = "7.0.0", default-features = false, path = "../../primitives/application-crypto" } @@ -29,6 +30,7 @@ sp-runtime = { version = "7.0.0", default-features = false, path = "../../primit sp-runtime-interface = { version = "7.0.0", default-features = false, path = "../../primitives/runtime-interface" } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } sp-storage = { version = "7.0.0", default-features = false, path = "../../primitives/storage" } +static_assertions = "1.1.0" [dev-dependencies] array-bytes = "4.1" diff --git a/frame/benchmarking/src/lib.rs b/frame/benchmarking/src/lib.rs index 525370e233..a3bf809f6b 100644 --- a/frame/benchmarking/src/lib.rs +++ b/frame/benchmarking/src/lib.rs @@ -50,2005 +50,226 @@ pub use sp_std::{self, boxed::Box, prelude::Vec, str, vec}; pub use sp_storage::{well_known_keys, TrackedStorageKey}; pub use utils::*; -/// Whitelist the given account. -#[macro_export] -macro_rules! whitelist { - ($acc:ident) => { - frame_benchmarking::benchmarking::add_to_whitelist( - frame_system::Account::::hashed_key_for(&$acc).into(), - ); - }; -} +pub mod v1; +pub use v1::*; -/// Construct pallet benchmarks for weighing dispatchables. -/// -/// Works around the idea of complexity parameters, named by a single letter (which is usually -/// upper cased in complexity notation but is lower-cased for use in this macro). -/// -/// Complexity parameters ("parameters") have a range which is a `u32` pair. Every time a benchmark -/// is prepared and run, this parameter takes a concrete value within the range. There is an -/// associated instancing block, which is a single expression that is evaluated during -/// preparation. It may use `?` (`i.e. `return Err(...)`) to bail with a string error. Here's a -/// few examples: -/// -/// ```ignore -/// // These two are equivalent: -/// let x in 0 .. 10; -/// let x in 0 .. 10 => (); -/// // This one calls a setup function and might return an error (which would be terminal). -/// let y in 0 .. 10 => setup(y)?; -/// // This one uses a code block to do lots of stuff: -/// let z in 0 .. 10 => { -/// let a = z * z / 5; -/// let b = do_something(a)?; -/// combine_into(z, b); -/// } -/// ``` +/// Contains macros, structs, and traits associated with v2 of the pallet benchmarking syntax. /// -/// Note that due to parsing restrictions, if the `from` expression is not a single token (i.e. a -/// literal or constant), then it must be parenthesized. +/// The [`v2::benchmarks`] and [`v2::instance_benchmarks`] macros can be used to designate a +/// module as a benchmarking module that can contain benchmarks and benchmark tests. The +/// `#[benchmarks]` variant will set up a regular, non-instance benchmarking module, and the +/// `#[instance_benchmarks]` variant will set up the module in instance benchmarking mode. /// -/// The macro allows for a number of "arms", each representing an individual benchmark. Using the -/// simple syntax, the associated dispatchable function maps 1:1 with the benchmark and the name of -/// the benchmark is the same as that of the associated function. However, extended syntax allows -/// for arbitrary expressions to be evaluated in a benchmark (including for example, -/// `on_initialize`). +/// Benchmarking modules should be gated behind a `#[cfg(feature = "runtime-benchmarks")]` +/// feature gate to ensure benchmarking code that is only compiled when the +/// `runtime-benchmarks` feature is enabled is not referenced. /// -/// Note that the ranges are *inclusive* on both sides. This is in contrast to ranges in Rust which -/// are left-inclusive right-exclusive. +/// The following is the general syntax for a benchmarks (or instance benchmarks) module: /// -/// Each arm may also have a block of code which is run prior to any instancing and a block of code -/// which is run afterwards. All code blocks may draw upon the specific value of each parameter -/// at any time. Local variables are shared between the two pre- and post- code blocks, but do not -/// leak from the interior of any instancing expressions. +/// ## General Syntax /// -/// Example: /// ```ignore -/// benchmarks! { -/// where_clause { where T::A: From } // Optional line to give additional bound on `T`. -/// -/// // first dispatchable: foo; this is a user dispatchable and operates on a `u8` vector of -/// // size `l` -/// foo { -/// let caller = account::(b"caller", 0, benchmarks_seed); -/// let l in 1 .. MAX_LENGTH => initialize_l(l); -/// }: _(RuntimeOrigin::Signed(caller), vec![0u8; l]) -/// -/// // second dispatchable: bar; this is a root dispatchable and accepts a `u8` vector of size -/// // `l`. -/// // In this case, we explicitly name the call using `bar` instead of `_`. -/// bar { -/// let l in 1 .. MAX_LENGTH => initialize_l(l); -/// }: bar(RuntimeOrigin::Root, vec![0u8; l]) -/// -/// // third dispatchable: baz; this is a user dispatchable. It isn't dependent on length like the -/// // other two but has its own complexity `c` that needs setting up. It uses `caller` (in the -/// // pre-instancing block) within the code block. This is only allowed in the param instancers -/// // of arms. -/// baz1 { -/// let caller = account::(b"caller", 0, benchmarks_seed); -/// let c = 0 .. 10 => setup_c(&caller, c); -/// }: baz(RuntimeOrigin::Signed(caller)) -/// -/// // this is a second benchmark of the baz dispatchable with a different setup. -/// baz2 { -/// let caller = account::(b"caller", 0, benchmarks_seed); -/// let c = 0 .. 10 => setup_c_in_some_other_way(&caller, c); -/// }: baz(RuntimeOrigin::Signed(caller)) -/// -/// // You may optionally specify the origin type if it can't be determined automatically like -/// // this. -/// baz3 { -/// let caller = account::(b"caller", 0, benchmarks_seed); -/// let l in 1 .. MAX_LENGTH => initialize_l(l); -/// }: baz(RuntimeOrigin::Signed(caller), vec![0u8; l]) -/// -/// // this is benchmarking some code that is not a dispatchable. -/// populate_a_set { -/// let x in 0 .. 10_000; -/// let mut m = Vec::::new(); -/// for i in 0..x { -/// m.insert(i); -/// } -/// }: { m.into_iter().collect::() } -/// } -/// ``` -/// -/// Test functions are automatically generated for each benchmark and are accessible to you when you -/// run `cargo test`. All tests are named `test_benchmark_`, implemented on the -/// Pallet struct, and run them in a test externalities environment. The test function runs your -/// benchmark just like a regular benchmark, but only testing at the lowest and highest values for -/// each component. The function will return `Ok(())` if the benchmarks return no errors. -/// -/// It is also possible to generate one #[test] function per benchmark by calling the -/// `impl_benchmark_test_suite` macro inside the `benchmarks` block. The functions will be named -/// `bench_` and can be run via `cargo test`. -/// You will see one line of output per benchmark. This approach will give you more understandable -/// error messages and allows for parallel benchmark execution. -/// -/// You can optionally add a `verify` code block at the end of a benchmark to test any final state -/// of your benchmark in a unit test. For example: -/// -/// ```ignore -/// sort_vector { -/// let x in 1 .. 10000; -/// let mut m = Vec::::new(); -/// for i in (0..x).rev() { -/// m.push(i); -/// } -/// }: { -/// m.sort(); -/// } verify { -/// ensure!(m[0] == 0, "You forgot to sort!") -/// } -/// ``` -/// -/// These `verify` blocks will not affect your benchmark results! -/// -/// You can construct benchmark by using the `impl_benchmark_test_suite` macro or -/// by manually implementing them like so: -/// -/// ```ignore -/// #[test] -/// fn test_benchmarks() { -/// new_test_ext().execute_with(|| { -/// assert_ok!(Pallet::::test_benchmark_dummy()); -/// assert_err!(Pallet::::test_benchmark_other_name(), "Bad origin"); -/// assert_ok!(Pallet::::test_benchmark_sort_vector()); -/// assert_err!(Pallet::::test_benchmark_broken_benchmark(), "You forgot to sort!"); -/// }); -/// } -/// ``` -#[macro_export] -macro_rules! benchmarks { - ( - $( $rest:tt )* - ) => { - $crate::benchmarks_iter!( - { } - { } - { } - ( ) - ( ) - ( ) - ( ) - $( $rest )* - ); - } -} - -/// Same as [`benchmarks`] but for instantiable module. -/// -/// NOTE: For pallet declared with [`frame_support::pallet`], use [`benchmarks_instance_pallet`]. -#[macro_export] -macro_rules! benchmarks_instance { - ( - $( $rest:tt )* - ) => { - $crate::benchmarks_iter!( - { } - { I: Instance } - { } - ( ) - ( ) - ( ) - ( ) - $( $rest )* - ); - } -} - -/// Same as [`benchmarks`] but for instantiable pallet declared [`frame_support::pallet`]. -/// -/// NOTE: For pallet declared with `decl_module!`, use [`benchmarks_instance`]. -#[macro_export] -macro_rules! benchmarks_instance_pallet { - ( - $( $rest:tt )* - ) => { - $crate::benchmarks_iter!( - { } - { I: 'static } - { } - ( ) - ( ) - ( ) - ( ) - $( $rest )* - ); - } -} - -#[macro_export] -#[doc(hidden)] -macro_rules! benchmarks_iter { - // detect and extract `impl_benchmark_test_suite` call: - // - with a semi-colon - ( - { } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - impl_benchmark_test_suite!( - $bench_module:ident, - $new_test_ext:expr, - $test:path - $(, $( $args:tt )* )?); - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $bench_module, $new_test_ext, $test $(, $( $args )* )? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $( $rest )* - } - }; - // - without a semicolon - ( - { } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - impl_benchmark_test_suite!( - $bench_module:ident, - $new_test_ext:expr, - $test:path - $(, $( $args:tt )* )?) - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $bench_module, $new_test_ext, $test $(, $( $args )* )? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $( $rest )* - } - }; - // detect and extract where clause: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - where_clause { where $( $where_bound:tt )* } - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound)? } - { $( $where_bound )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $( $rest )* - } - }; - // detect and extract `#[skip_meta]` tag: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - #[skip_meta] - $( #[ $($attributes:tt)+ ] )* - $name:ident - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* $name ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $( #[ $( $attributes )+ ] )* - $name - $( $rest )* - } - }; - // detect and extract `#[extra]` tag: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - #[extra] - $( #[ $($attributes:tt)+ ] )* - $name:ident - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* $name ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $( #[ $( $attributes )+ ] )* - $name - $( $rest )* - } - }; - // detect and extract `#[pov_mode = Mode { Pallet::Storage: Mode ... }]` tag: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $old_pov_name:ident: $( $old_storage:path = $old_pov_mode:ident )*; )* ) - #[pov_mode = $mode:ident $( { $( $storage:path: $pov_mode:ident )* } )?] - $( #[ $($attributes:tt)+ ] )* - $name:ident - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $name: ALL = $mode $($( $storage = $pov_mode )*)?; $( $old_pov_name: $( $old_storage = $old_pov_mode )*; )* ) - $( #[ $( $attributes )+ ] )* - $name - $( $rest )* - } - }; - // mutation arm: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) // This contains $( $( { $instance } )? $name:ident )* - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - $name:ident { $( $code:tt )* }: _ $(< $origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) - verify $postcode:block - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $name { $( $code )* }: $name $(< $origin_type >)? ( $origin $( , $arg )* ) - verify $postcode - $( $rest )* - } - }; - // mutation arm: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - $name:ident { $( $code:tt )* }: $dispatch:ident $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) - verify $postcode:block - $( $rest:tt )* - ) => { - $crate::paste::paste! { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $name { - $( $code )* - let __call = Call::< - T - $( , $instance )? - >:: [< new_call_variant_ $dispatch >] ( - $($arg),* - ); - let __benchmarked_call_encoded = $crate::frame_support::codec::Encode::encode( - &__call - ); - }: { - let __call_decoded = < - Call - as $crate::frame_support::codec::Decode - >::decode(&mut &__benchmarked_call_encoded[..]) - .expect("call is encoded above, encoding must be correct"); - let __origin = $crate::to_origin!($origin $(, $origin_type)?); - as $crate::frame_support::traits::UnfilteredDispatchable - >::dispatch_bypass_filter(__call_decoded, __origin)?; - } - verify $postcode - $( $rest )* - } - } - }; - // iteration arm: - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - $name:ident { $( $code:tt )* }: $eval:block - verify $postcode:block - $( $rest:tt )* - ) => { - $crate::benchmark_backend! { - { $( $instance: $instance_bound )? } - $name - { $( $where_clause )* } - { } - { $eval } - { $( $code )* } - $postcode - } - - #[cfg(test)] - $crate::impl_benchmark_test!( - { $( $where_clause )* } - { $( $instance: $instance_bound )? } - $name - ); - - $crate::benchmarks_iter!( - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* { $( $instance )? } $name ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $( $rest )* - ); - }; - // iteration-exit arm which generates a #[test] function for each case. - ( - { $bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - ) => { - $crate::selected_benchmark!( - { $( $where_clause)* } - { $( $instance: $instance_bound )? } - $( $names )* - ); - $crate::impl_benchmark!( - { $( $where_clause )* } - { $( $instance: $instance_bound )? } - ( $( $names )* ) - ( $( $names_extra ),* ) - ( $( $names_skip_meta ),* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - ); - $crate::impl_test_function!( - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - $bench_module, - $new_test_ext, - $test - $(, $( $args )* )? - ); - }; - // iteration-exit arm which doesn't generate a #[test] function for all cases. - ( - { } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - ) => { - $crate::selected_benchmark!( - { $( $where_clause)* } - { $( $instance: $instance_bound )? } - $( $names )* - ); - $crate::impl_benchmark!( - { $( $where_clause )* } - { $( $instance: $instance_bound )? } - ( $( $names )* ) - ( $( $names_extra ),* ) - ( $( $names_skip_meta ),* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - ); - }; - // add verify block to _() format - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - $name:ident { $( $code:tt )* }: _ $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $name { $( $code )* }: _ $(<$origin_type>)? ( $origin $( , $arg )* ) - verify { } - $( $rest )* - } - }; - // add verify block to name() format - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - $name:ident { $( $code:tt )* }: $dispatch:ident $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) - $( $rest:tt )* - ) => { - $crate::benchmarks_iter! { - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $name { $( $code )* }: $dispatch $(<$origin_type>)? ( $origin $( , $arg )* ) - verify { } - $( $rest )* - } - }; - // add verify block to {} format - ( - { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } - { $( $instance:ident: $instance_bound:tt )? } - { $( $where_clause:tt )* } - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - $name:ident { $( $code:tt )* }: $(<$origin_type:ty>)? $eval:block - $( $rest:tt )* - ) => { - $crate::benchmarks_iter!( - { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } - { $( $instance: $instance_bound )? } - { $( $where_clause )* } - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - ( $( $pov_name: $( $storage = $pov_mode )*; )* ) - $name { $( $code )* }: $(<$origin_type>)? $eval - verify { } - $( $rest )* - ); - }; -} - -#[macro_export] -#[doc(hidden)] -macro_rules! to_origin { - ($origin:expr) => { - $origin.into() - }; - ($origin:expr, $origin_type:ty) => { - <::RuntimeOrigin as From<$origin_type>>::from($origin) - }; -} - -#[macro_export] -#[doc(hidden)] -macro_rules! benchmark_backend { - // parsing arms - ( - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - { $( $where_clause:tt )* } - { $( PRE { $( $pre_parsed:tt )* } )* } - { $eval:block } - { - let $pre_id:tt : $pre_ty:ty = $pre_ex:expr; - $( $rest:tt )* - } - $postcode:block - ) => { - $crate::benchmark_backend! { - { $( $instance: $instance_bound )? } - $name - { $( $where_clause )* } - { - $( PRE { $( $pre_parsed )* } )* - PRE { $pre_id , $pre_ty , $pre_ex } - } - { $eval } - { $( $rest )* } - $postcode - } - }; - ( - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - { $( $where_clause:tt )* } - { $( $parsed:tt )* } - { $eval:block } - { - let $param:ident in ( $param_from:expr ) .. $param_to:expr => $param_instancer:expr; - $( $rest:tt )* - } - $postcode:block - ) => { - $crate::benchmark_backend! { - { $( $instance: $instance_bound )? } - $name - { $( $where_clause )* } - { - $( $parsed )* - PARAM { $param , $param_from , $param_to , $param_instancer } - } - { $eval } - { $( $rest )* } - $postcode - } - }; - // mutation arm to look after a single tt for param_from. - ( - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - { $( $where_clause:tt )* } - { $( $parsed:tt )* } - { $eval:block } - { - let $param:ident in $param_from:tt .. $param_to:expr => $param_instancer:expr ; - $( $rest:tt )* - } - $postcode:block - ) => { - $crate::benchmark_backend! { - { $( $instance: $instance_bound )? } - $name - { $( $where_clause )* } - { $( $parsed )* } - { $eval } - { - let $param in ( $param_from ) .. $param_to => $param_instancer; - $( $rest )* - } - $postcode - } - }; - // mutation arm to look after the default tail of `=> ()` - ( - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - { $( $where_clause:tt )* } - { $( $parsed:tt )* } - { $eval:block } - { - let $param:ident in $param_from:tt .. $param_to:expr; - $( $rest:tt )* - } - $postcode:block - ) => { - $crate::benchmark_backend! { - { $( $instance: $instance_bound )? } - $name - { $( $where_clause )* } - { $( $parsed )* } - { $eval } - { - let $param in $param_from .. $param_to => (); - $( $rest )* - } - $postcode - } - }; - // mutation arm to look after `let _ =` - ( - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - { $( $where_clause:tt )* } - { $( $parsed:tt )* } - { $eval:block } - { - let $pre_id:tt = $pre_ex:expr; - $( $rest:tt )* - } - $postcode:block - ) => { - $crate::benchmark_backend! { - { $( $instance: $instance_bound )? } - $name - { $( $where_clause )* } - { $( $parsed )* } - { $eval } - { - let $pre_id : _ = $pre_ex; - $( $rest )* - } - $postcode - } - }; - // actioning arm - ( - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - { $( $where_clause:tt )* } - { - $( PRE { $pre_id:tt , $pre_ty:ty , $pre_ex:expr } )* - $( PARAM { $param:ident , $param_from:expr , $param_to:expr , $param_instancer:expr } )* - } - { $eval:block } - { $( $post:tt )* } - $postcode:block - ) => { - #[allow(non_camel_case_types)] - struct $name; - #[allow(unused_variables)] - impl, $instance: $instance_bound )? > - $crate::BenchmarkingSetup for $name - where $( $where_clause )* - { - fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> { - $crate::vec! [ - $( - ($crate::BenchmarkParameter::$param, $param_from, $param_to) - ),* - ] - } - - fn instance( - &self, - components: &[($crate::BenchmarkParameter, u32)], - verify: bool - ) -> Result<$crate::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { - $( - // Prepare instance - let $param = components.iter() - .find(|&c| c.0 == $crate::BenchmarkParameter::$param) - .ok_or("Could not find component in benchmark preparation.")? - .1; - )* - $( - let $pre_id : $pre_ty = $pre_ex; - )* - $( $param_instancer ; )* - $( $post )* - - Ok($crate::Box::new(move || -> Result<(), $crate::BenchmarkError> { - $eval; - if verify { - $postcode; - } - Ok(()) - })) - } - } - }; -} - -// Creates #[test] functions for the given bench cases. -#[macro_export] -#[doc(hidden)] -macro_rules! impl_bench_case_tests { - ( - { $module:ident, $new_test_exec:expr, $exec_name:ident, $test:path, $extra:expr } - { $( $names_extra:tt )* } - $( { $( $bench_inst:ident )? } $bench:ident )* - ) - => { - $crate::impl_bench_name_tests!( - $module, $new_test_exec, $exec_name, $test, $extra, - { $( $names_extra )* }, - $( { $bench } )+ - ); - } -} - -// Creates a #[test] function for the given bench name. -#[macro_export] -#[doc(hidden)] -macro_rules! impl_bench_name_tests { - // recursion anchor - ( - $module:ident, $new_test_exec:expr, $exec_name:ident, $test:path, $extra:expr, - { $( $names_extra:tt )* }, - { $name:ident } - ) => { - $crate::paste::paste! { - #[test] - fn [] () { - $new_test_exec.$exec_name(|| { - // Skip all #[extra] benchmarks if $extra is false. - if !($extra) { - let disabled = $crate::vec![ $( stringify!($names_extra).as_ref() ),* ]; - if disabled.contains(&stringify!($name)) { - $crate::log::error!( - "INFO: extra benchmark skipped - {}", - stringify!($name), - ); - return (); - } - } - - // Same per-case logic as when all cases are run in the - // same function. - match std::panic::catch_unwind(|| { - $module::<$test>::[< test_benchmark_ $name >] () - }) { - Err(err) => { - panic!("{}: {:?}", stringify!($name), err); - }, - Ok(Err(err)) => { - match err { - $crate::BenchmarkError::Stop(err) => { - panic!("{}: {:?}", stringify!($name), err); - }, - $crate::BenchmarkError::Override(_) => { - // This is still considered a success condition. - $crate::log::error!( - "WARNING: benchmark error overrided - {}", - stringify!($name), - ); - }, - $crate::BenchmarkError::Skip => { - // This is considered a success condition. - $crate::log::error!( - "WARNING: benchmark error skipped - {}", - stringify!($name), - ); - }, - $crate::BenchmarkError::Weightless => { - // This is considered a success condition. - $crate::log::error!( - "WARNING: benchmark weightless skipped - {}", - stringify!($name), - ); - } - } - }, - Ok(Ok(())) => (), - } - }); - } - } - }; - // recursion tail - ( - $module:ident, $new_test_exec:expr, $exec_name:ident, $test:path, $extra:expr, - { $( $names_extra:tt )* }, - { $name:ident } $( { $rest:ident } )+ - ) => { - // car - $crate::impl_bench_name_tests!($module, $new_test_exec, $exec_name, $test, $extra, - { $( $names_extra )* }, { $name }); - // cdr - $crate::impl_bench_name_tests!($module, $new_test_exec, $exec_name, $test, $extra, - { $( $names_extra )* }, $( { $rest } )+); - }; -} - -// 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 { - ( - { $( $where_clause:tt )* } - { $( $instance:ident: $instance_bound:tt )? } - $( { $( $bench_inst:ident )? } $bench:ident )* - ) => { - // The list of available benchmarks for this pallet. - #[allow(non_camel_case_types)] - enum SelectedBenchmark { - $( $bench, )* - } - - // Allow us to select a benchmark from the list of available benchmarks. - impl, $instance: $instance_bound )? > - $crate::BenchmarkingSetup for SelectedBenchmark - where $( $where_clause )* - { - fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> { - match self { - $( - Self::$bench => < - $bench as $crate::BenchmarkingSetup - >::components(&$bench), - )* - } - } - - fn instance( - &self, - components: &[($crate::BenchmarkParameter, u32)], - verify: bool - ) -> Result<$crate::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { - match self { - $( - Self::$bench => < - $bench as $crate::BenchmarkingSetup - >::instance(&$bench, components, verify), - )* - } - } - } - }; -} - -#[macro_export] -#[doc(hidden)] -macro_rules! impl_benchmark { - ( - { $( $where_clause:tt )* } - { $( $instance:ident: $instance_bound:tt )? } - ( $( { $( $name_inst:ident )? } $name:ident )* ) - ( $( $name_extra:ident ),* ) - ( $( $name_skip_meta:ident ),* ) - ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) - ) => { - // We only need to implement benchmarks for the runtime-benchmarks feature or testing. - #[cfg(any(feature = "runtime-benchmarks", test))] - impl, $instance: $instance_bound )? > - $crate::Benchmarking for Pallet - where T: frame_system::Config, $( $where_clause )* - { - fn benchmarks(extra: bool) -> $crate::Vec<$crate::BenchmarkMetadata> { - $($crate::validate_pov_mode!( - $pov_name: $( $storage = $pov_mode )*; - );)* - let mut all_names = $crate::vec![ $( stringify!($name).as_ref() ),* ]; - if !extra { - let extra = [ $( stringify!($name_extra).as_ref() ),* ]; - all_names.retain(|x| !extra.contains(x)); - } - let pov_modes: $crate::Vec<($crate::Vec, $crate::Vec<($crate::Vec, $crate::Vec)>)> = $crate::vec![ - $( - (stringify!($pov_name).as_bytes().to_vec(), - $crate::vec![ - $( ( stringify!($storage).as_bytes().to_vec(), - stringify!($pov_mode).as_bytes().to_vec() ), )* - ]), - )* - ]; - all_names.into_iter().map(|benchmark| { - let selected_benchmark = match benchmark { - $( stringify!($name) => SelectedBenchmark::$name, )* - _ => panic!("all benchmarks should be selectable"), - }; - let name = benchmark.as_bytes().to_vec(); - let components = < - SelectedBenchmark as $crate::BenchmarkingSetup - >::components(&selected_benchmark); - - $crate::BenchmarkMetadata { - name: name.clone(), - components, - pov_modes: pov_modes.iter().find(|p| p.0 == name).map(|p| p.1.clone()).unwrap_or_default(), - } - }).collect::<$crate::Vec<_>>() - } - - fn run_benchmark( - extrinsic: &[u8], - c: &[($crate::BenchmarkParameter, u32)], - whitelist: &[$crate::TrackedStorageKey], - verify: bool, - internal_repeats: u32, - ) -> Result<$crate::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> { - // Map the input to the selected benchmark. - let extrinsic = $crate::str::from_utf8(extrinsic) - .map_err(|_| "`extrinsic` is not a valid utf8 string!")?; - let selected_benchmark = match extrinsic { - $( stringify!($name) => SelectedBenchmark::$name, )* - _ => return Err("Could not find extrinsic.".into()), - }; - - // Add whitelist to DB including whitelisted caller - let mut whitelist = whitelist.to_vec(); - let whitelisted_caller_key = - as $crate::frame_support::storage::StorageMap<_,_>>::hashed_key_for( - $crate::whitelisted_caller::() - ); - whitelist.push(whitelisted_caller_key.into()); - // Whitelist the transactional layer. - let transactional_layer_key = $crate::TrackedStorageKey::new( - $crate::frame_support::storage::transactional::TRANSACTION_LEVEL_KEY.into() - ); - whitelist.push(transactional_layer_key); - // Whitelist the `:extrinsic_index`. - let extrinsic_index = $crate::TrackedStorageKey::new( - $crate::well_known_keys::EXTRINSIC_INDEX.into() - ); - whitelist.push(extrinsic_index); - - $crate::benchmarking::set_whitelist(whitelist.clone()); - - let mut results: $crate::Vec<$crate::BenchmarkResult> = $crate::Vec::new(); - - // Always do at least one internal repeat... - for _ in 0 .. internal_repeats.max(1) { - // Always reset the state after the benchmark. - $crate::defer!($crate::benchmarking::wipe_db()); - - // Set up the externalities environment for the setup we want to - // benchmark. - let closure_to_benchmark = < - SelectedBenchmark as $crate::BenchmarkingSetup - >::instance(&selected_benchmark, c, verify)?; - - // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { - frame_system::Pallet::::set_block_number(1u32.into()); - } - - // Commit the externalities to the database, flushing the DB cache. - // This will enable worst case scenario for reading from the database. - $crate::benchmarking::commit_db(); - - // Access all whitelisted keys to get them into the proof recorder since the - // recorder does now have a whitelist. - for key in &whitelist { - $crate::frame_support::storage::unhashed::get_raw(&key.key); - } - - // 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. - $crate::log::trace!( - target: "benchmark", - "Start Benchmark: {} ({:?}) verify {}", - extrinsic, - c, - verify - ); - - let start_pov = $crate::benchmarking::proof_size(); - let start_extrinsic = $crate::benchmarking::current_time(); - - closure_to_benchmark()?; - - let finish_extrinsic = $crate::benchmarking::current_time(); - let end_pov = $crate::benchmarking::proof_size(); - - // Calculate the diff caused by the benchmark. - let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); - let diff_pov = match (start_pov, end_pov) { - (Some(start), Some(end)) => end.saturating_sub(start), - _ => Default::default(), - }; - - // Commit the changes to get proper write count - $crate::benchmarking::commit_db(); - $crate::log::trace!( - target: "benchmark", - "End Benchmark: {} ns", elapsed_extrinsic - ); - let read_write_count = $crate::benchmarking::read_write_count(); - $crate::log::trace!( - target: "benchmark", - "Read/Write Count {:?}", read_write_count - ); - $crate::log::trace!( - target: "benchmark", - "Proof sizes: before {:?} after {:?} diff {}", &start_pov, &end_pov, &diff_pov - ); - - // Time the storage root recalculation. - let start_storage_root = $crate::benchmarking::current_time(); - $crate::storage_root($crate::StateVersion::V1); - let finish_storage_root = $crate::benchmarking::current_time(); - let elapsed_storage_root = finish_storage_root - start_storage_root; - - let skip_meta = [ $( stringify!($name_skip_meta).as_ref() ),* ]; - let read_and_written_keys = if skip_meta.contains(&extrinsic) { - $crate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] - } else { - $crate::benchmarking::get_read_and_written_keys() - }; - - results.push($crate::BenchmarkResult { - components: c.to_vec(), - 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, - proof_size: diff_pov, - keys: read_and_written_keys, - }); - } - - return Ok(results); - } - } - - #[cfg(test)] - impl, $instance: $instance_bound )? > - Pallet - where T: frame_system::Config, $( $where_clause )* - { - /// Test a particular benchmark by name. - /// - /// This isn't called `test_benchmark_by_name` just in case some end-user eventually - /// writes a benchmark, itself called `by_name`; the function would be shadowed in - /// that case. - /// - /// This is generally intended to be used by child test modules such as those created - /// by the `impl_benchmark_test_suite` macro. However, it is not an error if a pallet - /// author chooses not to implement benchmarks. - #[allow(unused)] - fn test_bench_by_name(name: &[u8]) -> Result<(), $crate::BenchmarkError> { - let name = $crate::str::from_utf8(name) - .map_err(|_| -> $crate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?; - match name { - $( stringify!($name) => { - $crate::paste::paste! { Self::[< test_benchmark_ $name >]() } - } )* - _ => Err("Could not find test for requested benchmark.".into()), - } - } - } - }; -} - -// 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. -// Instances each component with six values which can be controlled with the -// env variable `VALUES_PER_COMPONENT`. -#[macro_export] -#[doc(hidden)] -macro_rules! impl_benchmark_test { - ( - { $( $where_clause:tt )* } - { $( $instance:ident: $instance_bound:tt )? } - $name:ident - ) => { - $crate::paste::item! { - #[cfg(test)] - impl, $instance: $instance_bound )? > - Pallet - where T: frame_system::Config, $( $where_clause )* - { - #[allow(unused)] - fn [] () -> Result<(), $crate::BenchmarkError> { - let selected_benchmark = SelectedBenchmark::$name; - let components = < - SelectedBenchmark as $crate::BenchmarkingSetup - >::components(&selected_benchmark); - - let execute_benchmark = | - c: $crate::Vec<($crate::BenchmarkParameter, u32)> - | -> Result<(), $crate::BenchmarkError> { - // Always reset the state after the benchmark. - $crate::defer!($crate::benchmarking::wipe_db()); - - // Set up the benchmark, return execution + verification function. - let closure_to_verify = < - SelectedBenchmark as $crate::BenchmarkingSetup - >::instance(&selected_benchmark, &c, true)?; - - // Set the block number to at least 1 so events are deposited. - if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { - frame_system::Pallet::::set_block_number(1u32.into()); - } - - // Run execution + verification - closure_to_verify() - }; - - if components.is_empty() { - execute_benchmark(Default::default())?; - } else { - let num_values: u32 = if let Ok(ev) = std::env::var("VALUES_PER_COMPONENT") { - ev.parse().map_err(|_| { - $crate::BenchmarkError::Stop( - "Could not parse env var `VALUES_PER_COMPONENT` as u32." - ) - })? - } else { - 6 - }; - - if num_values < 2 { - return Err("`VALUES_PER_COMPONENT` must be at least 2".into()); - } - - for (name, low, high) in components.clone().into_iter() { - // Test the lowest, highest (if its different from the lowest) - // and up to num_values-2 more equidistant values in between. - // For 0..10 and num_values=6 this would mean: [0, 2, 4, 6, 8, 10] - - let mut values = $crate::vec![low]; - let diff = (high - low).min(num_values - 1); - let slope = (high - low) as f32 / diff as f32; - - for i in 1..=diff { - let value = ((low as f32 + slope * i as f32) as u32) - .clamp(low, high); - values.push(value); - } - - for component_value in values { - // Select the max value for all the other components. - let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components - .iter() - .map(|(n, _, h)| - if *n == name { - (*n, component_value) - } else { - (*n, *h) - } - ) - .collect(); - - execute_benchmark(c)?; - } - } - } - Ok(()) - } - } - } - }; -} - -/// This creates a test suite which runs the module's benchmarks. +/// #![cfg(feature = "runtime-benchmarks")] /// -/// When called in `pallet_example_basic` as +/// use super::{mock_helpers::*, Pallet as MyPallet}; +/// use frame_benchmarking::v2::*; /// -/// ```rust,ignore -/// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); -/// ``` -/// -/// It expands to the equivalent of: -/// -/// ```rust,ignore -/// #[cfg(test)] -/// mod tests { +/// #[benchmarks] +/// mod benchmarks { /// use super::*; -/// use crate::tests::{new_test_ext, Test}; -/// use frame_support::assert_ok; /// -/// #[test] -/// fn test_benchmarks() { -/// new_test_ext().execute_with(|| { -/// assert_ok!(test_benchmark_accumulate_dummy::()); -/// assert_ok!(test_benchmark_set_dummy::()); -/// assert_ok!(test_benchmark_sort_vector::()); -/// }); -/// } -/// } -/// ``` -/// -/// When called inside the `benchmarks` macro of the `pallet_example_basic` as -/// -/// ```rust,ignore -/// benchmarks! { -/// // Benchmarks omitted for brevity +/// #[benchmark] +/// fn bench_name_1(x: Linear<7, 1_000>, y: Linear<1_000, 100_0000>) { +/// // setup code +/// let z = x + y; +/// let caller = whitelisted_caller(); /// -/// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); -/// } -/// ``` +/// #[extrinsic_call] +/// extrinsic_name(SystemOrigin::Signed(caller), other, arguments); /// -/// It expands to the equivalent of: -/// -/// ```rust,ignore -/// #[cfg(test)] -/// mod benchmarking { -/// use super::*; -/// use crate::tests::{new_test_ext, Test}; -/// use frame_support::assert_ok; -/// -/// #[test] -/// fn bench_accumulate_dummy() { -/// new_test_ext().execute_with(|| { -/// assert_ok!(test_benchmark_accumulate_dummy::()); -/// }) +/// // verification code +/// assert_eq!(MyPallet::::my_var(), z); /// } /// -/// #[test] -/// fn bench_set_dummy() { -/// new_test_ext().execute_with(|| { -/// assert_ok!(test_benchmark_set_dummy::()); -/// }) -/// } +/// #[benchmark] +/// fn bench_name_2() { +/// // setup code +/// let caller = whitelisted_caller(); /// -/// #[test] -/// fn bench_sort_vector() { -/// new_test_ext().execute_with(|| { -/// assert_ok!(test_benchmark_sort_vector::()); -/// }) +/// #[block] +/// { +/// something(some, thing); +/// my_extrinsic(RawOrigin::Signed(caller), some, argument); +/// something_else(foo, bar); +/// } +/// +/// // verification code +/// assert_eq!(MyPallet::::something(), 37); /// } /// } /// ``` /// -/// ## Arguments +/// ## Benchmark Definitions /// -/// The first argument, `module`, must be the path to this crate's module. +/// Within a `#[benchmarks]` or `#[instance_benchmarks]` module, you can define individual +/// benchmarks using the `#[benchmark]` attribute, as shown in the example above. /// -/// The second argument, `new_test_ext`, must be a function call which returns either a -/// `sp_io::TestExternalities`, or some other type with a similar interface. +/// The `#[benchmark]` attribute expects a function definition with a blank return type and +/// zero or more arguments whose names are valid +/// [BenchmarkParameter](`crate::BenchmarkParameter`) parameters, such as `x`, `y`, `a`, `b`, +/// etc., and whose param types must implement [ParamRange](`v2::ParamRange`). At the moment +/// the only valid type that implements [ParamRange](`v2::ParamRange`) is +/// [Linear](`v2::Linear`). /// -/// Note that this function call is _not_ evaluated at compile time, but is instead copied textually -/// into each appropriate invocation site. +/// The valid syntax for defining a [Linear](`v2::Linear`)is `Linear` where `A`, and `B` +/// are valid integer literals (that fit in a `u32`), such that `B` >= `A`. /// -/// The third argument, `test`, must be the path to the runtime. The item to which this must refer -/// will generally take the form: +/// Note that the benchmark function definition does not actually expand as a function +/// definition, but rather is used to automatically create a number of impls and structs +/// required by the benchmarking engine. For this reason, the visibility of the function +/// definition as well as the return type are not used for any purpose and are discarded by the +/// expansion code. /// -/// ```rust,ignore -/// frame_support::construct_runtime!( -/// pub enum Test where ... -/// { ... } -/// ); -/// ``` +/// Also note that the `// setup code` and `// verification code` comments shown above are not +/// required and are included simply for demonstration purposes. /// -/// There is an optional fourth argument, with keyword syntax: `benchmarks_path = -/// path_to_benchmarks_invocation`. In the typical case in which this macro is in the same module as -/// the `benchmarks!` invocation, you don't need to supply this. However, if the -/// `impl_benchmark_test_suite!` invocation is in a different module than the `benchmarks!` -/// invocation, then you should provide the path to the module containing the `benchmarks!` -/// invocation: +/// ### `#[extrinsic_call]` and `#[block]` /// -/// ```rust,ignore -/// mod benches { -/// benchmarks!{ -/// ... -/// } -/// } +/// Within the benchmark function body, either an `#[extrinsic_call]` or a `#[block]` +/// annotation is required. These attributes should be attached to a block (shown in +/// `bench_name_2` above) or a one-line function call (shown in `bench_name_1` above, in `syn` +/// parlance this should be an `ExprCall`), respectively. /// -/// mod tests { -/// // because of macro syntax limitations, neither Pallet nor benches can be paths, but both have -/// // to be idents in the scope of `impl_benchmark_test_suite`. -/// use crate::{benches, Pallet}; +/// The `#[block]` syntax is broad and will benchmark any code contained within the block the +/// attribute is attached to. If `#[block]` is attached to something other than a block, a +/// compiler error will be emitted. /// -/// impl_benchmark_test_suite!(Pallet, new_test_ext(), Test, benchmarks_path = benches); +/// The one-line `#[extrinsic_call]` syntax must consist of a function call to an extrinsic, +/// where the first argument is the origin. If `#[extrinsic_call]` is attached to an item that +/// doesn't meet these requirements, a compiler error will be emitted. /// -/// // new_test_ext and the Test item are defined later in this module -/// } -/// ``` -/// -/// There is an optional fifth argument, with keyword syntax: `extra = true` or `extra = false`. -/// By default, this generates a test suite which iterates over all benchmarks, including those -/// marked with the `#[extra]` annotation. Setting `extra = false` excludes those. -/// -/// There is an optional sixth argument, with keyword syntax: `exec_name = custom_exec_name`. -/// By default, this macro uses `execute_with` for this parameter. This argument, if set, is subject -/// to these restrictions: -/// -/// - It must be the name of a method applied to the output of the `new_test_ext` argument. -/// - That method must have a signature capable of receiving a single argument of the form `impl -/// FnOnce()`. -// ## Notes (not for rustdoc) -// -// The biggest challenge for this macro is communicating the actual test functions to be run. We -// can't just build an array of function pointers to each test function and iterate over it, because -// the test functions are parameterized by the `Test` type. That's incompatible with -// monomorphization: if it were legal, then even if the compiler detected and monomorphized the -// functions into only the types of the callers, which implementation would the function pointer -// point to? There would need to be some kind of syntax for selecting the destination of the pointer -// according to a generic argument, and in general it would be a huge mess and not worth it. -// -// Instead, we're going to steal a trick from `fn run_benchmark`: generate a function which is -// itself parametrized by `Test`, which accepts a `&[u8]` parameter containing the name of the -// benchmark, and dispatches based on that to the appropriate real test implementation. Then, we can -// just iterate over the `Benchmarking::benchmarks` list to run the actual implementations. -#[macro_export] -macro_rules! impl_benchmark_test_suite { - ( - $bench_module:ident, - $new_test_ext:expr, - $test:path - $(, $( $rest:tt )* )? - ) => { - $crate::impl_test_function!( - () - () - () - $bench_module, - $new_test_ext, - $test - $(, $( $rest )* )? - ); - } -} - -/// Validates the passed `pov_mode`s. -/// -/// Checks that: -/// - a top-level `ignored` is exclusive -/// - all modes are valid -#[macro_export] -macro_rules! validate_pov_mode { - () => {}; - ( $_bench:ident: ; ) => { }; - ( $_bench:ident: $_car:path = Ignored ; ) => { }; - ( $bench:ident: $_car:path = Ignored $( $storage:path = $_pov_mode:ident )+; ) => { - compile_error!( - concat!(concat!("`pov_mode = Ignored` is exclusive. Please remove the attribute from keys: ", $( stringify!($storage) )+), " on benchmark '", stringify!($bench), "'")); - }; - ( $bench:ident: $car:path = Measured $( $storage:path = $pov_mode:ident )*; ) => { - $crate::validate_pov_mode!( - $bench: $( $storage = $pov_mode )*; - ); - }; - ( $bench:ident: $car:path = MaxEncodedLen $( $storage:path = $pov_mode:ident )*; ) => { - $crate::validate_pov_mode!( - $bench: $( $storage = $pov_mode )*; - ); - }; - ( $bench:ident: $key:path = $unknown:ident $( $_storage:path = $_pov_mode:ident )*; ) => { - compile_error!( - concat!("Unknown pov_mode '", stringify!($unknown) ,"' for benchmark '", stringify!($bench), "' on key '", stringify!($key), "'. Must be one of: Ignored, Measured, MaxEncodedLen") - ); - }; -} - -// Takes all arguments from `impl_benchmark_test_suite` and three additional arguments. -// -// Can be configured to generate one #[test] fn per bench case or -// one #[test] fn for all bench cases. -// This depends on whether or not the first argument contains a non-empty list of bench names. -#[macro_export] -#[doc(hidden)] -macro_rules! impl_test_function { - // user might or might not have set some keyword arguments; set the defaults - // - // The weird syntax indicates that `rest` comes only after a comma, which is otherwise optional - ( - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - - $bench_module:ident, - $new_test_ext:expr, - $test:path - $(, $( $rest:tt )* )? - ) => { - $crate::impl_test_function!( - @cases: - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - @selected: - $bench_module, - $new_test_ext, - $test, - benchmarks_path = super, - extra = true, - exec_name = execute_with, - @user: - $( $( $rest )* )? - ); - }; - // pick off the benchmarks_path keyword argument - ( - @cases: - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - @selected: - $bench_module:ident, - $new_test_ext:expr, - $test:path, - benchmarks_path = $old:ident, - extra = $extra:expr, - exec_name = $exec_name:ident, - @user: - benchmarks_path = $benchmarks_path:ident - $(, $( $rest:tt )* )? - ) => { - $crate::impl_test_function!( - @cases: - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - @selected: - $bench_module, - $new_test_ext, - $test, - benchmarks_path = $benchmarks_path, - extra = $extra, - exec_name = $exec_name, - @user: - $( $( $rest )* )? - ); - }; - // pick off the extra keyword argument - ( - @cases: - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - @selected: - $bench_module:ident, - $new_test_ext:expr, - $test:path, - benchmarks_path = $benchmarks_path:ident, - extra = $old:expr, - exec_name = $exec_name:ident, - @user: - extra = $extra:expr - $(, $( $rest:tt )* )? - ) => { - $crate::impl_test_function!( - @cases: - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - @selected: - $bench_module, - $new_test_ext, - $test, - benchmarks_path = $benchmarks_path, - extra = $extra, - exec_name = $exec_name, - @user: - $( $( $rest )* )? - ); - }; - // pick off the exec_name keyword argument - ( - @cases: - ( $( $names:tt )* ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - @selected: - $bench_module:ident, - $new_test_ext:expr, - $test:path, - benchmarks_path = $benchmarks_path:ident, - extra = $extra:expr, - exec_name = $old:ident, - @user: - exec_name = $exec_name:ident - $(, $( $rest:tt )* )? - ) => { - $crate::impl_test_function!( - @cases: - ( $( $names )* ) - ( $( $names_extra )* ) - ( $( $names_skip_meta )* ) - @selected: - $bench_module, - $new_test_ext, - $test, - benchmarks_path = $benchmarks_path, - extra = $extra, - exec_name = $exec_name, - @user: - $( $( $rest )* )? - ); - }; - // iteration-exit arm which generates a #[test] function for each case. - ( - @cases: - ( $( $names:tt )+ ) - ( $( $names_extra:tt )* ) - ( $( $names_skip_meta:tt )* ) - @selected: - $bench_module:ident, - $new_test_ext:expr, - $test:path, - benchmarks_path = $path_to_benchmarks_invocation:ident, - extra = $extra:expr, - exec_name = $exec_name:ident, - @user: - $(,)? - ) => { - $crate::impl_bench_case_tests!( - { $bench_module, $new_test_ext, $exec_name, $test, $extra } - { $( $names_extra:tt )* } - $($names)+ - ); - }; - // iteration-exit arm which generates one #[test] function for all cases. - ( - @cases: - () - () - () - @selected: - $bench_module:ident, - $new_test_ext:expr, - $test:path, - benchmarks_path = $path_to_benchmarks_invocation:ident, - extra = $extra:expr, - exec_name = $exec_name:ident, - @user: - $(,)? - ) => { - #[cfg(test)] - mod benchmark_tests { - use super::$bench_module; - - #[test] - fn test_benchmarks() { - $new_test_ext.$exec_name(|| { - use $crate::Benchmarking; - - let mut anything_failed = false; - println!("failing benchmark tests:"); - for benchmark_metadata in $bench_module::<$test>::benchmarks($extra) { - let benchmark_name = &benchmark_metadata.name; - match std::panic::catch_unwind(|| { - $bench_module::<$test>::test_bench_by_name(benchmark_name) - }) { - Err(err) => { - println!( - "{}: {:?}", - $crate::str::from_utf8(benchmark_name) - .expect("benchmark name is always a valid string!"), - err, - ); - anything_failed = true; - }, - Ok(Err(err)) => { - match err { - $crate::BenchmarkError::Stop(err) => { - println!( - "{}: {:?}", - $crate::str::from_utf8(benchmark_name) - .expect("benchmark name is always a valid string!"), - err, - ); - anything_failed = true; - }, - $crate::BenchmarkError::Override(_) => { - // This is still considered a success condition. - $crate::log::error!( - "WARNING: benchmark error overrided - {}", - $crate::str::from_utf8(benchmark_name) - .expect("benchmark name is always a valid string!"), - ); - }, - $crate::BenchmarkError::Skip => { - // This is considered a success condition. - $crate::log::error!( - "WARNING: benchmark error skipped - {}", - $crate::str::from_utf8(benchmark_name) - .expect("benchmark name is always a valid string!"), - ); - } - $crate::BenchmarkError::Weightless => { - // This is considered a success condition. - $crate::log::error!( - "WARNING: benchmark weightless skipped - {}", - $crate::str::from_utf8(benchmark_name) - .expect("benchmark name is always a valid string!"), - ); - } - } - }, - Ok(Ok(())) => (), - } - } - assert!(!anything_failed); - }); - } - } - }; -} - -/// show error message and debugging info for the case of an error happening -/// during a benchmark -pub fn show_benchmark_debug_info( - instance_string: &[u8], - benchmark: &[u8], - components: &[(BenchmarkParameter, u32)], - verify: &bool, - error_message: &str, -) -> sp_runtime::RuntimeString { - sp_runtime::format_runtime_string!( - "\n* Pallet: {}\n\ - * Benchmark: {}\n\ - * Components: {:?}\n\ - * Verify: {:?}\n\ - * Error message: {}", - sp_std::str::from_utf8(instance_string) - .expect("it's all just strings ran through the wasm interface. qed"), - sp_std::str::from_utf8(benchmark) - .expect("it's all just strings ran through the wasm interface. qed"), - components, - verify, - error_message, - ) -} - -/// This macro adds pallet benchmarks to a `Vec` object. -/// -/// First create an object that holds in the input parameters for the benchmark: +/// As a short-hand, you may substitute the name of the extrinsic call with `_`, such as the +/// following: /// /// ```ignore -/// let params = (&config, &whitelist); +/// #[extrinsic_call] +/// _(RawOrigin::Signed(whitelisted_caller()), 0u32.into(), 0); /// ``` /// -/// The `whitelist` is a parameter you pass to control the DB read/write tracking. -/// We use a vector of [TrackedStorageKey](./struct.TrackedStorageKey.html), which is a simple -/// struct used to set if a key has been read or written to. +/// The underscore will be substituted with the name of the benchmark (i.e. the name of the +/// function in the benchmark function definition). /// -/// For values that should be skipped entirely, we can just pass `key.into()`. For example: +/// Regardless of whether `#[extrinsic_call]` or `#[block]` is used, this attribute also serves +/// the purpose of designating the boundary between the setup code portion of the benchmark +/// (everything before the `#[extrinsic_call]` or `#[block]` attribute) and the verification +/// stage (everything after the item that the `#[extrinsic_call]` or `#[block]` attribute is +/// attached to). The setup code section should contain any code that needs to execute before +/// the measured portion of the benchmark executes. The verification section is where you can +/// perform assertions to verify that the extrinsic call (or whatever is happening in your +/// block, if you used the `#[block]` syntax) executed successfully. /// -/// ``` -/// use frame_benchmarking::TrackedStorageKey; -/// let whitelist: Vec = vec![ -/// // Block Number -/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"), -/// // Total Issuance -/// array_bytes::hex_into_unchecked("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"), -/// // Execution Phase -/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"), -/// // Event Count -/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"), -/// ]; -/// ``` +/// Note that neither `#[extrinsic_call]` nor `#[block]` are real attribute macros and are +/// instead consumed by the outer macro pattern as part of the enclosing benchmark function +/// definition. This is why we are able to use `#[extrinsic_call]` and `#[block]` within a +/// function definition even though this behavior has not been stabilized +/// yet—`#[extrinsic_call]` and `#[block]` are parsed and consumed as part of the benchmark +/// definition parsing code, so they never expand as their own attribute macros. /// -/// Then define a mutable local variable to hold your `BenchmarkBatch` object: +/// ### Optional Attributes /// -/// ```ignore -/// let mut batches = Vec::::new(); -/// ```` +/// The keywords `extra` and `skip_meta` can be provided as optional arguments to the +/// `#[benchmark]` attribute, i.e. `#[benchmark(extra, skip_meta)]`. Including either of these +/// will enable the `extra` or `skip_meta` option, respectively. These options enable the same +/// behavior they did in the old benchmarking syntax in `frame_benchmarking`, namely: /// -/// Then add the pallets you want to benchmark to this object, using their crate name and generated -/// module struct: +/// #### `extra` /// -/// ```ignore -/// add_benchmark!(params, batches, pallet_balances, Balances); -/// add_benchmark!(params, batches, pallet_session, SessionBench::); -/// add_benchmark!(params, batches, frame_system, SystemBench::); -/// ... -/// ``` +/// Specifies that this benchmark should not normally run. To run benchmarks marked with +/// `extra`, you will need to invoke the `frame-benchmarking-cli` with `--extra`. /// -/// At the end of `dispatch_benchmark`, you should return this batches object. +/// #### `skip_meta` /// -/// In the case where you have multiple instances of a pallet that you need to separately benchmark, -/// the name of your module struct will be used as a suffix to your outputted weight file. For -/// example: +/// Specifies that the benchmarking framework should not analyze the storage keys that +/// benchmarked code read or wrote. This useful to suppress the prints in the form of unknown +/// 0x… in case a storage key that does not have metadata. Note that this skips the analysis +/// of all accesses, not just ones without metadata. /// -/// ```ignore -/// add_benchmark!(params, batches, pallet_balances, Balances); // pallet_balances.rs -/// add_benchmark!(params, batches, pallet_collective, Council); // pallet_collective_council.rs -/// add_benchmark!(params, batches, pallet_collective, TechnicalCommittee); // pallet_collective_technical_committee.rs -/// ``` +/// ## Where Clause /// -/// You can manipulate this suffixed string by using a type alias if needed. For example: +/// Some pallets require a where clause specifying constraints on their generics to make +/// writing benchmarks feasible. To accomodate this situation, you can provide such a where +/// clause as the (only) argument to the `#[benchmarks]` or `#[instance_benchmarks]` attribute +/// macros. Below is an example of this taken from the `message-queue` pallet. /// /// ```ignore -/// type Council2 = TechnicalCommittee; -/// add_benchmark!(params, batches, pallet_collective, Council2); // pallet_collective_council_2.rs +/// #[benchmarks( +/// where +/// <::MessageProcessor as ProcessMessage>::Origin: From + PartialEq, +/// ::Size: From, +/// )] +/// mod benchmarks { +/// use super::*; +/// // ... +/// } /// ``` -#[macro_export] -macro_rules! add_benchmark { - ( $params:ident, $batches:ident, $name:path, $( $location:tt )* ) => ( - let name_string = stringify!($name).as_bytes(); - let instance_string = stringify!( $( $location )* ).as_bytes(); - let (config, whitelist) = $params; - let $crate::BenchmarkConfig { - pallet, - benchmark, - selected_components, - verify, - internal_repeats, - } = config; - if &pallet[..] == &name_string[..] { - let benchmark_result = $( $location )*::run_benchmark( - &benchmark[..], - &selected_components[..], - whitelist, - *verify, - *internal_repeats, - ); - - let final_results = match benchmark_result { - Ok(results) => Some(results), - Err($crate::BenchmarkError::Override(mut result)) => { - // Insert override warning as the first storage key. - $crate::log::error!( - "WARNING: benchmark error overrided - {}", - $crate::str::from_utf8(benchmark) - .expect("benchmark name is always a valid string!") - ); - result.keys.insert(0, - (b"Benchmark Override".to_vec(), 0, 0, false) - ); - Some($crate::vec![result]) - }, - Err($crate::BenchmarkError::Stop(e)) => { - $crate::show_benchmark_debug_info( - instance_string, - benchmark, - selected_components, - verify, - e, - ); - return Err(e.into()); - }, - Err($crate::BenchmarkError::Skip) => { - $crate::log::error!( - "WARNING: benchmark error skipped - {}", - $crate::str::from_utf8(benchmark) - .expect("benchmark name is always a valid string!") - ); - None - }, - Err($crate::BenchmarkError::Weightless) => { - $crate::log::error!( - "WARNING: benchmark weightless skipped - {}", - $crate::str::from_utf8(benchmark) - .expect("benchmark name is always a valid string!") - ); - Some(vec![$crate::BenchmarkResult { - components: selected_components.clone(), - .. Default::default() - }]) - } - }; - - if let Some(final_results) = final_results { - $batches.push($crate::BenchmarkBatch { - pallet: name_string.to_vec(), - instance: instance_string.to_vec(), - benchmark: benchmark.clone(), - results: final_results, - }); - } - } - ) -} - -/// Callback for `define_benchmarks` to call `add_benchmark`. -#[macro_export] -macro_rules! cb_add_benchmarks { - // anchor - ( $params:ident, $batches:ident, [ $name:path, $( $location:tt )* ] ) => { - $crate::add_benchmark!( $params, $batches, $name, $( $location )* ); - }; - // recursion tail - ( $params:ident, $batches:ident, [ $name:path, $( $location:tt )* ] $([ $names:path, $( $locations:tt )* ])+ ) => { - $crate::cb_add_benchmarks!( $params, $batches, [ $name, $( $location )* ] ); - $crate::cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); - } -} - -/// This macro allows users to easily generate a list of benchmarks for the pallets configured -/// in the runtime. -/// -/// To use this macro, first create a an object to store the list: /// -/// ```ignore -/// let mut list = Vec::::new(); -/// ``` +/// ## Benchmark Tests /// -/// Then pass this `list` to the macro, along with the `extra` boolean, the pallet crate, and -/// pallet struct: +/// Benchmark tests can be generated using the old syntax in `frame_benchmarking`, +/// including the `frame_benchmarking::impl_benchmark_test_suite` macro. /// +/// An example is shown below (taken from the `message-queue` pallet's `benchmarking` module): /// ```ignore -/// list_benchmark!(list, extra, pallet_balances, Balances); -/// list_benchmark!(list, extra, pallet_session, SessionBench::); -/// list_benchmark!(list, extra, frame_system, SystemBench::); +/// #[benchmarks] +/// mod benchmarks { +/// use super::*; +/// // ... +/// impl_benchmark_test_suite!( +/// MessageQueue, +/// crate::mock::new_test_ext::(), +/// crate::integration_test::Test +/// ); +/// } /// ``` -/// -/// This should match what exists with the `add_benchmark!` macro. -#[macro_export] -macro_rules! list_benchmark { - ( $list:ident, $extra:ident, $name:path, $( $location:tt )* ) => ( - let pallet_string = stringify!($name).as_bytes(); - let instance_string = stringify!( $( $location )* ).as_bytes(); - let benchmarks = $( $location )*::benchmarks($extra); - let pallet_benchmarks = BenchmarkList { - pallet: pallet_string.to_vec(), - instance: instance_string.to_vec(), - benchmarks: benchmarks.to_vec(), - }; - $list.push(pallet_benchmarks) - ) -} - -/// Callback for `define_benchmarks` to call `list_benchmark`. -#[macro_export] -macro_rules! cb_list_benchmarks { - // anchor - ( $list:ident, $extra:ident, [ $name:path, $( $location:tt )* ] ) => { - $crate::list_benchmark!( $list, $extra, $name, $( $location )* ); - }; - // recursion tail - ( $list:ident, $extra:ident, [ $name:path, $( $location:tt )* ] $([ $names:path, $( $locations:tt )* ])+ ) => { - $crate::cb_list_benchmarks!( $list, $extra, [ $name, $( $location )* ] ); - $crate::cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); +pub mod v2 { + pub use super::*; + pub use frame_support_procedural::{ + benchmark, benchmarks, block, extrinsic_call, instance_benchmarks, + }; + + // Used in #[benchmark] implementation to ensure that benchmark function arguments + // implement [`ParamRange`]. + #[doc(hidden)] + pub use static_assertions::assert_impl_all; + + /// Used by the new benchmarking code to specify that a benchmarking variable is linear + /// over some specified range, i.e. `Linear<0, 1_000>` means that the corresponding variable + /// is allowed to range from `0` to `1000`, inclusive. + /// + /// See [`v2`] for more info. + pub struct Linear; + + /// Trait that must be implemented by all structs that can be used as parameter range types + /// in the new benchmarking code (i.e. `Linear<0, 1_000>`). Right now there is just + /// [`Linear`] but this could later be extended to support additional non-linear parameter + /// ranges. + /// + /// See [`v2`] for more info. + pub trait ParamRange { + /// Represents the (inclusive) starting number of this `ParamRange`. + fn start(&self) -> u32; + + /// Represents the (inclusive) ending number of this `ParamRange`. + fn end(&self) -> u32; } -} -/// Defines pallet configs that `add_benchmarks` and `list_benchmarks` use. -/// Should be preferred instead of having a repetitive list of configs -/// in `add_benchmark` and `list_benchmark`. -#[macro_export] -macro_rules! define_benchmarks { - ( $([ $names:path, $( $locations:tt )* ])* ) => { - /// Calls `list_benchmark` with all configs from `define_benchmarks` - /// and passes the first two parameters on. - /// - /// Use as: - /// ```ignore - /// list_benchmarks!(list, extra); - /// ``` - #[macro_export] - macro_rules! list_benchmarks { - ( $list:ident, $extra:ident ) => { - $crate::cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); - } + impl ParamRange for Linear { + fn start(&self) -> u32 { + A } - /// Calls `add_benchmark` with all configs from `define_benchmarks` - /// and passes the first two parameters on. - /// - /// Use as: - /// ```ignore - /// add_benchmarks!(params, batches); - /// ``` - #[macro_export] - macro_rules! add_benchmarks { - ( $params:ident, $batches:ident ) => { - $crate::cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); - } + fn end(&self) -> u32 { + B } } } diff --git a/frame/benchmarking/src/v1.rs b/frame/benchmarking/src/v1.rs new file mode 100644 index 0000000000..089083f85b --- /dev/null +++ b/frame/benchmarking/src/v1.rs @@ -0,0 +1,2043 @@ +// This file is part of Substrate. + +// Copyright (C) 2020-2023 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Macros for benchmarking a FRAME runtime. + +pub use super::*; + +/// Whitelist the given account. +#[macro_export] +macro_rules! whitelist { + ($acc:ident) => { + frame_benchmarking::benchmarking::add_to_whitelist( + frame_system::Account::::hashed_key_for(&$acc).into(), + ); + }; +} + +/// Construct pallet benchmarks for weighing dispatchables. +/// +/// Works around the idea of complexity parameters, named by a single letter (which is usually +/// upper cased in complexity notation but is lower-cased for use in this macro). +/// +/// Complexity parameters ("parameters") have a range which is a `u32` pair. Every time a benchmark +/// is prepared and run, this parameter takes a concrete value within the range. There is an +/// associated instancing block, which is a single expression that is evaluated during +/// preparation. It may use `?` (`i.e. `return Err(...)`) to bail with a string error. Here's a +/// few examples: +/// +/// ```ignore +/// // These two are equivalent: +/// let x in 0 .. 10; +/// let x in 0 .. 10 => (); +/// // This one calls a setup function and might return an error (which would be terminal). +/// let y in 0 .. 10 => setup(y)?; +/// // This one uses a code block to do lots of stuff: +/// let z in 0 .. 10 => { +/// let a = z * z / 5; +/// let b = do_something(a)?; +/// combine_into(z, b); +/// } +/// ``` +/// +/// Note that due to parsing restrictions, if the `from` expression is not a single token (i.e. a +/// literal or constant), then it must be parenthesized. +/// +/// The macro allows for a number of "arms", each representing an individual benchmark. Using the +/// simple syntax, the associated dispatchable function maps 1:1 with the benchmark and the name of +/// the benchmark is the same as that of the associated function. However, extended syntax allows +/// for arbitrary expressions to be evaluated in a benchmark (including for example, +/// `on_initialize`). +/// +/// Note that the ranges are *inclusive* on both sides. This is in contrast to ranges in Rust which +/// are left-inclusive right-exclusive. +/// +/// Each arm may also have a block of code which is run prior to any instancing and a block of code +/// which is run afterwards. All code blocks may draw upon the specific value of each parameter +/// at any time. Local variables are shared between the two pre- and post- code blocks, but do not +/// leak from the interior of any instancing expressions. +/// +/// Example: +/// ```ignore +/// benchmarks! { +/// where_clause { where T::A: From } // Optional line to give additional bound on `T`. +/// +/// // first dispatchable: foo; this is a user dispatchable and operates on a `u8` vector of +/// // size `l` +/// foo { +/// let caller = account::(b"caller", 0, benchmarks_seed); +/// let l in 1 .. MAX_LENGTH => initialize_l(l); +/// }: _(RuntimeOrigin::Signed(caller), vec![0u8; l]) +/// +/// // second dispatchable: bar; this is a root dispatchable and accepts a `u8` vector of size +/// // `l`. +/// // In this case, we explicitly name the call using `bar` instead of `_`. +/// bar { +/// let l in 1 .. MAX_LENGTH => initialize_l(l); +/// }: bar(RuntimeOrigin::Root, vec![0u8; l]) +/// +/// // third dispatchable: baz; this is a user dispatchable. It isn't dependent on length like the +/// // other two but has its own complexity `c` that needs setting up. It uses `caller` (in the +/// // pre-instancing block) within the code block. This is only allowed in the param instancers +/// // of arms. +/// baz1 { +/// let caller = account::(b"caller", 0, benchmarks_seed); +/// let c = 0 .. 10 => setup_c(&caller, c); +/// }: baz(RuntimeOrigin::Signed(caller)) +/// +/// // this is a second benchmark of the baz dispatchable with a different setup. +/// baz2 { +/// let caller = account::(b"caller", 0, benchmarks_seed); +/// let c = 0 .. 10 => setup_c_in_some_other_way(&caller, c); +/// }: baz(RuntimeOrigin::Signed(caller)) +/// +/// // You may optionally specify the origin type if it can't be determined automatically like +/// // this. +/// baz3 { +/// let caller = account::(b"caller", 0, benchmarks_seed); +/// let l in 1 .. MAX_LENGTH => initialize_l(l); +/// }: baz(RuntimeOrigin::Signed(caller), vec![0u8; l]) +/// +/// // this is benchmarking some code that is not a dispatchable. +/// populate_a_set { +/// let x in 0 .. 10_000; +/// let mut m = Vec::::new(); +/// for i in 0..x { +/// m.insert(i); +/// } +/// }: { m.into_iter().collect::() } +/// } +/// ``` +/// +/// Test functions are automatically generated for each benchmark and are accessible to you when you +/// run `cargo test`. All tests are named `test_benchmark_`, implemented on the +/// Pallet struct, and run them in a test externalities environment. The test function runs your +/// benchmark just like a regular benchmark, but only testing at the lowest and highest values for +/// each component. The function will return `Ok(())` if the benchmarks return no errors. +/// +/// It is also possible to generate one #[test] function per benchmark by calling the +/// `impl_benchmark_test_suite` macro inside the `benchmarks` block. The functions will be named +/// `bench_` and can be run via `cargo test`. +/// You will see one line of output per benchmark. This approach will give you more understandable +/// error messages and allows for parallel benchmark execution. +/// +/// You can optionally add a `verify` code block at the end of a benchmark to test any final state +/// of your benchmark in a unit test. For example: +/// +/// ```ignore +/// sort_vector { +/// let x in 1 .. 10000; +/// let mut m = Vec::::new(); +/// for i in (0..x).rev() { +/// m.push(i); +/// } +/// }: { +/// m.sort(); +/// } verify { +/// ensure!(m[0] == 0, "You forgot to sort!") +/// } +/// ``` +/// +/// These `verify` blocks will not affect your benchmark results! +/// +/// You can construct benchmark by using the `impl_benchmark_test_suite` macro or +/// by manually implementing them like so: +/// +/// ```ignore +/// #[test] +/// fn test_benchmarks() { +/// new_test_ext().execute_with(|| { +/// assert_ok!(Pallet::::test_benchmark_dummy()); +/// assert_err!(Pallet::::test_benchmark_other_name(), "Bad origin"); +/// assert_ok!(Pallet::::test_benchmark_sort_vector()); +/// assert_err!(Pallet::::test_benchmark_broken_benchmark(), "You forgot to sort!"); +/// }); +/// } +/// ``` +#[macro_export] +macro_rules! benchmarks { + ( + $( $rest:tt )* + ) => { + $crate::benchmarks_iter!( + { } + { } + { } + ( ) + ( ) + ( ) + ( ) + $( $rest )* + ); + } +} + +/// Same as [`benchmarks`] but for instantiable module. +/// +/// NOTE: For pallet declared with [`frame_support::pallet`], use [`benchmarks_instance_pallet`]. +#[macro_export] +macro_rules! benchmarks_instance { + ( + $( $rest:tt )* + ) => { + $crate::benchmarks_iter!( + { } + { I: Instance } + { } + ( ) + ( ) + ( ) + ( ) + $( $rest )* + ); + } +} + +/// Same as [`benchmarks`] but for instantiable pallet declared [`frame_support::pallet`]. +/// +/// NOTE: For pallet declared with `decl_module!`, use [`benchmarks_instance`]. +#[macro_export] +macro_rules! benchmarks_instance_pallet { + ( + $( $rest:tt )* + ) => { + $crate::benchmarks_iter!( + { } + { I: 'static } + { } + ( ) + ( ) + ( ) + ( ) + $( $rest )* + ); + } +} + +#[macro_export] +#[doc(hidden)] +macro_rules! benchmarks_iter { + // detect and extract `impl_benchmark_test_suite` call: + // - with a semi-colon + ( + { } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + impl_benchmark_test_suite!( + $bench_module:ident, + $new_test_ext:expr, + $test:path + $(, $( $args:tt )* )?); + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $bench_module, $new_test_ext, $test $(, $( $args )* )? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( $rest )* + } + }; + // - without a semicolon + ( + { } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + impl_benchmark_test_suite!( + $bench_module:ident, + $new_test_ext:expr, + $test:path + $(, $( $args:tt )* )?) + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $bench_module, $new_test_ext, $test $(, $( $args )* )? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( $rest )* + } + }; + // detect and extract where clause: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + where_clause { where $( $where_bound:tt )* } + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound)? } + { $( $where_bound )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( $rest )* + } + }; + // detect and extract `#[skip_meta]` tag: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + #[skip_meta] + $( #[ $($attributes:tt)+ ] )* + $name:ident + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* $name ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( #[ $( $attributes )+ ] )* + $name + $( $rest )* + } + }; + // detect and extract `#[extra]` tag: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + #[extra] + $( #[ $($attributes:tt)+ ] )* + $name:ident + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* $name ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( #[ $( $attributes )+ ] )* + $name + $( $rest )* + } + }; + // detect and extract `#[pov_mode = Mode { Pallet::Storage: Mode ... }]` tag: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $old_pov_name:ident: $( $old_storage:path = $old_pov_mode:ident )*; )* ) + #[pov_mode = $mode:ident $( { $( $storage:path: $pov_mode:ident )* } )?] + $( #[ $($attributes:tt)+ ] )* + $name:ident + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $name: ALL = $mode $($( $storage = $pov_mode )*)?; $( $old_pov_name: $( $old_storage = $old_pov_mode )*; )* ) + $( #[ $( $attributes )+ ] )* + $name + $( $rest )* + } + }; + // mutation arm: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) // This contains $( $( { $instance } )? $name:ident )* + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + $name:ident { $( $code:tt )* }: _ $(< $origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) + verify $postcode:block + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $name { $( $code )* }: $name $(< $origin_type >)? ( $origin $( , $arg )* ) + verify $postcode + $( $rest )* + } + }; + // mutation arm: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + $name:ident { $( $code:tt )* }: $dispatch:ident $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) + verify $postcode:block + $( $rest:tt )* + ) => { + $crate::paste::paste! { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $name { + $( $code )* + let __call = Call::< + T + $( , $instance )? + >:: [< new_call_variant_ $dispatch >] ( + $($arg),* + ); + let __benchmarked_call_encoded = $crate::frame_support::codec::Encode::encode( + &__call + ); + }: { + let __call_decoded = < + Call + as $crate::frame_support::codec::Decode + >::decode(&mut &__benchmarked_call_encoded[..]) + .expect("call is encoded above, encoding must be correct"); + let __origin = $crate::to_origin!($origin $(, $origin_type)?); + as $crate::frame_support::traits::UnfilteredDispatchable + >::dispatch_bypass_filter(__call_decoded, __origin)?; + } + verify $postcode + $( $rest )* + } + } + }; + // iteration arm: + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + $name:ident { $( $code:tt )* }: $eval:block + verify $postcode:block + $( $rest:tt )* + ) => { + $crate::benchmark_backend! { + { $( $instance: $instance_bound )? } + $name + { $( $where_clause )* } + { } + { $eval } + { $( $code )* } + $postcode + } + + #[cfg(test)] + $crate::impl_benchmark_test!( + { $( $where_clause )* } + { $( $instance: $instance_bound )? } + $name + ); + + $crate::benchmarks_iter!( + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* { $( $instance )? } $name ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $( $rest )* + ); + }; + // iteration-exit arm which generates a #[test] function for each case. + ( + { $bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + ) => { + $crate::selected_benchmark!( + { $( $where_clause)* } + { $( $instance: $instance_bound )? } + $( $names )* + ); + $crate::impl_benchmark!( + { $( $where_clause )* } + { $( $instance: $instance_bound )? } + ( $( $names )* ) + ( $( $names_extra ),* ) + ( $( $names_skip_meta ),* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + ); + $crate::impl_test_function!( + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + $bench_module, + $new_test_ext, + $test + $(, $( $args )* )? + ); + }; + // iteration-exit arm which doesn't generate a #[test] function for all cases. + ( + { } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + ) => { + $crate::selected_benchmark!( + { $( $where_clause)* } + { $( $instance: $instance_bound )? } + $( $names )* + ); + $crate::impl_benchmark!( + { $( $where_clause )* } + { $( $instance: $instance_bound )? } + ( $( $names )* ) + ( $( $names_extra ),* ) + ( $( $names_skip_meta ),* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + ); + }; + // add verify block to _() format + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + $name:ident { $( $code:tt )* }: _ $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $name { $( $code )* }: _ $(<$origin_type>)? ( $origin $( , $arg )* ) + verify { } + $( $rest )* + } + }; + // add verify block to name() format + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + $name:ident { $( $code:tt )* }: $dispatch:ident $(<$origin_type:ty>)? ( $origin:expr $( , $arg:expr )* ) + $( $rest:tt )* + ) => { + $crate::benchmarks_iter! { + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $name { $( $code )* }: $dispatch $(<$origin_type>)? ( $origin $( , $arg )* ) + verify { } + $( $rest )* + } + }; + // add verify block to {} format + ( + { $($bench_module:ident, $new_test_ext:expr, $test:path $(, $( $args:tt )* )?)? } + { $( $instance:ident: $instance_bound:tt )? } + { $( $where_clause:tt )* } + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + $name:ident { $( $code:tt )* }: $(<$origin_type:ty>)? $eval:block + $( $rest:tt )* + ) => { + $crate::benchmarks_iter!( + { $($bench_module, $new_test_ext, $test $(, $( $args )* )?)? } + { $( $instance: $instance_bound )? } + { $( $where_clause )* } + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + ( $( $pov_name: $( $storage = $pov_mode )*; )* ) + $name { $( $code )* }: $(<$origin_type>)? $eval + verify { } + $( $rest )* + ); + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! to_origin { + ($origin:expr) => { + $origin.into() + }; + ($origin:expr, $origin_type:ty) => { + <::RuntimeOrigin as From<$origin_type>>::from($origin) + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! benchmark_backend { + // parsing arms + ( + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + { $( $where_clause:tt )* } + { $( PRE { $( $pre_parsed:tt )* } )* } + { $eval:block } + { + let $pre_id:tt : $pre_ty:ty = $pre_ex:expr; + $( $rest:tt )* + } + $postcode:block + ) => { + $crate::benchmark_backend! { + { $( $instance: $instance_bound )? } + $name + { $( $where_clause )* } + { + $( PRE { $( $pre_parsed )* } )* + PRE { $pre_id , $pre_ty , $pre_ex } + } + { $eval } + { $( $rest )* } + $postcode + } + }; + ( + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + { $( $where_clause:tt )* } + { $( $parsed:tt )* } + { $eval:block } + { + let $param:ident in ( $param_from:expr ) .. $param_to:expr => $param_instancer:expr; + $( $rest:tt )* + } + $postcode:block + ) => { + $crate::benchmark_backend! { + { $( $instance: $instance_bound )? } + $name + { $( $where_clause )* } + { + $( $parsed )* + PARAM { $param , $param_from , $param_to , $param_instancer } + } + { $eval } + { $( $rest )* } + $postcode + } + }; + // mutation arm to look after a single tt for param_from. + ( + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + { $( $where_clause:tt )* } + { $( $parsed:tt )* } + { $eval:block } + { + let $param:ident in $param_from:tt .. $param_to:expr => $param_instancer:expr ; + $( $rest:tt )* + } + $postcode:block + ) => { + $crate::benchmark_backend! { + { $( $instance: $instance_bound )? } + $name + { $( $where_clause )* } + { $( $parsed )* } + { $eval } + { + let $param in ( $param_from ) .. $param_to => $param_instancer; + $( $rest )* + } + $postcode + } + }; + // mutation arm to look after the default tail of `=> ()` + ( + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + { $( $where_clause:tt )* } + { $( $parsed:tt )* } + { $eval:block } + { + let $param:ident in $param_from:tt .. $param_to:expr; + $( $rest:tt )* + } + $postcode:block + ) => { + $crate::benchmark_backend! { + { $( $instance: $instance_bound )? } + $name + { $( $where_clause )* } + { $( $parsed )* } + { $eval } + { + let $param in $param_from .. $param_to => (); + $( $rest )* + } + $postcode + } + }; + // mutation arm to look after `let _ =` + ( + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + { $( $where_clause:tt )* } + { $( $parsed:tt )* } + { $eval:block } + { + let $pre_id:tt = $pre_ex:expr; + $( $rest:tt )* + } + $postcode:block + ) => { + $crate::benchmark_backend! { + { $( $instance: $instance_bound )? } + $name + { $( $where_clause )* } + { $( $parsed )* } + { $eval } + { + let $pre_id : _ = $pre_ex; + $( $rest )* + } + $postcode + } + }; + // actioning arm + ( + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + { $( $where_clause:tt )* } + { + $( PRE { $pre_id:tt , $pre_ty:ty , $pre_ex:expr } )* + $( PARAM { $param:ident , $param_from:expr , $param_to:expr , $param_instancer:expr } )* + } + { $eval:block } + { $( $post:tt )* } + $postcode:block + ) => { + #[allow(non_camel_case_types)] + struct $name; + #[allow(unused_variables)] + impl, $instance: $instance_bound )? > + $crate::BenchmarkingSetup for $name + where $( $where_clause )* + { + fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> { + $crate::vec! [ + $( + ($crate::BenchmarkParameter::$param, $param_from, $param_to) + ),* + ] + } + + fn instance( + &self, + components: &[($crate::BenchmarkParameter, u32)], + verify: bool + ) -> Result<$crate::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { + $( + // Prepare instance + let $param = components.iter() + .find(|&c| c.0 == $crate::BenchmarkParameter::$param) + .ok_or("Could not find component in benchmark preparation.")? + .1; + )* + $( + let $pre_id : $pre_ty = $pre_ex; + )* + $( $param_instancer ; )* + $( $post )* + + Ok($crate::Box::new(move || -> Result<(), $crate::BenchmarkError> { + $eval; + if verify { + $postcode; + } + Ok(()) + })) + } + } + }; +} + +// Creates #[test] functions for the given bench cases. +#[macro_export] +#[doc(hidden)] +macro_rules! impl_bench_case_tests { + ( + { $module:ident, $new_test_exec:expr, $exec_name:ident, $test:path, $extra:expr } + { $( $names_extra:tt )* } + $( { $( $bench_inst:ident )? } $bench:ident )* + ) + => { + $crate::impl_bench_name_tests!( + $module, $new_test_exec, $exec_name, $test, $extra, + { $( $names_extra )* }, + $( { $bench } )+ + ); + } +} + +// Creates a #[test] function for the given bench name. +#[macro_export] +#[doc(hidden)] +macro_rules! impl_bench_name_tests { + // recursion anchor + ( + $module:ident, $new_test_exec:expr, $exec_name:ident, $test:path, $extra:expr, + { $( $names_extra:tt )* }, + { $name:ident } + ) => { + $crate::paste::paste! { + #[test] + fn [] () { + $new_test_exec.$exec_name(|| { + // Skip all #[extra] benchmarks if $extra is false. + if !($extra) { + let disabled = $crate::vec![ $( stringify!($names_extra).as_ref() ),* ]; + if disabled.contains(&stringify!($name)) { + $crate::log::error!( + "INFO: extra benchmark skipped - {}", + stringify!($name), + ); + return (); + } + } + + // Same per-case logic as when all cases are run in the + // same function. + match std::panic::catch_unwind(|| { + $module::<$test>::[< test_benchmark_ $name >] () + }) { + Err(err) => { + panic!("{}: {:?}", stringify!($name), err); + }, + Ok(Err(err)) => { + match err { + $crate::BenchmarkError::Stop(err) => { + panic!("{}: {:?}", stringify!($name), err); + }, + $crate::BenchmarkError::Override(_) => { + // This is still considered a success condition. + $crate::log::error!( + "WARNING: benchmark error overrided - {}", + stringify!($name), + ); + }, + $crate::BenchmarkError::Skip => { + // This is considered a success condition. + $crate::log::error!( + "WARNING: benchmark error skipped - {}", + stringify!($name), + ); + }, + $crate::BenchmarkError::Weightless => { + // This is considered a success condition. + $crate::log::error!( + "WARNING: benchmark weightless skipped - {}", + stringify!($name), + ); + } + } + }, + Ok(Ok(())) => (), + } + }); + } + } + }; + // recursion tail + ( + $module:ident, $new_test_exec:expr, $exec_name:ident, $test:path, $extra:expr, + { $( $names_extra:tt )* }, + { $name:ident } $( { $rest:ident } )+ + ) => { + // car + $crate::impl_bench_name_tests!($module, $new_test_exec, $exec_name, $test, $extra, + { $( $names_extra )* }, { $name }); + // cdr + $crate::impl_bench_name_tests!($module, $new_test_exec, $exec_name, $test, $extra, + { $( $names_extra )* }, $( { $rest } )+); + }; +} + +// 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 { + ( + { $( $where_clause:tt )* } + { $( $instance:ident: $instance_bound:tt )? } + $( { $( $bench_inst:ident )? } $bench:ident )* + ) => { + // The list of available benchmarks for this pallet. + #[allow(non_camel_case_types)] + enum SelectedBenchmark { + $( $bench, )* + } + + // Allow us to select a benchmark from the list of available benchmarks. + impl, $instance: $instance_bound )? > + $crate::BenchmarkingSetup for SelectedBenchmark + where $( $where_clause )* + { + fn components(&self) -> $crate::Vec<($crate::BenchmarkParameter, u32, u32)> { + match self { + $( + Self::$bench => < + $bench as $crate::BenchmarkingSetup + >::components(&$bench), + )* + } + } + + fn instance( + &self, + components: &[($crate::BenchmarkParameter, u32)], + verify: bool + ) -> Result<$crate::Box Result<(), $crate::BenchmarkError>>, $crate::BenchmarkError> { + match self { + $( + Self::$bench => < + $bench as $crate::BenchmarkingSetup + >::instance(&$bench, components, verify), + )* + } + } + } + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! impl_benchmark { + ( + { $( $where_clause:tt )* } + { $( $instance:ident: $instance_bound:tt )? } + ( $( { $( $name_inst:ident )? } $name:ident )* ) + ( $( $name_extra:ident ),* ) + ( $( $name_skip_meta:ident ),* ) + ( $( $pov_name:ident: $( $storage:path = $pov_mode:ident )*; )* ) + ) => { + // We only need to implement benchmarks for the runtime-benchmarks feature or testing. + #[cfg(any(feature = "runtime-benchmarks", test))] + impl, $instance: $instance_bound )? > + $crate::Benchmarking for Pallet + where T: frame_system::Config, $( $where_clause )* + { + fn benchmarks(extra: bool) -> $crate::Vec<$crate::BenchmarkMetadata> { + $($crate::validate_pov_mode!( + $pov_name: $( $storage = $pov_mode )*; + );)* + let mut all_names = $crate::vec![ $( stringify!($name).as_ref() ),* ]; + if !extra { + let extra = [ $( stringify!($name_extra).as_ref() ),* ]; + all_names.retain(|x| !extra.contains(x)); + } + let pov_modes: $crate::Vec<($crate::Vec, $crate::Vec<($crate::Vec, $crate::Vec)>)> = $crate::vec![ + $( + (stringify!($pov_name).as_bytes().to_vec(), + $crate::vec![ + $( ( stringify!($storage).as_bytes().to_vec(), + stringify!($pov_mode).as_bytes().to_vec() ), )* + ]), + )* + ]; + all_names.into_iter().map(|benchmark| { + let selected_benchmark = match benchmark { + $( stringify!($name) => SelectedBenchmark::$name, )* + _ => panic!("all benchmarks should be selectable"), + }; + let name = benchmark.as_bytes().to_vec(); + let components = < + SelectedBenchmark as $crate::BenchmarkingSetup + >::components(&selected_benchmark); + + $crate::BenchmarkMetadata { + name: name.clone(), + components, + pov_modes: pov_modes.iter().find(|p| p.0 == name).map(|p| p.1.clone()).unwrap_or_default(), + } + }).collect::<$crate::Vec<_>>() + } + + fn run_benchmark( + extrinsic: &[u8], + c: &[($crate::BenchmarkParameter, u32)], + whitelist: &[$crate::TrackedStorageKey], + verify: bool, + internal_repeats: u32, + ) -> Result<$crate::Vec<$crate::BenchmarkResult>, $crate::BenchmarkError> { + // Map the input to the selected benchmark. + let extrinsic = $crate::str::from_utf8(extrinsic) + .map_err(|_| "`extrinsic` is not a valid utf8 string!")?; + let selected_benchmark = match extrinsic { + $( stringify!($name) => SelectedBenchmark::$name, )* + _ => return Err("Could not find extrinsic.".into()), + }; + + // Add whitelist to DB including whitelisted caller + let mut whitelist = whitelist.to_vec(); + let whitelisted_caller_key = + as $crate::frame_support::storage::StorageMap<_,_>>::hashed_key_for( + $crate::whitelisted_caller::() + ); + whitelist.push(whitelisted_caller_key.into()); + // Whitelist the transactional layer. + let transactional_layer_key = $crate::TrackedStorageKey::new( + $crate::frame_support::storage::transactional::TRANSACTION_LEVEL_KEY.into() + ); + whitelist.push(transactional_layer_key); + // Whitelist the `:extrinsic_index`. + let extrinsic_index = $crate::TrackedStorageKey::new( + $crate::well_known_keys::EXTRINSIC_INDEX.into() + ); + whitelist.push(extrinsic_index); + + $crate::benchmarking::set_whitelist(whitelist.clone()); + + let mut results: $crate::Vec<$crate::BenchmarkResult> = $crate::Vec::new(); + + // Always do at least one internal repeat... + for _ in 0 .. internal_repeats.max(1) { + // Always reset the state after the benchmark. + $crate::defer!($crate::benchmarking::wipe_db()); + + // Set up the externalities environment for the setup we want to + // benchmark. + let closure_to_benchmark = < + SelectedBenchmark as $crate::BenchmarkingSetup + >::instance(&selected_benchmark, c, verify)?; + + // Set the block number to at least 1 so events are deposited. + if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); + } + + // Commit the externalities to the database, flushing the DB cache. + // This will enable worst case scenario for reading from the database. + $crate::benchmarking::commit_db(); + + // Access all whitelisted keys to get them into the proof recorder since the + // recorder does now have a whitelist. + for key in &whitelist { + $crate::frame_support::storage::unhashed::get_raw(&key.key); + } + + // 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. + $crate::log::trace!( + target: "benchmark", + "Start Benchmark: {} ({:?}) verify {}", + extrinsic, + c, + verify + ); + + let start_pov = $crate::benchmarking::proof_size(); + let start_extrinsic = $crate::benchmarking::current_time(); + + closure_to_benchmark()?; + + let finish_extrinsic = $crate::benchmarking::current_time(); + let end_pov = $crate::benchmarking::proof_size(); + + // Calculate the diff caused by the benchmark. + let elapsed_extrinsic = finish_extrinsic.saturating_sub(start_extrinsic); + let diff_pov = match (start_pov, end_pov) { + (Some(start), Some(end)) => end.saturating_sub(start), + _ => Default::default(), + }; + + // Commit the changes to get proper write count + $crate::benchmarking::commit_db(); + $crate::log::trace!( + target: "benchmark", + "End Benchmark: {} ns", elapsed_extrinsic + ); + let read_write_count = $crate::benchmarking::read_write_count(); + $crate::log::trace!( + target: "benchmark", + "Read/Write Count {:?}", read_write_count + ); + $crate::log::trace!( + target: "benchmark", + "Proof sizes: before {:?} after {:?} diff {}", &start_pov, &end_pov, &diff_pov + ); + + // Time the storage root recalculation. + let start_storage_root = $crate::benchmarking::current_time(); + $crate::storage_root($crate::StateVersion::V1); + let finish_storage_root = $crate::benchmarking::current_time(); + let elapsed_storage_root = finish_storage_root - start_storage_root; + + let skip_meta = [ $( stringify!($name_skip_meta).as_ref() ),* ]; + let read_and_written_keys = if skip_meta.contains(&extrinsic) { + $crate::vec![(b"Skipped Metadata".to_vec(), 0, 0, false)] + } else { + $crate::benchmarking::get_read_and_written_keys() + }; + + results.push($crate::BenchmarkResult { + components: c.to_vec(), + 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, + proof_size: diff_pov, + keys: read_and_written_keys, + }); + } + + return Ok(results); + } + } + + #[cfg(test)] + impl, $instance: $instance_bound )? > + Pallet + where T: frame_system::Config, $( $where_clause )* + { + /// Test a particular benchmark by name. + /// + /// This isn't called `test_benchmark_by_name` just in case some end-user eventually + /// writes a benchmark, itself called `by_name`; the function would be shadowed in + /// that case. + /// + /// This is generally intended to be used by child test modules such as those created + /// by the `impl_benchmark_test_suite` macro. However, it is not an error if a pallet + /// author chooses not to implement benchmarks. + #[allow(unused)] + fn test_bench_by_name(name: &[u8]) -> Result<(), $crate::BenchmarkError> { + let name = $crate::str::from_utf8(name) + .map_err(|_| -> $crate::BenchmarkError { "`name` is not a valid utf8 string!".into() })?; + match name { + $( stringify!($name) => { + $crate::paste::paste! { Self::[< test_benchmark_ $name >]() } + } )* + _ => Err("Could not find test for requested benchmark.".into()), + } + } + } + }; +} + +// 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. +// Instances each component with six values which can be controlled with the +// env variable `VALUES_PER_COMPONENT`. +#[macro_export] +#[doc(hidden)] +macro_rules! impl_benchmark_test { + ( + { $( $where_clause:tt )* } + { $( $instance:ident: $instance_bound:tt )? } + $name:ident + ) => { + $crate::paste::item! { + #[cfg(test)] + impl, $instance: $instance_bound )? > + Pallet + where T: frame_system::Config, $( $where_clause )* + { + #[allow(unused)] + fn [] () -> Result<(), $crate::BenchmarkError> { + let selected_benchmark = SelectedBenchmark::$name; + let components = < + SelectedBenchmark as $crate::BenchmarkingSetup + >::components(&selected_benchmark); + + let execute_benchmark = | + c: $crate::Vec<($crate::BenchmarkParameter, u32)> + | -> Result<(), $crate::BenchmarkError> { + // Always reset the state after the benchmark. + $crate::defer!($crate::benchmarking::wipe_db()); + + // Set up the benchmark, return execution + verification function. + let closure_to_verify = < + SelectedBenchmark as $crate::BenchmarkingSetup + >::instance(&selected_benchmark, &c, true)?; + + // Set the block number to at least 1 so events are deposited. + if $crate::Zero::is_zero(&frame_system::Pallet::::block_number()) { + frame_system::Pallet::::set_block_number(1u32.into()); + } + + // Run execution + verification + closure_to_verify() + }; + + if components.is_empty() { + execute_benchmark(Default::default())?; + } else { + let num_values: u32 = if let Ok(ev) = std::env::var("VALUES_PER_COMPONENT") { + ev.parse().map_err(|_| { + $crate::BenchmarkError::Stop( + "Could not parse env var `VALUES_PER_COMPONENT` as u32." + ) + })? + } else { + 6 + }; + + if num_values < 2 { + return Err("`VALUES_PER_COMPONENT` must be at least 2".into()); + } + + for (name, low, high) in components.clone().into_iter() { + // Test the lowest, highest (if its different from the lowest) + // and up to num_values-2 more equidistant values in between. + // For 0..10 and num_values=6 this would mean: [0, 2, 4, 6, 8, 10] + + let mut values = $crate::vec![low]; + let diff = (high - low).min(num_values - 1); + let slope = (high - low) as f32 / diff as f32; + + for i in 1..=diff { + let value = ((low as f32 + slope * i as f32) as u32) + .clamp(low, high); + values.push(value); + } + + for component_value in values { + // Select the max value for all the other components. + let c: $crate::Vec<($crate::BenchmarkParameter, u32)> = components + .iter() + .map(|(n, _, h)| + if *n == name { + (*n, component_value) + } else { + (*n, *h) + } + ) + .collect(); + + execute_benchmark(c)?; + } + } + } + Ok(()) + } + } + } + }; +} + +/// This creates a test suite which runs the module's benchmarks. +/// +/// When called in `pallet_example_basic` as +/// +/// ```rust,ignore +/// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); +/// ``` +/// +/// It expands to the equivalent of: +/// +/// ```rust,ignore +/// #[cfg(test)] +/// mod tests { +/// use super::*; +/// use crate::tests::{new_test_ext, Test}; +/// use frame_support::assert_ok; +/// +/// #[test] +/// fn test_benchmarks() { +/// new_test_ext().execute_with(|| { +/// assert_ok!(test_benchmark_accumulate_dummy::()); +/// assert_ok!(test_benchmark_set_dummy::()); +/// assert_ok!(test_benchmark_sort_vector::()); +/// }); +/// } +/// } +/// ``` +/// +/// When called inside the `benchmarks` macro of the `pallet_example_basic` as +/// +/// ```rust,ignore +/// benchmarks! { +/// // Benchmarks omitted for brevity +/// +/// impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); +/// } +/// ``` +/// +/// It expands to the equivalent of: +/// +/// ```rust,ignore +/// #[cfg(test)] +/// mod benchmarking { +/// use super::*; +/// use crate::tests::{new_test_ext, Test}; +/// use frame_support::assert_ok; +/// +/// #[test] +/// fn bench_accumulate_dummy() { +/// new_test_ext().execute_with(|| { +/// assert_ok!(test_benchmark_accumulate_dummy::()); +/// }) +/// } +/// +/// #[test] +/// fn bench_set_dummy() { +/// new_test_ext().execute_with(|| { +/// assert_ok!(test_benchmark_set_dummy::()); +/// }) +/// } +/// +/// #[test] +/// fn bench_sort_vector() { +/// new_test_ext().execute_with(|| { +/// assert_ok!(test_benchmark_sort_vector::()); +/// }) +/// } +/// } +/// ``` +/// +/// ## Arguments +/// +/// The first argument, `module`, must be the path to this crate's module. +/// +/// The second argument, `new_test_ext`, must be a function call which returns either a +/// `sp_io::TestExternalities`, or some other type with a similar interface. +/// +/// Note that this function call is _not_ evaluated at compile time, but is instead copied textually +/// into each appropriate invocation site. +/// +/// The third argument, `test`, must be the path to the runtime. The item to which this must refer +/// will generally take the form: +/// +/// ```rust,ignore +/// frame_support::construct_runtime!( +/// pub enum Test where ... +/// { ... } +/// ); +/// ``` +/// +/// There is an optional fourth argument, with keyword syntax: `benchmarks_path = +/// path_to_benchmarks_invocation`. In the typical case in which this macro is in the same module as +/// the `benchmarks!` invocation, you don't need to supply this. However, if the +/// `impl_benchmark_test_suite!` invocation is in a different module than the `benchmarks!` +/// invocation, then you should provide the path to the module containing the `benchmarks!` +/// invocation: +/// +/// ```rust,ignore +/// mod benches { +/// benchmarks!{ +/// ... +/// } +/// } +/// +/// mod tests { +/// // because of macro syntax limitations, neither Pallet nor benches can be paths, but both have +/// // to be idents in the scope of `impl_benchmark_test_suite`. +/// use crate::{benches, Pallet}; +/// +/// impl_benchmark_test_suite!(Pallet, new_test_ext(), Test, benchmarks_path = benches); +/// +/// // new_test_ext and the Test item are defined later in this module +/// } +/// ``` +/// +/// There is an optional fifth argument, with keyword syntax: `extra = true` or `extra = false`. +/// By default, this generates a test suite which iterates over all benchmarks, including those +/// marked with the `#[extra]` annotation. Setting `extra = false` excludes those. +/// +/// There is an optional sixth argument, with keyword syntax: `exec_name = custom_exec_name`. +/// By default, this macro uses `execute_with` for this parameter. This argument, if set, is subject +/// to these restrictions: +/// +/// - It must be the name of a method applied to the output of the `new_test_ext` argument. +/// - That method must have a signature capable of receiving a single argument of the form `impl +/// FnOnce()`. +// ## Notes (not for rustdoc) +// +// The biggest challenge for this macro is communicating the actual test functions to be run. We +// can't just build an array of function pointers to each test function and iterate over it, because +// the test functions are parameterized by the `Test` type. That's incompatible with +// monomorphization: if it were legal, then even if the compiler detected and monomorphized the +// functions into only the types of the callers, which implementation would the function pointer +// point to? There would need to be some kind of syntax for selecting the destination of the pointer +// according to a generic argument, and in general it would be a huge mess and not worth it. +// +// Instead, we're going to steal a trick from `fn run_benchmark`: generate a function which is +// itself parametrized by `Test`, which accepts a `&[u8]` parameter containing the name of the +// benchmark, and dispatches based on that to the appropriate real test implementation. Then, we can +// just iterate over the `Benchmarking::benchmarks` list to run the actual implementations. +#[macro_export] +macro_rules! impl_benchmark_test_suite { + ( + $bench_module:ident, + $new_test_ext:expr, + $test:path + $(, $( $rest:tt )* )? + ) => { + $crate::impl_test_function!( + () + () + () + $bench_module, + $new_test_ext, + $test + $(, $( $rest )* )? + ); + } +} + +/// Validates the passed `pov_mode`s. +/// +/// Checks that: +/// - a top-level `ignored` is exclusive +/// - all modes are valid +#[macro_export] +macro_rules! validate_pov_mode { + () => {}; + ( $_bench:ident: ; ) => { }; + ( $_bench:ident: $_car:path = Ignored ; ) => { }; + ( $bench:ident: $_car:path = Ignored $( $storage:path = $_pov_mode:ident )+; ) => { + compile_error!( + concat!(concat!("`pov_mode = Ignored` is exclusive. Please remove the attribute from keys: ", $( stringify!($storage) )+), " on benchmark '", stringify!($bench), "'")); + }; + ( $bench:ident: $car:path = Measured $( $storage:path = $pov_mode:ident )*; ) => { + $crate::validate_pov_mode!( + $bench: $( $storage = $pov_mode )*; + ); + }; + ( $bench:ident: $car:path = MaxEncodedLen $( $storage:path = $pov_mode:ident )*; ) => { + $crate::validate_pov_mode!( + $bench: $( $storage = $pov_mode )*; + ); + }; + ( $bench:ident: $key:path = $unknown:ident $( $_storage:path = $_pov_mode:ident )*; ) => { + compile_error!( + concat!("Unknown pov_mode '", stringify!($unknown) ,"' for benchmark '", stringify!($bench), "' on key '", stringify!($key), "'. Must be one of: Ignored, Measured, MaxEncodedLen") + ); + }; +} + +// Takes all arguments from `impl_benchmark_test_suite` and three additional arguments. +// +// Can be configured to generate one #[test] fn per bench case or +// one #[test] fn for all bench cases. +// This depends on whether or not the first argument contains a non-empty list of bench names. +#[macro_export] +#[doc(hidden)] +macro_rules! impl_test_function { + // user might or might not have set some keyword arguments; set the defaults + // + // The weird syntax indicates that `rest` comes only after a comma, which is otherwise optional + ( + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + + $bench_module:ident, + $new_test_ext:expr, + $test:path + $(, $( $rest:tt )* )? + ) => { + $crate::impl_test_function!( + @cases: + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + @selected: + $bench_module, + $new_test_ext, + $test, + benchmarks_path = super, + extra = true, + exec_name = execute_with, + @user: + $( $( $rest )* )? + ); + }; + // pick off the benchmarks_path keyword argument + ( + @cases: + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + @selected: + $bench_module:ident, + $new_test_ext:expr, + $test:path, + benchmarks_path = $old:ident, + extra = $extra:expr, + exec_name = $exec_name:ident, + @user: + benchmarks_path = $benchmarks_path:ident + $(, $( $rest:tt )* )? + ) => { + $crate::impl_test_function!( + @cases: + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + @selected: + $bench_module, + $new_test_ext, + $test, + benchmarks_path = $benchmarks_path, + extra = $extra, + exec_name = $exec_name, + @user: + $( $( $rest )* )? + ); + }; + // pick off the extra keyword argument + ( + @cases: + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + @selected: + $bench_module:ident, + $new_test_ext:expr, + $test:path, + benchmarks_path = $benchmarks_path:ident, + extra = $old:expr, + exec_name = $exec_name:ident, + @user: + extra = $extra:expr + $(, $( $rest:tt )* )? + ) => { + $crate::impl_test_function!( + @cases: + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + @selected: + $bench_module, + $new_test_ext, + $test, + benchmarks_path = $benchmarks_path, + extra = $extra, + exec_name = $exec_name, + @user: + $( $( $rest )* )? + ); + }; + // pick off the exec_name keyword argument + ( + @cases: + ( $( $names:tt )* ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + @selected: + $bench_module:ident, + $new_test_ext:expr, + $test:path, + benchmarks_path = $benchmarks_path:ident, + extra = $extra:expr, + exec_name = $old:ident, + @user: + exec_name = $exec_name:ident + $(, $( $rest:tt )* )? + ) => { + $crate::impl_test_function!( + @cases: + ( $( $names )* ) + ( $( $names_extra )* ) + ( $( $names_skip_meta )* ) + @selected: + $bench_module, + $new_test_ext, + $test, + benchmarks_path = $benchmarks_path, + extra = $extra, + exec_name = $exec_name, + @user: + $( $( $rest )* )? + ); + }; + // iteration-exit arm which generates a #[test] function for each case. + ( + @cases: + ( $( $names:tt )+ ) + ( $( $names_extra:tt )* ) + ( $( $names_skip_meta:tt )* ) + @selected: + $bench_module:ident, + $new_test_ext:expr, + $test:path, + benchmarks_path = $path_to_benchmarks_invocation:ident, + extra = $extra:expr, + exec_name = $exec_name:ident, + @user: + $(,)? + ) => { + $crate::impl_bench_case_tests!( + { $bench_module, $new_test_ext, $exec_name, $test, $extra } + { $( $names_extra:tt )* } + $($names)+ + ); + }; + // iteration-exit arm which generates one #[test] function for all cases. + ( + @cases: + () + () + () + @selected: + $bench_module:ident, + $new_test_ext:expr, + $test:path, + benchmarks_path = $path_to_benchmarks_invocation:ident, + extra = $extra:expr, + exec_name = $exec_name:ident, + @user: + $(,)? + ) => { + #[cfg(test)] + mod benchmark_tests { + use super::$bench_module; + + #[test] + fn test_benchmarks() { + $new_test_ext.$exec_name(|| { + use $crate::Benchmarking; + + let mut anything_failed = false; + println!("failing benchmark tests:"); + for benchmark_metadata in $bench_module::<$test>::benchmarks($extra) { + let benchmark_name = &benchmark_metadata.name; + match std::panic::catch_unwind(|| { + $bench_module::<$test>::test_bench_by_name(benchmark_name) + }) { + Err(err) => { + println!( + "{}: {:?}", + $crate::str::from_utf8(benchmark_name) + .expect("benchmark name is always a valid string!"), + err, + ); + anything_failed = true; + }, + Ok(Err(err)) => { + match err { + $crate::BenchmarkError::Stop(err) => { + println!( + "{}: {:?}", + $crate::str::from_utf8(benchmark_name) + .expect("benchmark name is always a valid string!"), + err, + ); + anything_failed = true; + }, + $crate::BenchmarkError::Override(_) => { + // This is still considered a success condition. + $crate::log::error!( + "WARNING: benchmark error overrided - {}", + $crate::str::from_utf8(benchmark_name) + .expect("benchmark name is always a valid string!"), + ); + }, + $crate::BenchmarkError::Skip => { + // This is considered a success condition. + $crate::log::error!( + "WARNING: benchmark error skipped - {}", + $crate::str::from_utf8(benchmark_name) + .expect("benchmark name is always a valid string!"), + ); + } + $crate::BenchmarkError::Weightless => { + // This is considered a success condition. + $crate::log::error!( + "WARNING: benchmark weightless skipped - {}", + $crate::str::from_utf8(benchmark_name) + .expect("benchmark name is always a valid string!"), + ); + } + } + }, + Ok(Ok(())) => (), + } + } + assert!(!anything_failed); + }); + } + } + }; +} + +/// show error message and debugging info for the case of an error happening +/// during a benchmark +pub fn show_benchmark_debug_info( + instance_string: &[u8], + benchmark: &[u8], + components: &[(BenchmarkParameter, u32)], + verify: &bool, + error_message: &str, +) -> sp_runtime::RuntimeString { + sp_runtime::format_runtime_string!( + "\n* Pallet: {}\n\ + * Benchmark: {}\n\ + * Components: {:?}\n\ + * Verify: {:?}\n\ + * Error message: {}", + sp_std::str::from_utf8(instance_string) + .expect("it's all just strings ran through the wasm interface. qed"), + sp_std::str::from_utf8(benchmark) + .expect("it's all just strings ran through the wasm interface. qed"), + components, + verify, + error_message, + ) +} + +/// This macro adds pallet benchmarks to a `Vec` object. +/// +/// First create an object that holds in the input parameters for the benchmark: +/// +/// ```ignore +/// let params = (&config, &whitelist); +/// ``` +/// +/// The `whitelist` is a parameter you pass to control the DB read/write tracking. +/// We use a vector of [TrackedStorageKey](./struct.TrackedStorageKey.html), which is a simple +/// struct used to set if a key has been read or written to. +/// +/// For values that should be skipped entirely, we can just pass `key.into()`. For example: +/// +/// ``` +/// use frame_benchmarking::TrackedStorageKey; +/// let whitelist: Vec = vec![ +/// // Block Number +/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"), +/// // Total Issuance +/// array_bytes::hex_into_unchecked("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"), +/// // Execution Phase +/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"), +/// // Event Count +/// array_bytes::hex_into_unchecked("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"), +/// ]; +/// ``` +/// +/// Then define a mutable local variable to hold your `BenchmarkBatch` object: +/// +/// ```ignore +/// let mut batches = Vec::::new(); +/// ```` +/// +/// Then add the pallets you want to benchmark to this object, using their crate name and generated +/// module struct: +/// +/// ```ignore +/// add_benchmark!(params, batches, pallet_balances, Balances); +/// add_benchmark!(params, batches, pallet_session, SessionBench::); +/// add_benchmark!(params, batches, frame_system, SystemBench::); +/// ... +/// ``` +/// +/// At the end of `dispatch_benchmark`, you should return this batches object. +/// +/// In the case where you have multiple instances of a pallet that you need to separately benchmark, +/// the name of your module struct will be used as a suffix to your outputted weight file. For +/// example: +/// +/// ```ignore +/// add_benchmark!(params, batches, pallet_balances, Balances); // pallet_balances.rs +/// add_benchmark!(params, batches, pallet_collective, Council); // pallet_collective_council.rs +/// add_benchmark!(params, batches, pallet_collective, TechnicalCommittee); // pallet_collective_technical_committee.rs +/// ``` +/// +/// You can manipulate this suffixed string by using a type alias if needed. For example: +/// +/// ```ignore +/// type Council2 = TechnicalCommittee; +/// add_benchmark!(params, batches, pallet_collective, Council2); // pallet_collective_council_2.rs +/// ``` +#[macro_export] +macro_rules! add_benchmark { + ( $params:ident, $batches:ident, $name:path, $( $location:tt )* ) => ( + let name_string = stringify!($name).as_bytes(); + let instance_string = stringify!( $( $location )* ).as_bytes(); + let (config, whitelist) = $params; + let $crate::BenchmarkConfig { + pallet, + benchmark, + selected_components, + verify, + internal_repeats, + } = config; + if &pallet[..] == &name_string[..] { + let benchmark_result = $( $location )*::run_benchmark( + &benchmark[..], + &selected_components[..], + whitelist, + *verify, + *internal_repeats, + ); + + let final_results = match benchmark_result { + Ok(results) => Some(results), + Err($crate::BenchmarkError::Override(mut result)) => { + // Insert override warning as the first storage key. + $crate::log::error!( + "WARNING: benchmark error overrided - {}", + $crate::str::from_utf8(benchmark) + .expect("benchmark name is always a valid string!") + ); + result.keys.insert(0, + (b"Benchmark Override".to_vec(), 0, 0, false) + ); + Some($crate::vec![result]) + }, + Err($crate::BenchmarkError::Stop(e)) => { + $crate::show_benchmark_debug_info( + instance_string, + benchmark, + selected_components, + verify, + e, + ); + return Err(e.into()); + }, + Err($crate::BenchmarkError::Skip) => { + $crate::log::error!( + "WARNING: benchmark error skipped - {}", + $crate::str::from_utf8(benchmark) + .expect("benchmark name is always a valid string!") + ); + None + }, + Err($crate::BenchmarkError::Weightless) => { + $crate::log::error!( + "WARNING: benchmark weightless skipped - {}", + $crate::str::from_utf8(benchmark) + .expect("benchmark name is always a valid string!") + ); + Some(vec![$crate::BenchmarkResult { + components: selected_components.clone(), + .. Default::default() + }]) + } + }; + + if let Some(final_results) = final_results { + $batches.push($crate::BenchmarkBatch { + pallet: name_string.to_vec(), + instance: instance_string.to_vec(), + benchmark: benchmark.clone(), + results: final_results, + }); + } + } + ) +} + +/// Callback for `define_benchmarks` to call `add_benchmark`. +#[macro_export] +macro_rules! cb_add_benchmarks { + // anchor + ( $params:ident, $batches:ident, [ $name:path, $( $location:tt )* ] ) => { + $crate::add_benchmark!( $params, $batches, $name, $( $location )* ); + }; + // recursion tail + ( $params:ident, $batches:ident, [ $name:path, $( $location:tt )* ] $([ $names:path, $( $locations:tt )* ])+ ) => { + $crate::cb_add_benchmarks!( $params, $batches, [ $name, $( $location )* ] ); + $crate::cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); + } +} + +/// This macro allows users to easily generate a list of benchmarks for the pallets configured +/// in the runtime. +/// +/// To use this macro, first create a an object to store the list: +/// +/// ```ignore +/// let mut list = Vec::::new(); +/// ``` +/// +/// Then pass this `list` to the macro, along with the `extra` boolean, the pallet crate, and +/// pallet struct: +/// +/// ```ignore +/// list_benchmark!(list, extra, pallet_balances, Balances); +/// list_benchmark!(list, extra, pallet_session, SessionBench::); +/// list_benchmark!(list, extra, frame_system, SystemBench::); +/// ``` +/// +/// This should match what exists with the `add_benchmark!` macro. +#[macro_export] +macro_rules! list_benchmark { + ( $list:ident, $extra:ident, $name:path, $( $location:tt )* ) => ( + let pallet_string = stringify!($name).as_bytes(); + let instance_string = stringify!( $( $location )* ).as_bytes(); + let benchmarks = $( $location )*::benchmarks($extra); + let pallet_benchmarks = BenchmarkList { + pallet: pallet_string.to_vec(), + instance: instance_string.to_vec(), + benchmarks: benchmarks.to_vec(), + }; + $list.push(pallet_benchmarks) + ) +} + +/// Callback for `define_benchmarks` to call `list_benchmark`. +#[macro_export] +macro_rules! cb_list_benchmarks { + // anchor + ( $list:ident, $extra:ident, [ $name:path, $( $location:tt )* ] ) => { + $crate::list_benchmark!( $list, $extra, $name, $( $location )* ); + }; + // recursion tail + ( $list:ident, $extra:ident, [ $name:path, $( $location:tt )* ] $([ $names:path, $( $locations:tt )* ])+ ) => { + $crate::cb_list_benchmarks!( $list, $extra, [ $name, $( $location )* ] ); + $crate::cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); + } +} + +/// Defines pallet configs that `add_benchmarks` and `list_benchmarks` use. +/// Should be preferred instead of having a repetitive list of configs +/// in `add_benchmark` and `list_benchmark`. +#[macro_export] +macro_rules! define_benchmarks { + ( $([ $names:path, $( $locations:tt )* ])* ) => { + /// Calls `list_benchmark` with all configs from `define_benchmarks` + /// and passes the first two parameters on. + /// + /// Use as: + /// ```ignore + /// list_benchmarks!(list, extra); + /// ``` + #[macro_export] + macro_rules! list_benchmarks { + ( $list:ident, $extra:ident ) => { + $crate::cb_list_benchmarks!( $list, $extra, $([ $names, $( $locations )* ])+ ); + } + } + + /// Calls `add_benchmark` with all configs from `define_benchmarks` + /// and passes the first two parameters on. + /// + /// Use as: + /// ```ignore + /// add_benchmarks!(params, batches); + /// ``` + #[macro_export] + macro_rules! add_benchmarks { + ( $params:ident, $batches:ident ) => { + $crate::cb_add_benchmarks!( $params, $batches, $([ $names, $( $locations )* ])+ ); + } + } + } +} + +pub use add_benchmark; +pub use benchmark_backend; +pub use benchmarks; +pub use benchmarks_instance; +pub use benchmarks_instance_pallet; +pub use benchmarks_iter; +pub use cb_add_benchmarks; +pub use cb_list_benchmarks; +pub use define_benchmarks; +pub use impl_bench_case_tests; +pub use impl_bench_name_tests; +pub use impl_benchmark; +pub use impl_benchmark_test; +pub use impl_benchmark_test_suite; +pub use impl_test_function; +pub use list_benchmark; +pub use selected_benchmark; +pub use to_origin; +pub use whitelist; diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index adadb3411a..a43372978e 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -21,7 +21,9 @@ use super::*; -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError}; +use frame_benchmarking::v1::{ + account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, +}; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index 04a8583f28..e7f18c1645 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; -use frame_benchmarking::{account, benchmarks, whitelisted_caller, BenchmarkError}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_system::RawOrigin; use crate::Pallet as ChildBounties; diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 75a7246230..5c9e55862d 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -23,7 +23,7 @@ use crate::Pallet as Collective; use sp_runtime::traits::Bounded; use sp_std::mem::size_of; -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; use frame_system::{Call as SystemCall, Pallet as System, RawOrigin as SystemOrigin}; const SEED: u32 = 0; diff --git a/frame/contracts/src/benchmarking/mod.rs b/frame/contracts/src/benchmarking/mod.rs index 2bd807dfb7..708d92766d 100644 --- a/frame/contracts/src/benchmarking/mod.rs +++ b/frame/contracts/src/benchmarking/mod.rs @@ -37,7 +37,7 @@ use crate::{ Pallet as Contracts, *, }; use codec::{Encode, MaxEncodedLen}; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::weights::Weight; use frame_system::RawOrigin; use sp_runtime::{ diff --git a/frame/conviction-voting/src/benchmarking.rs b/frame/conviction-voting/src/benchmarking.rs index 117bb7fe22..8c168a34a7 100644 --- a/frame/conviction-voting/src/benchmarking.rs +++ b/frame/conviction-voting/src/benchmarking.rs @@ -20,7 +20,7 @@ use super::*; use assert_matches::assert_matches; -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelist_account}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist_account}; use frame_support::{ dispatch::RawOrigin, traits::{fungible, Currency, Get}, diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 424192e252..66d9e2a007 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -19,7 +19,7 @@ use super::*; -use frame_benchmarking::{account, benchmarks, whitelist_account}; +use frame_benchmarking::v1::{account, benchmarks, whitelist_account}; use frame_support::{ assert_noop, assert_ok, traits::{Currency, EnsureOrigin, Get, OnInitialize, UnfilteredDispatchable}, diff --git a/frame/election-provider-support/benchmarking/src/lib.rs b/frame/election-provider-support/benchmarking/src/lib.rs index 547e35bed3..5323513da9 100644 --- a/frame/election-provider-support/benchmarking/src/lib.rs +++ b/frame/election-provider-support/benchmarking/src/lib.rs @@ -22,7 +22,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Decode; -use frame_benchmarking::{benchmarks, Vec}; +use frame_benchmarking::v1::{benchmarks, Vec}; use frame_election_provider_support::{NposSolver, PhragMMS, SequentialPhragmen}; pub struct Pallet(frame_system::Pallet); diff --git a/frame/elections-phragmen/src/benchmarking.rs b/frame/elections-phragmen/src/benchmarking.rs index 53157deaa9..1fc500a8e3 100644 --- a/frame/elections-phragmen/src/benchmarking.rs +++ b/frame/elections-phragmen/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; -use frame_benchmarking::{account, benchmarks, whitelist, BenchmarkError, BenchmarkResult}; +use frame_benchmarking::v1::{account, benchmarks, whitelist, BenchmarkError, BenchmarkResult}; use frame_support::{dispatch::DispatchResultWithPostInfo, traits::OnInitialize}; use frame_system::RawOrigin; diff --git a/frame/examples/basic/src/benchmarking.rs b/frame/examples/basic/src/benchmarking.rs index 699e56685f..a9e2013b04 100644 --- a/frame/examples/basic/src/benchmarking.rs +++ b/frame/examples/basic/src/benchmarking.rs @@ -21,8 +21,11 @@ #![cfg(feature = "runtime-benchmarks")] use crate::*; -use frame_benchmarking::{impl_benchmark_test_suite, whitelisted_caller}; -use frame_support::benchmarking::{benchmarks, Linear}; +use frame_benchmarking::v1::{ + impl_benchmark_test_suite, + v2::{benchmarks, Linear}, + whitelisted_caller, +}; use frame_system::RawOrigin; // To actually run this benchmark on pallet-example-basic, we need to put this pallet into the diff --git a/frame/fast-unstake/src/benchmarking.rs b/frame/fast-unstake/src/benchmarking.rs index de85502f7b..77488b6447 100644 --- a/frame/fast-unstake/src/benchmarking.rs +++ b/frame/fast-unstake/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use crate::{types::*, Pallet as FastUnstake, *}; -use frame_benchmarking::{benchmarks, whitelist_account}; +use frame_benchmarking::v1::{benchmarks, whitelist_account}; use frame_support::{ assert_ok, traits::{Currency, EnsureOrigin, Get, Hooks}, diff --git a/frame/grandpa/src/benchmarking.rs b/frame/grandpa/src/benchmarking.rs index 1240859149..6eee12ad98 100644 --- a/frame/grandpa/src/benchmarking.rs +++ b/frame/grandpa/src/benchmarking.rs @@ -18,7 +18,7 @@ //! Benchmarks for the GRANDPA pallet. use super::{Pallet as Grandpa, *}; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v1::benchmarks; use frame_system::RawOrigin; use sp_core::H256; diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index 3584eb954b..356bcb2e80 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use crate::Pallet as Identity; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ ensure, traits::{EnsureOrigin, Get}, diff --git a/frame/im-online/src/benchmarking.rs b/frame/im-online/src/benchmarking.rs index edc21043c3..e4d1a64651 100644 --- a/frame/im-online/src/benchmarking.rs +++ b/frame/im-online/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v1::benchmarks; use frame_support::{traits::UnfilteredDispatchable, WeakBoundedVec}; use frame_system::RawOrigin; use sp_core::{offchain::OpaqueMultiaddr, OpaquePeerId}; diff --git a/frame/indices/src/benchmarking.rs b/frame/indices/src/benchmarking.rs index f462f22284..ce1ea9f4d3 100644 --- a/frame/indices/src/benchmarking.rs +++ b/frame/indices/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/frame/lottery/src/benchmarking.rs b/frame/lottery/src/benchmarking.rs index fba722a07f..658dd25a98 100644 --- a/frame/lottery/src/benchmarking.rs +++ b/frame/lottery/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::{ storage::bounded_vec::BoundedVec, traits::{EnsureOrigin, OnInitialize}, diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 934abb996d..6d973a15fe 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -362,7 +362,7 @@ impl, I: 'static> SortedMembers for Pallet { #[cfg(feature = "runtime-benchmarks")] mod benchmark { use super::{Pallet as Membership, *}; - use frame_benchmarking::{account, benchmarks_instance_pallet, whitelist}; + use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist}; use frame_support::{assert_ok, traits::EnsureOrigin}; use frame_system::RawOrigin; diff --git a/frame/merkle-mountain-range/src/benchmarking.rs b/frame/merkle-mountain-range/src/benchmarking.rs index d24364a55f..7731c0e505 100644 --- a/frame/merkle-mountain-range/src/benchmarking.rs +++ b/frame/merkle-mountain-range/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use crate::*; -use frame_benchmarking::benchmarks_instance_pallet; +use frame_benchmarking::v1::benchmarks_instance_pallet; use frame_support::traits::OnInitialize; benchmarks_instance_pallet! { diff --git a/frame/message-queue/src/benchmarking.rs b/frame/message-queue/src/benchmarking.rs index 9651c81e5e..97ca71ce9d 100644 --- a/frame/message-queue/src/benchmarking.rs +++ b/frame/message-queue/src/benchmarking.rs @@ -22,8 +22,8 @@ use super::{mock_helpers::*, Pallet as MessageQueue, *}; -use frame_benchmarking::{impl_benchmark_test_suite, whitelisted_caller}; -use frame_support::{benchmarking::*, traits::Get}; +use frame_benchmarking::v2::*; +use frame_support::traits::Get; use frame_system::RawOrigin; use sp_std::prelude::*; diff --git a/frame/multisig/src/benchmarking.rs b/frame/multisig/src/benchmarking.rs index d5faf9ae8a..8993908b25 100644 --- a/frame/multisig/src/benchmarking.rs +++ b/frame/multisig/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{account, benchmarks}; +use frame_benchmarking::v1::{account, benchmarks}; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 6517445da6..17ff28b822 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use enumflags2::{BitFlag, BitFlags}; -use frame_benchmarking::{ +use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, }; use frame_support::{ diff --git a/frame/nis/src/benchmarking.rs b/frame/nis/src/benchmarking.rs index b45c982bd1..b01d414c4b 100644 --- a/frame/nis/src/benchmarking.rs +++ b/frame/nis/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::traits::{nonfungible::Inspect, Currency, EnsureOrigin, Get}; use frame_system::RawOrigin; use sp_arithmetic::Perquintill; diff --git a/frame/nomination-pools/benchmarking/src/lib.rs b/frame/nomination-pools/benchmarking/src/lib.rs index 9b06353915..32708ff53e 100644 --- a/frame/nomination-pools/benchmarking/src/lib.rs +++ b/frame/nomination-pools/benchmarking/src/lib.rs @@ -23,7 +23,9 @@ #[cfg(test)] mod mock; -use frame_benchmarking::{account, frame_support::traits::Currency, vec, whitelist_account, Vec}; +use frame_benchmarking::v1::{ + account, frame_support::traits::Currency, vec, whitelist_account, Vec, +}; use frame_election_provider_support::SortedListProvider; use frame_support::{assert_ok, ensure, traits::Get}; use frame_system::RawOrigin as RuntimeOrigin; diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 7e586a96bb..b71321906c 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -24,7 +24,7 @@ mod mock; use sp_std::{prelude::*, vec}; -use frame_benchmarking::{account, benchmarks}; +use frame_benchmarking::v1::{account, benchmarks}; use frame_support::traits::{Currency, Get, ValidatorSet, ValidatorSetWithIdentification}; use frame_system::{Config as SystemConfig, Pallet as System, RawOrigin}; diff --git a/frame/preimage/src/benchmarking.rs b/frame/preimage/src/benchmarking.rs index 8a61d7d780..f9526b67d4 100644 --- a/frame/preimage/src/benchmarking.rs +++ b/frame/preimage/src/benchmarking.rs @@ -18,7 +18,7 @@ //! Preimage pallet benchmarking. use super::*; -use frame_benchmarking::{account, benchmarks, whitelist_account}; +use frame_benchmarking::v1::{account, benchmarks, whitelist_account}; use frame_support::assert_ok; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 58c0cb7301..ef3df02dcc 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use crate::Pallet as Proxy; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/frame/ranked-collective/src/benchmarking.rs b/frame/ranked-collective/src/benchmarking.rs index eb629b330a..48df7f1f1e 100644 --- a/frame/ranked-collective/src/benchmarking.rs +++ b/frame/ranked-collective/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; #[allow(unused_imports)] use crate::Pallet as RankedCollective; -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; use frame_support::{assert_ok, dispatch::UnfilteredDispatchable}; use frame_system::RawOrigin as SystemOrigin; diff --git a/frame/recovery/src/benchmarking.rs b/frame/recovery/src/benchmarking.rs index 870543d9bd..48ca7dad76 100644 --- a/frame/recovery/src/benchmarking.rs +++ b/frame/recovery/src/benchmarking.rs @@ -20,7 +20,7 @@ use super::*; use crate::Pallet; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::traits::{Currency, Get}; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index e57b5f9859..db5299e0d5 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -20,7 +20,7 @@ use super::*; use crate::Pallet as Referenda; use assert_matches::assert_matches; -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelist_account}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist_account}; use frame_support::{ assert_ok, dispatch::UnfilteredDispatchable, diff --git a/frame/remark/src/benchmarking.rs b/frame/remark/src/benchmarking.rs index c0db8d5d3d..ee93cb24a3 100644 --- a/frame/remark/src/benchmarking.rs +++ b/frame/remark/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_system::{EventRecord, Pallet as System, RawOrigin}; use sp_std::*; diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index 8e2876290b..9ec82f5c84 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -18,7 +18,7 @@ //! Scheduler pallet benchmarking. use super::*; -use frame_benchmarking::{account, benchmarks}; +use frame_benchmarking::v1::{account, benchmarks}; use frame_support::{ ensure, traits::{schedule::Priority, BoundedInline}, diff --git a/frame/session/benchmarking/src/lib.rs b/frame/session/benchmarking/src/lib.rs index 9e478ada53..a6c25f5e10 100644 --- a/frame/session/benchmarking/src/lib.rs +++ b/frame/session/benchmarking/src/lib.rs @@ -26,7 +26,7 @@ mod mock; use sp_runtime::traits::{One, StaticLookup, TrailingZeroInput}; use sp_std::{prelude::*, vec}; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v1::benchmarks; use frame_support::{ codec::Decode, traits::{Get, KeyOwnerProofSystem, OnInitialize}, diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index b3d32b26ec..a4366bbd8a 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -35,7 +35,7 @@ use sp_runtime::{ use sp_staking::SessionIndex; use sp_std::prelude::*; -pub use frame_benchmarking::{ +pub use frame_benchmarking::v1::{ account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, }; use frame_system::RawOrigin; diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index ae2fc35897..4f62ae42ef 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -27,7 +27,6 @@ sp-arithmetic = { version = "6.0.0", default-features = false, path = "../../pri sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../primitives/inherents" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } sp-weights = { version = "4.0.0", default-features = false, path = "../../primitives/weights" } -static_assertions = "1.1.0" tt-call = "1.0.8" frame-support-procedural = { version = "4.0.0-dev", default-features = false, path = "./procedural" } paste = "1.0" diff --git a/frame/support/procedural/src/benchmark.rs b/frame/support/procedural/src/benchmark.rs index f3bd5c2cfe..fa7fd44928 100644 --- a/frame/support/procedural/src/benchmark.rs +++ b/frame/support/procedural/src/benchmark.rs @@ -638,7 +638,7 @@ fn expand_benchmark( Ok(ident) => ident, Err(err) => return err.to_compile_error().into(), }; - let home = quote!(#krate::frame_support::benchmarking); + let home = quote!(#krate::v2); let codec = quote!(#krate::frame_support::codec); let traits = quote!(#krate::frame_support::traits); let setup_stmts = benchmark_def.setup_stmts; diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 9bdbbd1f27..8fa46b48d0 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -483,7 +483,7 @@ pub fn pallet(attr: TokenStream, item: TokenStream) -> TokenStream { /// An attribute macro that can be attached to a (non-empty) module declaration. Doing so will /// designate that module as a benchmarking module. /// -/// See `frame_support::benchmarking` for more info. +/// See `frame_benchmarking::v2` for more info. #[proc_macro_attribute] pub fn benchmarks(attr: TokenStream, tokens: TokenStream) -> TokenStream { match benchmark::benchmarks(attr, tokens, false) { @@ -495,7 +495,7 @@ pub fn benchmarks(attr: TokenStream, tokens: TokenStream) -> TokenStream { /// An attribute macro that can be attached to a (non-empty) module declaration. Doing so will /// designate that module as an instance benchmarking module. /// -/// See `frame_support::benchmarking` for more info. +/// See `frame_benchmarking::v2` for more info. #[proc_macro_attribute] pub fn instance_benchmarks(attr: TokenStream, tokens: TokenStream) -> TokenStream { match benchmark::benchmarks(attr, tokens, true) { @@ -508,7 +508,7 @@ pub fn instance_benchmarks(attr: TokenStream, tokens: TokenStream) -> TokenStrea /// attached to a function definition containing an `#[extrinsic_call]` or `#[block]` /// attribute. /// -/// See `frame_support::benchmarking` for more info. +/// See `frame_benchmarking::v2` for more info. #[proc_macro_attribute] pub fn benchmark(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { quote!(compile_error!( @@ -521,7 +521,7 @@ pub fn benchmark(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { /// used as a boundary designating where the benchmark setup code ends, and the benchmark /// verification code begins. /// -/// See `frame_support::benchmarking` for more info. +/// See `frame_benchmarking::v2` for more info. #[proc_macro_attribute] pub fn extrinsic_call(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { quote!(compile_error!( @@ -534,7 +534,7 @@ pub fn extrinsic_call(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream /// enclosing benchmark function, This attribute is also used as a boundary designating where /// the benchmark setup code ends, and the benchmark verification code begins. /// -/// See `frame_support::benchmarking` for more info. +/// See `frame_benchmarking::v2` for more info. #[proc_macro_attribute] pub fn block(_attrs: TokenStream, _tokens: TokenStream) -> TokenStream { quote!(compile_error!( diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 40bc878cff..902893972f 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2745,228 +2745,5 @@ pub mod pallet_macros { }; } -/// Contains macros, structs, and traits associated with v2 of the pallet benchmarking syntax. -/// This module contains macros, structs, and traits associated with v2 of the pallet -/// benchmarking syntax. -/// -/// The [`benchmarking::benchmarks`] and [`benchmarking::instance_benchmarks`] macros can be -/// used to designate a module as a benchmarking module that can contain benchmarks and -/// benchmark tests. The `#[benchmarks]` variant will set up a regular, non-instance -/// benchmarking module, and the `#[instance_benchmarks]` variant will set up the module in -/// instance benchmarking mode. -/// -/// Benchmarking modules should be gated behind a `#[cfg(feature = "runtime-benchmarks")]` -/// feature gate to ensure benchmarking code that is only compiled when the -/// `runtime-benchmarks` feature is enabled is not referenced. -/// -/// The following is the general syntax for a benchmarks (or instance benchmarks) module: -/// -/// ## General Syntax -/// -/// ```ignore -/// #![cfg(feature = "runtime-benchmarks")] -/// -/// use super::{mock_helpers::*, Pallet as MyPallet}; -/// use frame_support::benchmarking::*; -/// use frame_benchmarking::whitelisted_caller; -/// -/// #[benchmarks] -/// mod benchmarks { -/// use super::*; -/// -/// #[benchmark] -/// fn bench_name_1(x: Linear<7, 1_000>, y: Linear<1_000, 100_0000>) { -/// // setup code -/// let z = x + y; -/// let caller = whitelisted_caller(); -/// -/// #[extrinsic_call] -/// extrinsic_name(SystemOrigin::Signed(caller), other, arguments); -/// -/// // verification code -/// assert_eq!(MyPallet::::my_var(), z); -/// } -/// -/// #[benchmark] -/// fn bench_name_2() { -/// // setup code -/// let caller = whitelisted_caller(); -/// -/// #[block] -/// { -/// something(some, thing); -/// my_extrinsic(RawOrigin::Signed(caller), some, argument); -/// something_else(foo, bar); -/// } -/// -/// // verification code -/// assert_eq!(MyPallet::::something(), 37); -/// } -/// } -/// ``` -/// -/// ## Benchmark Definitions -/// -/// Within a `#[benchmarks]` or `#[instance_benchmarks]` module, you can define individual -/// benchmarks using the `#[benchmark]` attribute, as shown in the example above. -/// -/// The `#[benchmark]` attribute expects a function definition with a blank return type and -/// zero or more arguments whose names are valid `frame_benchmarking::BenchmarkParamater` -/// parameters, such as `x`, `y`, `a`, `b`, etc., and whose param types must implement -/// [`benchmarking::ParamRange`]. At the moment the only valid type that implements -/// [`benchmarking::ParamRange`] is [`benchmarking::Linear`]. -/// -/// The valid syntax for defining a `Linear` is `Linear` where `A`, and `B` are -/// valid integer literals (that fit in a `u32`), such that `B` >= `A`. -/// -/// Note that the benchmark function definition does not actually expand as a function -/// definition, but rather is used to automatically create a number of impls and structs -/// required by the benchmarking engine. For this reason, the visibility of the function -/// definition as well as the return type are not used for any purpose and are discarded by the -/// expansion code. -/// -/// Also note that the `// setup code` and `// verification code` comments shown above are not -/// required and are included simply for demonstration purposes. -/// -/// ### `#[extrinsic_call]` and `#[block]` -/// -/// Within the benchmark function body, either an `#[extrinsic_call]` or a `#[block]` -/// annotation is required. These attributes should be attached to a block (shown in -/// `bench_name_2` above) or a one-line function call (shown in `bench_name_1` above, in `syn` -/// parlance this should be an `ExprCall`), respectively. -/// -/// The `#[block]` syntax is broad and will benchmark any code contained within the block the -/// attribute is attached to. If `#[block]` is attached to something other than a block, a -/// compiler error will be emitted. -/// -/// The one-line `#[extrinsic_call]` syntax must consist of a function call to an extrinsic, -/// where the first argument is the origin. If `#[extrinsic_call]` is attached to an item that -/// doesn't meet these requirements, a compiler error will be emitted. -/// -/// As a short-hand, you may substitute the name of the extrinsic call with `_`, such as the -/// following: -/// -/// ```ignore -/// #[extrinsic_call] -/// _(RawOrigin::Signed(whitelisted_caller()), 0u32.into(), 0); -/// ``` -/// -/// The underscore will be substituted with the name of the benchmark (i.e. the name of the -/// function in the benchmark function definition). -/// -/// Regardless of whether `#[extrinsic_call]` or `#[block]` is used, this attribute also serves -/// the purpose of designating the boundary between the setup code portion of the benchmark -/// (everything before the `#[extrinsic_call]` or `#[block]` attribute) and the verification -/// stage (everything after the item that the `#[extrinsic_call]` or `#[block]` attribute is -/// attached to). The setup code section should contain any code that needs to execute before -/// the measured portion of the benchmark executes. The verification section is where you can -/// perform assertions to verify that the extrinsic call (or whatever is happening in your -/// block, if you used the `#[block]` syntax) executed successfully. -/// -/// Note that neither `#[extrinsic_call]` nor `#[block]` are real attribute macros and are -/// instead consumed by the outer macro pattern as part of the enclosing benchmark function -/// definition. This is why we are able to use `#[extrinsic_call]` and `#[block]` within a -/// function definition even though this behavior has not been stabilized -/// yet—`#[extrinsic_call]` and `#[block]` are parsed and consumed as part of the benchmark -/// definition parsing code, so they never expand as their own attribute macros. -/// -/// ### Optional Attributes -/// -/// The keywords `extra` and `skip_meta` can be provided as optional arguments to the -/// `#[benchmark]` attribute, i.e. `#[benchmark(extra, skip_meta)]`. Including either of these -/// will enable the `extra` or `skip_meta` option, respectively. These options enable the same -/// behavior they did in the old benchmarking syntax in `frame_benchmarking`, namely: -/// -/// #### `extra` -/// -/// Specifies that this benchmark should not normally run. To run benchmarks marked with -/// `extra`, you will need to invoke the `frame-benchmarking-cli` with `--extra`. -/// -/// #### `skip_meta` -/// -/// Specifies that the benchmarking framework should not analyze the storage keys that -/// benchmarked code read or wrote. This useful to suppress the prints in the form of unknown -/// 0x… in case a storage key that does not have metadata. Note that this skips the analysis -/// of all accesses, not just ones without metadata. -/// -/// ## Where Clause -/// -/// Some pallets require a where clause specifying constraints on their generics to make -/// writing benchmarks feasible. To accomodate this situation, you can provide such a where -/// clause as the (only) argument to the `#[benchmarks]` or `#[instance_benchmarks]` attribute -/// macros. Below is an example of this taken from the `message-queue` pallet. -/// -/// ```ignore -/// #[benchmarks( -/// where -/// <::MessageProcessor as ProcessMessage>::Origin: From + PartialEq, -/// ::Size: From, -/// )] -/// mod benchmarks { -/// use super::*; -/// // ... -/// } -/// ``` -/// -/// ## Benchmark Tests -/// -/// Benchmark tests can be generated using the old syntax in `frame_benchmarking`, -/// including the `frame_benchmarking::impl_benchmark_test_suite` macro. -/// -/// An example is shown below (taken from the `message-queue` pallet's `benchmarking` module): -/// ```ignore -/// #[benchmarks] -/// mod benchmarks { -/// use super::*; -/// // ... -/// impl_benchmark_test_suite!( -/// MessageQueue, -/// crate::mock::new_test_ext::(), -/// crate::integration_test::Test -/// ); -/// } -/// ``` -pub mod benchmarking { - pub use frame_support_procedural::{ - benchmark, benchmarks, block, extrinsic_call, instance_benchmarks, - }; - - // Used in #[benchmark] implementation to ensure that benchmark function arguments - // implement [`ParamRange`]. - #[doc(hidden)] - pub use static_assertions::assert_impl_all; - - /// Used by the new benchmarking code to specify that a benchmarking variable is linear - /// over some specified range, i.e. `Linear<0, 1_000>` means that the corresponding variable - /// is allowed to range from `0` to `1000`, inclusive. - /// - /// See [`frame_support::benchmarking`] for more info. - pub struct Linear; - - /// Trait that must be implemented by all structs that can be used as parameter range types - /// in the new benchmarking code (i.e. `Linear<0, 1_000>`). Right now there is just - /// [`Linear`] but this could later be extended to support additional non-linear parameter - /// ranges. - /// - /// See [`frame_support::benchmarking`] for more info. - pub trait ParamRange { - /// Represents the (inclusive) starting number of this [`ParamRange`]. - fn start(&self) -> u32; - - /// Represents the (inclusive) ending number of this [`ParamRange`] - fn end(&self) -> u32; - } - - impl ParamRange for Linear { - fn start(&self) -> u32 { - return A - } - - fn end(&self) -> u32 { - return B - } - } -} - // Generate a macro that will enable/disable code based on `std` feature being active. sp_core::generate_feature_enabled_macro!(std_enabled, feature = "std", $); diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name.rs b/frame/support/test/tests/benchmark_ui/bad_param_name.rs index ad4db4f0a4..657e481a94 100644 --- a/frame/support/test/tests/benchmark_ui/bad_param_name.rs +++ b/frame/support/test/tests/benchmark_ui/bad_param_name.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs b/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs index 50e4dc6fd4..f970126d12 100644 --- a/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs +++ b/frame/support/test/tests/benchmark_ui/bad_param_name_too_long.rs @@ -1,9 +1,9 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; #[benchmarks] -mod benches { +mod benchmarks { #[benchmark] fn bench(xx: Linear<1, 2>) { #[block] diff --git a/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs b/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs index 0270582b3b..9970f32301 100644 --- a/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs +++ b/frame/support/test/tests/benchmark_ui/bad_param_name_upper_case.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/bad_param_range.rs b/frame/support/test/tests/benchmark_ui/bad_param_range.rs index aabb9fa740..993f2a0004 100644 --- a/frame/support/test/tests/benchmark_ui/bad_param_range.rs +++ b/frame/support/test/tests/benchmark_ui/bad_param_range.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/bad_params.rs b/frame/support/test/tests/benchmark_ui/bad_params.rs index a0c9236982..5049f2eae2 100644 --- a/frame/support/test/tests/benchmark_ui/bad_params.rs +++ b/frame/support/test/tests/benchmark_ui/bad_params.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/dup_block.rs b/frame/support/test/tests/benchmark_ui/dup_block.rs index 4c4a8fc11d..2c2ef9db9a 100644 --- a/frame/support/test/tests/benchmark_ui/dup_block.rs +++ b/frame/support/test/tests/benchmark_ui/dup_block.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs b/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs index 1a91b7c16d..4d135d1a04 100644 --- a/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs +++ b/frame/support/test/tests/benchmark_ui/dup_extrinsic_call.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/extra_extra.rs b/frame/support/test/tests/benchmark_ui/extra_extra.rs index 021106c7af..1aa6c9ecb7 100644 --- a/frame/support/test/tests/benchmark_ui/extra_extra.rs +++ b/frame/support/test/tests/benchmark_ui/extra_extra.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs b/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs index 1940f4cf1f..3418c7af73 100644 --- a/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs +++ b/frame/support/test/tests/benchmark_ui/extra_skip_meta.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs b/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs index 4cb6bfc34c..ce360ee757 100644 --- a/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs +++ b/frame/support/test/tests/benchmark_ui/extrinsic_call_out_of_fn.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[extrinsic_call] mod stuff {} diff --git a/frame/support/test/tests/benchmark_ui/missing_call.rs b/frame/support/test/tests/benchmark_ui/missing_call.rs index 7437049354..bc04101dd3 100644 --- a/frame/support/test/tests/benchmark_ui/missing_call.rs +++ b/frame/support/test/tests/benchmark_ui/missing_call.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/missing_origin.rs b/frame/support/test/tests/benchmark_ui/missing_origin.rs index aad91bc79f..2aaed756b9 100644 --- a/frame/support/test/tests/benchmark_ui/missing_origin.rs +++ b/frame/support/test/tests/benchmark_ui/missing_origin.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs b/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs index 5c84d7f76d..450ce4f9c5 100644 --- a/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs +++ b/frame/support/test/tests/benchmark_ui/pass/valid_basic.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; use frame_support_test::Config; #[benchmarks] diff --git a/frame/support/test/tests/benchmark_ui/unrecognized_option.rs b/frame/support/test/tests/benchmark_ui/unrecognized_option.rs index 4c2cea139f..18cae4d5d5 100644 --- a/frame/support/test/tests/benchmark_ui/unrecognized_option.rs +++ b/frame/support/test/tests/benchmark_ui/unrecognized_option.rs @@ -1,4 +1,4 @@ -use frame_support::benchmarking::*; +use frame_benchmarking::v2::*; #[allow(unused_imports)] use frame_support_test::Config; diff --git a/frame/system/benchmarking/src/lib.rs b/frame/system/benchmarking/src/lib.rs index 0f7603fe1d..87d3c7fc70 100644 --- a/frame/system/benchmarking/src/lib.rs +++ b/frame/system/benchmarking/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Encode; -use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_support::{dispatch::DispatchClass, storage, traits::Get}; use frame_system::{Call, Pallet as System, RawOrigin}; use sp_core::storage::well_known_keys; diff --git a/frame/timestamp/src/benchmarking.rs b/frame/timestamp/src/benchmarking.rs index 8974eb9569..3a9297fda8 100644 --- a/frame/timestamp/src/benchmarking.rs +++ b/frame/timestamp/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{benchmarks, TrackedStorageKey}; +use frame_benchmarking::v1::{benchmarks, TrackedStorageKey}; use frame_support::{ensure, traits::OnFinalize}; use frame_system::RawOrigin; diff --git a/frame/tips/src/benchmarking.rs b/frame/tips/src/benchmarking.rs index 312424e579..8ffc53b45e 100644 --- a/frame/tips/src/benchmarking.rs +++ b/frame/tips/src/benchmarking.rs @@ -19,7 +19,7 @@ #![cfg(feature = "runtime-benchmarks")] -use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; use frame_support::ensure; use frame_system::RawOrigin; use sp_runtime::traits::Saturating; diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index c7fbd00fb5..736d2c40d0 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{benchmarks, whitelisted_caller}; use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize}; use frame_system::{EventRecord, Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, One, Zero}; diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index d718a5fb89..eb44744506 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::{Pallet as Treasury, *}; -use frame_benchmarking::{account, benchmarks_instance_pallet}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet}; use frame_support::{ dispatch::UnfilteredDispatchable, ensure, diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index ab34558f95..5ecb093a5d 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{ +use frame_benchmarking::v1::{ account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, }; use frame_support::{ diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs index 07bc14951c..f381b1e5f9 100644 --- a/frame/utility/src/benchmarking.rs +++ b/frame/utility/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_system::RawOrigin; const SEED: u32 = 0; diff --git a/frame/vesting/src/benchmarking.rs b/frame/vesting/src/benchmarking.rs index dde5fe3ac7..eb0d596b8a 100644 --- a/frame/vesting/src/benchmarking.rs +++ b/frame/vesting/src/benchmarking.rs @@ -19,7 +19,7 @@ #![cfg(feature = "runtime-benchmarks")] -use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; use frame_support::assert_ok; use frame_system::{Pallet as System, RawOrigin}; use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul}; diff --git a/frame/whitelist/src/benchmarking.rs b/frame/whitelist/src/benchmarking.rs index 569b13c12d..e64842b34d 100644 --- a/frame/whitelist/src/benchmarking.rs +++ b/frame/whitelist/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::benchmarks; +use frame_benchmarking::v1::benchmarks; use frame_support::{ensure, traits::EnsureOrigin}; #[cfg(test)] From 9762613a130235317467f66d6e6f46bfa30a5674 Mon Sep 17 00:00:00 2001 From: Matteo Muraca <56828990+muraca@users.noreply.github.com> Date: Sat, 28 Jan 2023 00:47:17 +0100 Subject: [PATCH 65/80] mutate_exists for StorageValue with ValueQuery (#13245) * mutate_exists for StorageValue with ValueQuery Signed-off-by: muraca * added `#[crate::storage_alias]` to tests Signed-off-by: muraca * added StorageEntryMetadata Signed-off-by: muraca * Update frame/support/src/lib.rs --------- Signed-off-by: muraca Co-authored-by: Oliver Tale-Yazdi --- frame/support/src/lib.rs | 63 ++++++++++++++++++++ frame/support/src/storage/generator/value.rs | 24 ++++++++ frame/support/src/storage/mod.rs | 6 ++ frame/support/src/storage/types/value.rs | 12 ++++ 4 files changed, 105 insertions(+) diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 902893972f..77ca89dc6f 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -874,6 +874,7 @@ pub mod tests { decl_storage! { trait Store for Module as Test { + pub Value get(fn value): u64; pub Data get(fn data) build(|_| vec![(15u32, 42u64)]): map hasher(twox_64_concat) u32 => u64; pub OptionLinkedMap: map hasher(blake2_128_concat) u32 => Option; @@ -946,6 +947,61 @@ pub mod tests { }); } + #[test] + fn storage_value_mutate_exists_should_work() { + new_test_ext().execute_with(|| { + #[crate::storage_alias] + pub type Value = StorageValue; + + assert!(!Value::exists()); + + Value::mutate_exists(|v| *v = Some(1)); + assert!(Value::exists()); + assert_eq!(Value::get(), Some(1)); + + // removed if mutated to `None` + Value::mutate_exists(|v| *v = None); + assert!(!Value::exists()); + }); + } + + #[test] + fn storage_value_try_mutate_exists_should_work() { + new_test_ext().execute_with(|| { + #[crate::storage_alias] + pub type Value = StorageValue; + + type TestResult = result::Result<(), &'static str>; + + assert!(!Value::exists()); + + // mutated if `Ok` + assert_ok!(Value::try_mutate_exists(|v| -> TestResult { + *v = Some(1); + Ok(()) + })); + assert!(Value::exists()); + assert_eq!(Value::get(), Some(1)); + + // no-op if `Err` + assert_noop!( + Value::try_mutate_exists(|v| -> TestResult { + *v = Some(2); + Err("nah") + }), + "nah" + ); + assert_eq!(Value::get(), Some(1)); + + // removed if mutated to`None` + assert_ok!(Value::try_mutate_exists(|v| -> TestResult { + *v = None; + Ok(()) + })); + assert!(!Value::exists()); + }); + } + #[test] fn map_issue_3318() { new_test_ext().execute_with(|| { @@ -1257,6 +1313,13 @@ pub mod tests { PalletStorageMetadata { prefix: "Test", entries: vec![ + StorageEntryMetadata { + name: "Value", + modifier: StorageEntryModifier::Default, + ty: StorageEntryType::Plain(scale_info::meta_type::()), + default: vec![0, 0, 0, 0, 0, 0, 0, 0], + docs: vec![], + }, StorageEntryMetadata { name: "Data", modifier: StorageEntryModifier::Default, diff --git a/frame/support/src/storage/generator/value.rs b/frame/support/src/storage/generator/value.rs index 55b3487b13..4a1fd5c551 100644 --- a/frame/support/src/storage/generator/value.rs +++ b/frame/support/src/storage/generator/value.rs @@ -118,6 +118,30 @@ impl> storage::StorageValue for G { ret } + fn mutate_exists(f: F) -> R + where + F: FnOnce(&mut Option) -> R, + { + Self::try_mutate_exists(|v| Ok::(f(v))) + .expect("`Never` can not be constructed; qed") + } + + fn try_mutate_exists(f: F) -> Result + where + F: FnOnce(&mut Option) -> Result, + { + let mut val = G::from_query_to_optional_value(Self::get()); + + let ret = f(&mut val); + if ret.is_ok() { + match val { + Some(ref val) => Self::put(val), + None => Self::kill(), + } + } + ret + } + fn take() -> G::Query { let key = Self::storage_value_final_key(); let value = unhashed::get(&key); diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 8c0d6207c3..28f2dee992 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -114,6 +114,12 @@ pub trait StorageValue { /// Mutate the value if closure returns `Ok` fn try_mutate Result>(f: F) -> Result; + /// Mutate the value. Deletes the item if mutated to a `None`. + fn mutate_exists) -> R>(f: F) -> R; + + /// Mutate the value if closure returns `Ok`. Deletes the item if mutated to a `None`. + fn try_mutate_exists) -> Result>(f: F) -> Result; + /// Clear the storage value. fn kill(); diff --git a/frame/support/src/storage/types/value.rs b/frame/support/src/storage/types/value.rs index f145e9fb30..15290f1b1e 100644 --- a/frame/support/src/storage/types/value.rs +++ b/frame/support/src/storage/types/value.rs @@ -142,6 +142,18 @@ where >::try_mutate(f) } + /// Mutate the value. Deletes the item if mutated to a `None`. + pub fn mutate_exists) -> R>(f: F) -> R { + >::mutate_exists(f) + } + + /// Mutate the value if closure returns `Ok`. Deletes the item if mutated to a `None`. + pub fn try_mutate_exists) -> Result>( + f: F, + ) -> Result { + >::try_mutate_exists(f) + } + /// Clear the storage value. pub fn kill() { >::kill() From 1e6b8921b771debd18de54aae55787c467baeddd Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Sat, 28 Jan 2023 09:09:06 +0900 Subject: [PATCH 66/80] Fix derive PassByInner with generics (#13247) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix derive PassByInner with generics * Update primitives/runtime-interface/proc-macro/src/pass_by/inner.rs --------- Co-authored-by: Bastian Köcher --- primitives/runtime-interface/proc-macro/src/pass_by/inner.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/runtime-interface/proc-macro/src/pass_by/inner.rs b/primitives/runtime-interface/proc-macro/src/pass_by/inner.rs index 7a527af129..7c9bd63aba 100644 --- a/primitives/runtime-interface/proc-macro/src/pass_by/inner.rs +++ b/primitives/runtime-interface/proc-macro/src/pass_by/inner.rs @@ -52,7 +52,7 @@ pub fn derive_impl(mut input: DeriveInput) -> Result { #crate_include impl #impl_generics #crate_::pass_by::PassBy for #ident #ty_generics #where_clause { - type PassBy = #crate_::pass_by::Inner<#ident, #inner_ty>; + type PassBy = #crate_::pass_by::Inner; } impl #impl_generics #crate_::pass_by::PassByInner for #ident #ty_generics #where_clause { From ece32a72e934f6fe6705a7d418bbf3e71b4931ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathas=20Concei=C3=A7=C3=A3o?= Date: Fri, 27 Jan 2023 21:16:57 -0300 Subject: [PATCH 67/80] docs: Fix broken documentation links for pallets (#13241) Fixes broken links to `Config` and `Call`, for READMEs the link has been fixed by adding the missing "/pallet" path, and for rust docs we let the compiler figure out the type's link by itself Signed-off-by: Jonathas-Conceicao --- frame/multisig/README.md | 4 ++-- frame/multisig/src/lib.rs | 3 --- frame/nicks/README.md | 4 ++-- frame/proxy/README.md | 4 ++-- frame/sudo/README.md | 4 ++-- frame/utility/README.md | 4 ++-- frame/vesting/README.md | 4 ++-- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/frame/multisig/README.md b/frame/multisig/README.md index 4eab00d108..5f320377d3 100644 --- a/frame/multisig/README.md +++ b/frame/multisig/README.md @@ -1,8 +1,8 @@ # Multisig Module A module for doing multisig dispatch. -- [`multisig::Config`](https://docs.rs/pallet-multisig/latest/pallet_multisig/trait.Config.html) -- [`Call`](https://docs.rs/pallet-multisig/latest/pallet_multisig/enum.Call.html) +- [`Config`](https://docs.rs/pallet-multisig/latest/pallet_multisig/pallet/trait.Config.html) +- [`Call`](https://docs.rs/pallet-multisig/latest/pallet_multisig/pallet/enum.Call.html) ## Overview diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 076a289e06..03d7ddec6a 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -39,9 +39,6 @@ //! number of signed origins. //! * `approve_as_multi` - Approve a call from a composite origin. //! * `cancel_as_multi` - Cancel a call from a composite origin. -//! -//! [`Call`]: ./enum.Call.html -//! [`Config`]: ./trait.Config.html // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] diff --git a/frame/nicks/README.md b/frame/nicks/README.md index a2a897b044..768043ffb9 100644 --- a/frame/nicks/README.md +++ b/frame/nicks/README.md @@ -1,7 +1,7 @@ # Nicks Module -- [`nicks::Config`](https://docs.rs/pallet-nicks/latest/pallet_nicks/trait.Config.html) -- [`Call`](https://docs.rs/pallet-nicks/latest/pallet_nicks/enum.Call.html) +- [`Config`](https://docs.rs/pallet-nicks/latest/pallet_nicks/pallet/trait.Config.html) +- [`Call`](https://docs.rs/pallet-nicks/latest/pallet_nicks/pallet/enum.Call.html) ## Overview diff --git a/frame/proxy/README.md b/frame/proxy/README.md index 2eb83fab6d..bfe26d9aef 100644 --- a/frame/proxy/README.md +++ b/frame/proxy/README.md @@ -6,8 +6,8 @@ The accounts to which permission is delegated may be requied to announce the act wish to execute some duration prior to execution happens. In this case, the target account may reject the announcement and in doing so, veto the execution. -- [`proxy::Config`](https://docs.rs/pallet-proxy/latest/pallet_proxy/trait.Config.html) -- [`Call`](https://docs.rs/pallet-proxy/latest/pallet_proxy/enum.Call.html) +- [`Config`](https://docs.rs/pallet-proxy/latest/pallet_proxy/pallet/trait.Config.html) +- [`Call`](https://docs.rs/pallet-proxy/latest/pallet_proxy/pallet/enum.Call.html) ## Overview diff --git a/frame/sudo/README.md b/frame/sudo/README.md index 7342832d2d..886dc59817 100644 --- a/frame/sudo/README.md +++ b/frame/sudo/README.md @@ -1,7 +1,7 @@ # Sudo Module -- [`sudo::Config`](https://docs.rs/pallet-sudo/latest/pallet_sudo/trait.Config.html) -- [`Call`](https://docs.rs/pallet-sudo/latest/pallet_sudo/enum.Call.html) +- [`Config`](https://docs.rs/pallet-sudo/latest/pallet_sudo/pallet/trait.Config.html) +- [`Call`](https://docs.rs/pallet-sudo/latest/pallet_sudo/pallet/enum.Call.html) ## Overview diff --git a/frame/utility/README.md b/frame/utility/README.md index 1beeb66733..db19b0cf8c 100644 --- a/frame/utility/README.md +++ b/frame/utility/README.md @@ -1,8 +1,8 @@ # Utility Module A stateless module with helpers for dispatch management which does no re-authentication. -- [`utility::Config`](https://docs.rs/pallet-utility/latest/pallet_utility/trait.Config.html) -- [`Call`](https://docs.rs/pallet-utility/latest/pallet_utility/enum.Call.html) +- [`utility::Config`](https://docs.rs/pallet-utility/latest/pallet_utility/pallet/trait.Config.html) +- [`Call`](https://docs.rs/pallet-utility/latest/pallet_utility/pallet/enum.Call.html) ## Overview diff --git a/frame/vesting/README.md b/frame/vesting/README.md index b19a60c5b6..1f3744d635 100644 --- a/frame/vesting/README.md +++ b/frame/vesting/README.md @@ -1,7 +1,7 @@ # Vesting Module -- [`vesting::Config`](https://docs.rs/pallet-vesting/latest/pallet_vesting/trait.Config.html) -- [`Call`](https://docs.rs/pallet-vesting/latest/pallet_vesting/enum.Call.html) +- [`Config`](https://docs.rs/pallet-vesting/latest/pallet_vesting/pallet/trait.Config.html) +- [`Call`](https://docs.rs/pallet-vesting/latest/pallet_vesting/pallet/enum.Call.html) ## Overview From 0100b3b96984f128a06f9701a3424a3a9cde26fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 28 Jan 2023 20:10:40 +0100 Subject: [PATCH 68/80] sc-finality-grandpa: Warp proof generation can not expect justifications (#13249) When a node is running with `--blocks-pruning` it will also prunes justifications. So, the warp proof generation can not use `expect` for unwrapping the justification. --- client/cli/src/params/pruning_params.rs | 1 + client/finality-grandpa/src/warp_proof.rs | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/client/cli/src/params/pruning_params.rs b/client/cli/src/params/pruning_params.rs index fd01ba67ba..66282fd088 100644 --- a/client/cli/src/params/pruning_params.rs +++ b/client/cli/src/params/pruning_params.rs @@ -49,6 +49,7 @@ pub struct PruningParams { /// [default: 256] #[arg(alias = "pruning", long, value_name = "PRUNING_MODE")] pub state_pruning: Option, + /// Specify the blocks pruning mode. /// /// This mode specifies when the block's body (including justifications) diff --git a/client/finality-grandpa/src/warp_proof.rs b/client/finality-grandpa/src/warp_proof.rs index c65a705d3e..1169083ea1 100644 --- a/client/finality-grandpa/src/warp_proof.rs +++ b/client/finality-grandpa/src/warp_proof.rs @@ -135,11 +135,7 @@ impl WarpSyncProof { let justification = blockchain .justifications(header.hash())? .and_then(|just| just.into_justification(GRANDPA_ENGINE_ID)) - .expect( - "header is last in set and contains standard change signal; \ - must have justification; \ - qed.", - ); + .ok_or_else(|| Error::MissingData)?; let justification = GrandpaJustification::::decode(&mut &justification[..])?; From 6c1119016ff6b35e8ea79594edf20c03a39e3740 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Sun, 29 Jan 2023 03:43:32 +0800 Subject: [PATCH 69/80] update criterion to v0.4.0 (#13142) --- Cargo.lock | 129 ++++++++++++++--------------- bin/node/cli/Cargo.toml | 2 +- bin/node/executor/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/tracing/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- frame/system/Cargo.toml | 2 +- primitives/api/test/Cargo.toml | 2 +- primitives/arithmetic/Cargo.toml | 2 +- primitives/core/Cargo.toml | 4 +- primitives/core/benches/bench.rs | 5 +- primitives/trie/Cargo.toml | 4 +- 13 files changed, 78 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6aafb0e175..c075f065fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -167,6 +167,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -705,10 +711,7 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ - "lazy_static", "memchr", - "regex-automata", - "serde", ] [[package]] @@ -914,6 +917,33 @@ dependencies = [ "winapi", ] +[[package]] +name = "ciborium" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" + +[[package]] +name = "ciborium-ll" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cid" version = "0.8.6" @@ -967,13 +997,14 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "3.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "bitflags", + "clap_lex 0.2.4", + "indexmap", "textwrap", - "unicode-width", ] [[package]] @@ -984,7 +1015,7 @@ checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39" dependencies = [ "bitflags", "clap_derive", - "clap_lex", + "clap_lex 0.3.0", "is-terminal", "once_cell", "strsim", @@ -1013,6 +1044,15 @@ dependencies = [ "syn", ] +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "clap_lex" version = "0.3.0" @@ -1243,15 +1283,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" dependencies = [ + "anes", "atty", "cast", - "clap 2.34.0", + "ciborium", + "clap 3.2.23", "criterion-plot", - "csv", "futures", "itertools", "lazy_static", @@ -1261,7 +1302,6 @@ dependencies = [ "rayon", "regex", "serde", - "serde_cbor", "serde_derive", "serde_json", "tinytemplate", @@ -1271,9 +1311,9 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", "itertools", @@ -1380,28 +1420,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "csv" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" -dependencies = [ - "bstr 0.2.17", - "csv-core", - "itoa 0.4.8", - "ryu", - "serde", -] - -[[package]] -name = "csv-core" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" -dependencies = [ - "memchr", -] - [[package]] name = "ctor" version = "0.1.26" @@ -2976,7 +2994,7 @@ checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 1.0.5", + "itoa", ] [[package]] @@ -3029,7 +3047,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.5", + "itoa", "pin-project-lite 0.2.9", "socket2", "tokio", @@ -3277,12 +3295,6 @@ dependencies = [ "either", ] -[[package]] -name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - [[package]] name = "itoa" version = "1.0.5" @@ -5083,7 +5095,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ "arrayvec 0.7.2", - "itoa 1.0.5", + "itoa", ] [[package]] @@ -7188,7 +7200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" dependencies = [ "dtoa", - "itoa 1.0.5", + "itoa", "parking_lot 0.12.1", "prometheus-client-derive-text-encode", ] @@ -9380,16 +9392,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde_cbor" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.152" @@ -9407,7 +9409,7 @@ version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ - "itoa 1.0.5", + "itoa", "ryu", "serde", ] @@ -10945,12 +10947,9 @@ checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" [[package]] name = "textwrap" -version = "0.11.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" @@ -11024,7 +11023,7 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" dependencies = [ - "itoa 1.0.5", + "itoa", "serde", "time-core", "time-macros", @@ -11338,9 +11337,9 @@ dependencies = [ [[package]] name = "trie-bench" -version = "0.33.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5b26bd2cdd7641c5beb476b314c0cb1f629832bf21a6235f545e2d47bc9d05a" +checksum = "2fbb0a830db7c42ae97ce4e21b30e2cf9dbcc1b4f7853bd1aedad3d806c281d0" dependencies = [ "criterion", "hash-db", diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index b55b35c056..c529c7c9b8 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -122,7 +122,7 @@ serde_json = "1.0" regex = "1.6.0" platforms = "2.0" soketto = "0.7.1" -criterion = { version = "0.3.5", features = ["async_tokio"] } +criterion = { version = "0.4.0", features = ["async_tokio"] } tokio = { version = "1.22.0", features = ["macros", "time", "parking_lot"] } tokio-util = { version = "0.7.4", features = ["compat"] } wait-timeout = "0.2" diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index edcc4df9c8..ffa8d38ee4 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -26,7 +26,7 @@ sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } sp-trie = { version = "7.0.0", path = "../../../primitives/trie" } [dev-dependencies] -criterion = "0.3.0" +criterion = "0.4.0" futures = "0.3.21" wat = "1.0" frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index a9f5e28c73..7a62cb1ea0 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -36,7 +36,7 @@ sp-state-machine = { version = "0.13.0", path = "../../primitives/state-machine" sp-trie = { version = "7.0.0", path = "../../primitives/trie" } [dev-dependencies] -criterion = "0.3.3" +criterion = "0.4.0" kvdb-rocksdb = "0.17.0" rand = "0.8.5" tempfile = "3.1.0" diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 8bedcd3edc..46b72565af 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -46,7 +46,7 @@ sc-tracing = { version = "4.0.0-dev", path = "../tracing" } tracing-subscriber = "0.2.19" paste = "1.0" regex = "1.6.0" -criterion = "0.3" +criterion = "0.4.0" env_logger = "0.9" num_cpus = "1.13.1" tempfile = "3.3.0" diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index be6237a344..9312c04e9f 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -39,7 +39,7 @@ sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" } [dev-dependencies] -criterion = "0.3" +criterion = "0.4.0" [[bench]] name = "bench" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index bbb5ebae44..6338f8127a 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -37,7 +37,7 @@ sp-transaction-pool = { version = "4.0.0-dev", path = "../../primitives/transact [dev-dependencies] array-bytes = "4.1" assert_matches = "1.3.0" -criterion = "0.3" +criterion = "0.4.0" sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" } substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" } diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 7f573a9cbd..5a6c89aae3 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -26,7 +26,7 @@ sp-version = { version = "5.0.0", default-features = false, path = "../../primit sp-weights = { version = "4.0.0", default-features = false, path = "../../primitives/weights" } [dev-dependencies] -criterion = "0.3.3" +criterion = "0.4.0" sp-externalities = { version = "0.13.0", path = "../../primitives/externalities" } substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index b3ceb14fe0..5b6c144ef3 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -25,7 +25,7 @@ trybuild = "1.0.74" rustversion = "1.0.6" [dev-dependencies] -criterion = "0.3.0" +criterion = "0.4.0" futures = "0.3.21" log = "0.4.17" sp-core = { version = "7.0.0", path = "../../core" } diff --git a/primitives/arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml index bbb4bbd177..b3fc6abc33 100644 --- a/primitives/arithmetic/Cargo.toml +++ b/primitives/arithmetic/Cargo.toml @@ -26,7 +26,7 @@ static_assertions = "1.1.0" sp-std = { version = "5.0.0", default-features = false, path = "../std" } [dev-dependencies] -criterion = "0.3" +criterion = "0.4.0" primitive-types = "0.12.0" sp-core = { version = "7.0.0", features = ["full_crypto"], path = "../core" } rand = "0.8.5" diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index f9a522178f..5fd838de35 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -25,7 +25,7 @@ impl-serde = { version = "0.4.0", optional = true } hash-db = { version = "0.15.2", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } base58 = { version = "0.2.0", optional = true } -rand = { version = "0.8.5", optional = true, features = ["small_rng"] } +rand = { version = "0.8.5", features = ["small_rng"], optional = true } substrate-bip39 = { version = "0.4.4", optional = true } tiny-bip39 = { version = "1.0.0", optional = true } regex = { version = "1.6.0", optional = true } @@ -60,7 +60,7 @@ sp-runtime-interface = { version = "7.0.0", default-features = false, path = ".. [dev-dependencies] sp-serializer = { version = "4.0.0-dev", path = "../serializer" } rand = "0.8.5" -criterion = "0.3.3" +criterion = "0.4.0" serde_json = "1.0" sp-core-hashing-proc-macro = { version = "5.0.0", path = "./hashing/proc-macro" } diff --git a/primitives/core/benches/bench.rs b/primitives/core/benches/bench.rs index 53421278dc..77e5bb63fe 100644 --- a/primitives/core/benches/bench.rs +++ b/primitives/core/benches/bench.rs @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[macro_use] -extern crate criterion; - -use criterion::{black_box, Bencher, BenchmarkId, Criterion}; +use criterion::{black_box, criterion_group, criterion_main, Bencher, BenchmarkId, Criterion}; use sp_core::{ crypto::Pair as _, hashing::{blake2_128, twox_128}, diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 78b0b5d1bb..1e83a5d6df 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -37,8 +37,8 @@ schnellru = { version = "0.2.1", optional = true } [dev-dependencies] array-bytes = "4.1" -criterion = "0.3.3" -trie-bench = "0.33.0" +criterion = "0.4.0" +trie-bench = "0.34.0" trie-standardmap = "0.15.2" sp-runtime = { version = "7.0.0", path = "../runtime" } From f4caddb2af951cac4ef3fcceb8079aa539f97af9 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 29 Jan 2023 13:23:15 -0300 Subject: [PATCH 70/80] fix up template (#13205) --- bin/node-template/pallets/template/Cargo.toml | 6 +++--- bin/node-template/pallets/template/src/mock.rs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/node-template/pallets/template/Cargo.toml b/bin/node-template/pallets/template/Cargo.toml index 6dec5c8da6..f6607b25c4 100644 --- a/bin/node-template/pallets/template/Cargo.toml +++ b/bin/node-template/pallets/template/Cargo.toml @@ -22,9 +22,9 @@ frame-support = { version = "4.0.0-dev", default-features = false, path = "../.. frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../../frame/system" } [dev-dependencies] -sp-core = { version = "7.0.0", default-features = false, path = "../../../../primitives/core" } -sp-io = { version = "7.0.0", default-features = false, path = "../../../../primitives/io" } -sp-runtime = { version = "7.0.0", default-features = false, path = "../../../../primitives/runtime" } +sp-core = { version = "7.0.0", path = "../../../../primitives/core" } +sp-io = { version = "7.0.0", path = "../../../../primitives/io" } +sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } [features] default = ["std"] diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 989681fa59..91a1bf6ed5 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -1,6 +1,5 @@ use crate as pallet_template; use frame_support::traits::{ConstU16, ConstU64}; -use frame_system as system; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -22,7 +21,7 @@ frame_support::construct_runtime!( } ); -impl system::Config for Test { +impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); @@ -55,5 +54,5 @@ impl pallet_template::Config for Test { // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::default().build_storage::().unwrap().into() } From fdff2b23009f25dd42d3a12fee6c998864399de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 29 Jan 2023 21:56:10 +0100 Subject: [PATCH 71/80] Remove `uncles` related code (#13216) The code was added without any clear usage. The inherent for example is not benchmarked and not used. --- Cargo.lock | 24 - Cargo.toml | 2 - bin/node/cli/Cargo.toml | 2 - bin/node/cli/src/service.rs | 12 +- bin/node/runtime/src/lib.rs | 6 - client/consensus/uncles/Cargo.toml | 19 - client/consensus/uncles/README.md | 3 - client/consensus/uncles/src/lib.rs | 45 -- frame/authorship/Cargo.toml | 2 - frame/authorship/src/lib.rs | 602 +----------------- frame/babe/src/mock.rs | 20 +- frame/grandpa/src/mock.rs | 20 +- frame/im-online/src/lib.rs | 4 - frame/im-online/src/mock.rs | 2 - frame/im-online/src/tests.rs | 5 +- frame/staking/src/mock.rs | 18 +- frame/staking/src/pallet/impls.rs | 10 - frame/staking/src/tests.rs | 9 +- .../asset-tx-payment/src/mock.rs | 14 +- primitives/authorship/Cargo.toml | 30 - primitives/authorship/README.md | 3 - primitives/authorship/src/lib.rs | 101 --- 22 files changed, 47 insertions(+), 906 deletions(-) delete mode 100644 client/consensus/uncles/Cargo.toml delete mode 100644 client/consensus/uncles/README.md delete mode 100644 client/consensus/uncles/src/lib.rs delete mode 100644 primitives/authorship/Cargo.toml delete mode 100644 primitives/authorship/README.md delete mode 100644 primitives/authorship/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index c075f065fd..29ddf38328 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4772,7 +4772,6 @@ dependencies = [ "sc-consensus-babe", "sc-consensus-epochs", "sc-consensus-slots", - "sc-consensus-uncles", "sc-executor", "sc-finality-grandpa", "sc-keystore", @@ -4792,7 +4791,6 @@ dependencies = [ "soketto", "sp-api", "sp-authority-discovery", - "sp-authorship", "sp-blockchain", "sp-consensus", "sp-consensus-babe", @@ -5379,7 +5377,6 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-authorship", "sp-core", "sp-io", "sp-runtime", @@ -8299,16 +8296,6 @@ dependencies = [ "substrate-test-runtime-client", ] -[[package]] -name = "sc-consensus-uncles" -version = "0.10.0-dev" -dependencies = [ - "sc-client-api", - "sp-authorship", - "sp-runtime", - "thiserror", -] - [[package]] name = "sc-executor" version = "0.10.0-dev" @@ -9714,17 +9701,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "sp-authorship" -version = "4.0.0-dev" -dependencies = [ - "async-trait", - "parity-scale-codec", - "sp-inherents", - "sp-runtime", - "sp-std", -] - [[package]] name = "sp-beefy" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index bb52305162..b004886e83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ members = [ "client/consensus/manual-seal", "client/consensus/pow", "client/consensus/slots", - "client/consensus/uncles", "client/db", "client/executor", "client/executor/common", @@ -177,7 +176,6 @@ members = [ "primitives/arithmetic", "primitives/arithmetic/fuzzer", "primitives/authority-discovery", - "primitives/authorship", "primitives/beefy", "primitives/block-builder", "primitives/blockchain", diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index c529c7c9b8..9ec06d9d9c 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -52,7 +52,6 @@ sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } sp-core = { version = "7.0.0", path = "../../../primitives/core" } sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } -sp-authorship = { version = "4.0.0-dev", path = "../../../primitives/authorship" } sp-inherents = { version = "4.0.0-dev", path = "../../../primitives/inherents" } sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" } sp-keystore = { version = "0.13.0", path = "../../../primitives/keystore" } @@ -71,7 +70,6 @@ sc-network = { version = "0.10.0-dev", path = "../../../client/network" } sc-network-common = { version = "0.10.0-dev", path = "../../../client/network/common" } sc-consensus-slots = { version = "0.10.0-dev", path = "../../../client/consensus/slots" } sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" } -sc-consensus-uncles = { version = "0.10.0-dev", path = "../../../client/consensus/uncles" } grandpa = { version = "0.10.0-dev", package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } sc-rpc = { version = "4.0.0-dev", path = "../../../client/rpc" } sc-basic-authorship = { version = "0.10.0-dev", path = "../../../client/basic-authorship" } diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index e329087947..b1e9360b4a 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -222,10 +222,7 @@ pub fn new_partial( slot_duration, ); - let uncles = - sp_authorship::InherentDataProvider::<::Header>::check_inherents(); - - Ok((slot, timestamp, uncles)) + Ok((slot, timestamp)) }, &task_manager.spawn_essential_handle(), config.prometheus_registry(), @@ -440,11 +437,6 @@ pub fn new_full_base( create_inherent_data_providers: move |parent, ()| { let client_clone = client_clone.clone(); async move { - let uncles = sc_consensus_uncles::create_uncles_inherent_data_provider( - &*client_clone, - parent, - )?; - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); let slot = @@ -459,7 +451,7 @@ pub fn new_full_base( &parent, )?; - Ok((slot, timestamp, uncles, storage_proof)) + Ok((slot, timestamp, storage_proof)) } }, force_authoring, diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index bd8a395d15..30165cdb6f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -488,14 +488,8 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = pallet_timestamp::weights::SubstrateWeight; } -parameter_types! { - pub const UncleGenerations: BlockNumber = 5; -} - impl pallet_authorship::Config for Runtime { type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type UncleGenerations = UncleGenerations; - type FilterUncle = (); type EventHandler = (Staking, ImOnline); } diff --git a/client/consensus/uncles/Cargo.toml b/client/consensus/uncles/Cargo.toml deleted file mode 100644 index 0be48659f9..0000000000 --- a/client/consensus/uncles/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "sc-consensus-uncles" -version = "0.10.0-dev" -authors = ["Parity Technologies "] -description = "Generic uncle inclusion utilities for consensus" -edition = "2021" -license = "GPL-3.0-or-later WITH Classpath-exception-2.0" -homepage = "https://substrate.io" -repository = "https://github.com/paritytech/substrate/" -readme = "README.md" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -thiserror = "1.0.30" -sc-client-api = { version = "4.0.0-dev", path = "../../api" } -sp-authorship = { version = "4.0.0-dev", path = "../../../primitives/authorship" } -sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } diff --git a/client/consensus/uncles/README.md b/client/consensus/uncles/README.md deleted file mode 100644 index 1b6fed5b97..0000000000 --- a/client/consensus/uncles/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Uncles functionality for Substrate. - -License: GPL-3.0-or-later WITH Classpath-exception-2.0 \ No newline at end of file diff --git a/client/consensus/uncles/src/lib.rs b/client/consensus/uncles/src/lib.rs deleted file mode 100644 index d03c2f8aa6..0000000000 --- a/client/consensus/uncles/src/lib.rs +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -//! Uncles functionality for Substrate. - -use sc_client_api::ProvideUncles; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("Could not retrieve the block hash for block id: {0:?}")] - NoHashForBlockId(BlockId), -} - -/// Maximum uncles generations we may provide to the runtime. -const MAX_UNCLE_GENERATIONS: u32 = 8; - -/// Create a new [`sp_authorship::InherentDataProvider`] at the given block. -pub fn create_uncles_inherent_data_provider( - client: &C, - parent: B::Hash, -) -> Result, sc_client_api::blockchain::Error> -where - B: BlockT, - C: ProvideUncles, -{ - let uncles = client.uncles(parent, MAX_UNCLE_GENERATIONS.into())?; - - Ok(sp_authorship::InherentDataProvider::new(uncles)) -} diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index 84d00a6fbc..a205c51f9c 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -20,7 +20,6 @@ impl-trait-for-tuples = "0.2.2" scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } -sp-authorship = { version = "4.0.0-dev", default-features = false, path = "../../primitives/authorship" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" } sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" } @@ -35,7 +34,6 @@ std = [ "frame-support/std", "frame-system/std", "scale-info/std", - "sp-authorship/std", "sp-runtime/std", "sp-std/std", ] diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 4065472d92..b5568a6acf 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -17,36 +17,12 @@ //! Authorship tracking for FRAME runtimes. //! -//! This tracks the current author of the block and recent uncles. +//! This tracks the current author of the block. #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{ - dispatch, - traits::{Defensive, FindAuthor, Get, VerifySeal}, - BoundedSlice, BoundedVec, -}; -use sp_authorship::{InherentError, UnclesInherentData, INHERENT_IDENTIFIER}; -use sp_runtime::traits::{Header as HeaderT, One, Saturating, UniqueSaturatedInto}; -use sp_std::{collections::btree_set::BTreeSet, prelude::*, result}; - -const MAX_UNCLES: usize = 10; - -struct MaxUncleEntryItems(core::marker::PhantomData); -impl Get for MaxUncleEntryItems { - fn get() -> u32 { - // There can be at most `MAX_UNCLES` of `UncleEntryItem::Uncle` and - // one `UncleEntryItem::InclusionHeight` per one `UncleGenerations`, - // so this gives us `MAX_UNCLES + 1` entries per one generation. - // - // There can be one extra generation worth of uncles (e.g. even - // if `UncleGenerations` is zero the pallet will still hold - // one generation worth of uncles). - let max_generations: u32 = T::UncleGenerations::get().unique_saturated_into(); - (MAX_UNCLES as u32 + 1) * (max_generations + 1) - } -} +use frame_support::traits::FindAuthor; +use sp_std::prelude::*; pub use pallet::*; @@ -56,87 +32,8 @@ pub use pallet::*; pub trait EventHandler { /// Note that the given account ID is the author of the current block. fn note_author(author: Author); - - /// Note that the given account ID authored the given uncle, and how many - /// blocks older than the current block it is (age >= 0, so siblings are allowed) - fn note_uncle(author: Author, age: BlockNumber); -} - -/// Additional filtering on uncles that pass preliminary ancestry checks. -/// -/// This should do work such as checking seals -pub trait FilterUncle { - /// An accumulator of data about uncles included. - /// - /// In practice, this is used to validate uncles against others in the same block. - type Accumulator: Default; - - /// Do additional filtering on a seal-checked uncle block, with the accumulated - /// filter. - fn filter_uncle( - header: &Header, - acc: &mut Self::Accumulator, - ) -> Result, &'static str>; } -impl FilterUncle for () { - type Accumulator = (); - fn filter_uncle(_: &H, _acc: &mut Self::Accumulator) -> Result, &'static str> { - Ok(None) - } -} - -/// A filter on uncles which verifies seals and does no additional checks. -/// This is well-suited to consensus modes such as PoW where the cost of -/// equivocating is high. -pub struct SealVerify(sp_std::marker::PhantomData); - -impl> FilterUncle for SealVerify { - type Accumulator = (); - - fn filter_uncle(header: &Header, _acc: &mut ()) -> Result, &'static str> { - T::verify_seal(header) - } -} - -/// A filter on uncles which verifies seals and ensures that there is only -/// one uncle included per author per height. -/// -/// This does O(n log n) work in the number of uncles included. -pub struct OnePerAuthorPerHeight(sp_std::marker::PhantomData<(T, N)>); - -impl FilterUncle for OnePerAuthorPerHeight -where - Header: HeaderT + PartialEq, - Header::Number: Ord, - Author: Clone + PartialEq + Ord, - T: VerifySeal, -{ - type Accumulator = BTreeSet<(Header::Number, Author)>; - - fn filter_uncle( - header: &Header, - acc: &mut Self::Accumulator, - ) -> Result, &'static str> { - let author = T::verify_seal(header)?; - let number = header.number(); - - if let Some(ref author) = author { - if !acc.insert((*number, author.clone())) { - return Err("more than one uncle per number per author included") - } - } - - Ok(author) - } -} - -#[derive(Encode, Decode, sp_runtime::RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen)] -#[cfg_attr(any(feature = "std", test), derive(PartialEq))] -enum UncleEntryItem { - InclusionHeight(BlockNumber), - Uncle(Hash, Option), -} #[frame_support::pallet] pub mod pallet { use super::*; @@ -147,25 +44,6 @@ pub mod pallet { pub trait Config: frame_system::Config { /// Find the author of a block. type FindAuthor: FindAuthor; - /// The number of blocks back we should accept uncles. - /// This means that we will deal with uncle-parents that are - /// `UncleGenerations + 1` before `now`. - #[pallet::constant] - type UncleGenerations: Get; - /// A filter for uncles within a block. This is for implementing - /// further constraints on what uncles can be included, other than their ancestry. - /// - /// For PoW, as long as the seals are checked, there is no need to use anything - /// but the `VerifySeal` implementation as the filter. This is because the cost of making - /// many equivocating uncles is high. - /// - /// For PoS, there is no such limitation, so a further constraint must be imposed - /// beyond a seal check in order to prevent an arbitrary number of - /// equivocating uncles from being included. - /// - /// The `OnePerAuthorPerHeight` filter is good for many slot-based PoS - /// engines. - type FilterUncle: FilterUncle; /// An event handler for authored blocks. type EventHandler: EventHandler; } @@ -176,16 +54,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: T::BlockNumber) -> Weight { - let uncle_generations = T::UncleGenerations::get(); - // prune uncles that are older than the allowed number of generations. - if uncle_generations <= now { - let minimum_height = now - uncle_generations; - Self::prune_old_uncles(minimum_height) - } - - >::put(false); - + fn on_initialize(_: T::BlockNumber) -> Weight { if let Some(author) = Self::author() { T::EventHandler::note_author(author); } @@ -196,125 +65,12 @@ pub mod pallet { fn on_finalize(_: T::BlockNumber) { // ensure we never go to trie with these values. >::kill(); - >::kill(); } } - #[pallet::storage] - /// Uncles - pub(super) type Uncles = StorageValue< - _, - BoundedVec, MaxUncleEntryItems>, - ValueQuery, - >; - #[pallet::storage] /// Author of current block. pub(super) type Author = StorageValue<_, T::AccountId, OptionQuery>; - - #[pallet::storage] - /// Whether uncles were already set in this block. - pub(super) type DidSetUncles = StorageValue<_, bool, ValueQuery>; - - #[pallet::error] - pub enum Error { - /// The uncle parent not in the chain. - InvalidUncleParent, - /// Uncles already set in the block. - UnclesAlreadySet, - /// Too many uncles. - TooManyUncles, - /// The uncle is genesis. - GenesisUncle, - /// The uncle is too high in chain. - TooHighUncle, - /// The uncle is already included. - UncleAlreadyIncluded, - /// The uncle isn't recent enough to be included. - OldUncle, - } - - #[pallet::call] - impl Pallet { - /// Provide a set of uncles. - #[pallet::call_index(0)] - #[pallet::weight((0, DispatchClass::Mandatory))] - pub fn set_uncles(origin: OriginFor, new_uncles: Vec) -> DispatchResult { - ensure_none(origin)?; - ensure!(new_uncles.len() <= MAX_UNCLES, Error::::TooManyUncles); - - if >::get() { - return Err(Error::::UnclesAlreadySet.into()) - } - >::put(true); - - Self::verify_and_import_uncles(new_uncles) - } - } - - #[pallet::inherent] - impl ProvideInherent for Pallet { - type Call = Call; - type Error = InherentError; - const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - - fn create_inherent(data: &InherentData) -> Option { - let uncles = data.uncles().unwrap_or_default(); - let mut new_uncles = Vec::new(); - - if !uncles.is_empty() { - let prev_uncles = >::get(); - let mut existing_hashes: Vec<_> = prev_uncles - .into_iter() - .filter_map(|entry| match entry { - UncleEntryItem::InclusionHeight(_) => None, - UncleEntryItem::Uncle(h, _) => Some(h), - }) - .collect(); - - let mut acc: >::Accumulator = - Default::default(); - - for uncle in uncles { - match Self::verify_uncle(&uncle, &existing_hashes, &mut acc) { - Ok(_) => { - let hash = uncle.hash(); - new_uncles.push(uncle); - existing_hashes.push(hash); - - if new_uncles.len() == MAX_UNCLES { - break - } - }, - Err(_) => { - // skip this uncle - }, - } - } - } - - if new_uncles.is_empty() { - None - } else { - Some(Call::set_uncles { new_uncles }) - } - } - - fn check_inherent( - call: &Self::Call, - _data: &InherentData, - ) -> result::Result<(), Self::Error> { - match call { - Call::set_uncles { ref new_uncles } if new_uncles.len() > MAX_UNCLES => - Err(InherentError::Uncles(Error::::TooManyUncles.as_str().into())), - _ => Ok(()), - } - } - - fn is_inherent(call: &Self::Call) -> bool { - matches!(call, Call::set_uncles { .. }) - } - } } impl Pallet { @@ -323,7 +79,7 @@ impl Pallet { /// This is safe to invoke in `on_initialize` implementations, as well /// as afterwards. pub fn author() -> Option { - // Check the memoized storage value. + // Check the memorized storage value. if let Some(author) = >::get() { return Some(author) } @@ -335,113 +91,22 @@ impl Pallet { a }) } - - fn verify_and_import_uncles(new_uncles: Vec) -> dispatch::DispatchResult { - let now = >::block_number(); - - let mut uncles = >::get(); - uncles - .try_push(UncleEntryItem::InclusionHeight(now)) - .defensive_proof("the list of uncles accepted per generation is bounded, and the number of generations is bounded, so pushing a new element will always succeed") - .map_err(|_| Error::::TooManyUncles)?; - - let mut acc: >::Accumulator = Default::default(); - - for uncle in new_uncles { - let prev_uncles = uncles.iter().filter_map(|entry| match entry { - UncleEntryItem::InclusionHeight(_) => None, - UncleEntryItem::Uncle(h, _) => Some(h), - }); - let maybe_author = Self::verify_uncle(&uncle, prev_uncles, &mut acc)?; - let hash = uncle.hash(); - - if let Some(author) = maybe_author.clone() { - T::EventHandler::note_uncle(author, now - *uncle.number()); - } - uncles.try_push(UncleEntryItem::Uncle(hash, maybe_author)) - .defensive_proof("the list of uncles accepted per generation is bounded, and the number of generations is bounded, so pushing a new element will always succeed") - .map_err(|_| Error::::TooManyUncles)?; - } - - >::put(&uncles); - Ok(()) - } - - fn verify_uncle<'a, I: IntoIterator>( - uncle: &T::Header, - existing_uncles: I, - accumulator: &mut >::Accumulator, - ) -> Result, dispatch::DispatchError> { - let now = >::block_number(); - - let (minimum_height, maximum_height) = { - let uncle_generations = T::UncleGenerations::get(); - let min = now.saturating_sub(uncle_generations); - - (min, now) - }; - - let hash = uncle.hash(); - - if uncle.number() < &One::one() { - return Err(Error::::GenesisUncle.into()) - } - - if uncle.number() > &maximum_height { - return Err(Error::::TooHighUncle.into()) - } - - { - let parent_number = *uncle.number() - One::one(); - let parent_hash = >::block_hash(&parent_number); - if &parent_hash != uncle.parent_hash() { - return Err(Error::::InvalidUncleParent.into()) - } - } - - if uncle.number() < &minimum_height { - return Err(Error::::OldUncle.into()) - } - - let duplicate = existing_uncles.into_iter().any(|h| *h == hash); - let in_chain = >::block_hash(uncle.number()) == hash; - - if duplicate || in_chain { - return Err(Error::::UncleAlreadyIncluded.into()) - } - - // check uncle validity. - T::FilterUncle::filter_uncle(uncle, accumulator).map_err(Into::into) - } - - fn prune_old_uncles(minimum_height: T::BlockNumber) { - let uncles = >::get(); - let prune_entries = uncles.iter().take_while(|item| match item { - UncleEntryItem::Uncle(_, _) => true, - UncleEntryItem::InclusionHeight(height) => height < &minimum_height, - }); - let prune_index = prune_entries.count(); - let pruned_uncles = - >>::try_from(&uncles[prune_index..]) - .expect("after pruning we can't end up with more uncles than we started with"); - - >::put(pruned_uncles); - } } #[cfg(test)] mod tests { use super::*; use crate as pallet_authorship; + use codec::{Decode, Encode}; use frame_support::{ - traits::{ConstU32, ConstU64, OnFinalize, OnInitialize}, + traits::{ConstU32, ConstU64}, ConsensusEngineId, }; use sp_core::H256; use sp_runtime::{ generic::DigestItem, testing::Header, - traits::{BlakeTwo256, IdentityLookup}, + traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -454,7 +119,7 @@ mod tests { UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, + Authorship: pallet_authorship::{Pallet, Storage}, } ); @@ -487,8 +152,6 @@ mod tests { impl pallet::Config for Test { type FindAuthor = AuthorGiven; - type UncleGenerations = ConstU64<5>; - type FilterUncle = SealVerify; type EventHandler = (); } @@ -511,34 +174,6 @@ mod tests { } } - pub struct VerifyBlock; - - impl VerifySeal for VerifyBlock { - fn verify_seal(header: &Header) -> Result, &'static str> { - let pre_runtime_digests = header.digest.logs.iter().filter_map(|d| d.as_pre_runtime()); - let seals = header.digest.logs.iter().filter_map(|d| d.as_seal()); - - let author = - AuthorGiven::find_author(pre_runtime_digests).ok_or_else(|| "no author")?; - - for (id, mut seal) in seals { - if id == TEST_ID { - match u64::decode(&mut seal) { - Err(_) => return Err("wrong seal"), - Ok(a) => { - if a != author { - return Err("wrong author in seal") - } - break - }, - } - } - } - - Ok(Some(author)) - } - } - fn seal_header(mut header: Header, author: u64) -> Header { { let digest = header.digest_mut(); @@ -558,196 +193,6 @@ mod tests { t.into() } - #[test] - fn prune_old_uncles_works() { - use UncleEntryItem::*; - new_test_ext().execute_with(|| { - let hash = Default::default(); - let author = Default::default(); - let uncles = vec![ - InclusionHeight(1u64), - Uncle(hash, Some(author)), - Uncle(hash, None), - Uncle(hash, None), - InclusionHeight(2u64), - Uncle(hash, None), - InclusionHeight(3u64), - Uncle(hash, None), - ]; - let uncles = BoundedVec::try_from(uncles).unwrap(); - - ::Uncles::put(uncles); - Authorship::prune_old_uncles(3); - - let uncles = ::Uncles::get(); - assert_eq!(uncles, vec![InclusionHeight(3u64), Uncle(hash, None)]); - }) - } - - #[test] - fn rejects_bad_uncles() { - new_test_ext().execute_with(|| { - let author_a = 69; - - struct CanonChain { - inner: Vec
, - } - - impl CanonChain { - fn best_hash(&self) -> H256 { - self.inner.last().unwrap().hash() - } - - fn canon_hash(&self, index: usize) -> H256 { - self.inner[index].hash() - } - - fn header(&self, index: usize) -> &Header { - &self.inner[index] - } - - fn push(&mut self, header: Header) { - self.inner.push(header) - } - } - - let mut canon_chain = CanonChain { - inner: vec![seal_header( - create_header(0, Default::default(), Default::default()), - 999, - )], - }; - - let initialize_block = |number, hash: H256| { - System::reset_events(); - System::initialize(&number, &hash, &Default::default()) - }; - - for number in 1..8 { - initialize_block(number, canon_chain.best_hash()); - let header = seal_header(System::finalize(), author_a); - canon_chain.push(header); - } - - // initialize so system context is set up correctly. - initialize_block(8, canon_chain.best_hash()); - - // 2 of the same uncle at once - { - let uncle_a = seal_header( - create_header(3, canon_chain.canon_hash(2), [1; 32].into()), - author_a, - ); - assert_eq!( - Authorship::verify_and_import_uncles(vec![uncle_a.clone(), uncle_a.clone()]), - Err(Error::::UncleAlreadyIncluded.into()), - ); - } - - // 2 of the same uncle at different times. - { - let uncle_a = seal_header( - create_header(3, canon_chain.canon_hash(2), [1; 32].into()), - author_a, - ); - - assert!(Authorship::verify_and_import_uncles(vec![uncle_a.clone()]).is_ok()); - - assert_eq!( - Authorship::verify_and_import_uncles(vec![uncle_a.clone()]), - Err(Error::::UncleAlreadyIncluded.into()), - ); - } - - // same uncle as ancestor. - { - let uncle_clone = canon_chain.header(5).clone(); - - assert_eq!( - Authorship::verify_and_import_uncles(vec![uncle_clone]), - Err(Error::::UncleAlreadyIncluded.into()), - ); - } - - // uncle without valid seal. - { - let unsealed = create_header(3, canon_chain.canon_hash(2), [2; 32].into()); - assert_eq!( - Authorship::verify_and_import_uncles(vec![unsealed]), - Err("no author".into()), - ); - } - - // old uncles can't get in. - { - assert_eq!(System::block_number(), 8); - - let gen_2 = seal_header( - create_header(2, canon_chain.canon_hash(1), [3; 32].into()), - author_a, - ); - - assert_eq!( - Authorship::verify_and_import_uncles(vec![gen_2]), - Err(Error::::OldUncle.into()), - ); - } - - // siblings are also allowed - { - let other_8 = seal_header( - create_header(8, canon_chain.canon_hash(7), [1; 32].into()), - author_a, - ); - - assert!(Authorship::verify_and_import_uncles(vec![other_8]).is_ok()); - } - }); - } - - #[test] - fn maximum_bound() { - new_test_ext().execute_with(|| { - let mut max_item_count = 0; - - let mut author_counter = 0; - let mut current_depth = 1; - let mut parent_hash: H256 = [1; 32].into(); - let mut uncles = vec![]; - - // We deliberately run this for more generations than the limit - // so that we can get the `Uncles` to hit its cap. - for _ in 0..<::UncleGenerations as Get>::get() + 3 { - let new_uncles: Vec<_> = (0..MAX_UNCLES) - .map(|_| { - System::reset_events(); - System::initialize(¤t_depth, &parent_hash, &Default::default()); - // Increment the author on every block to make sure the hash's always - // different. - author_counter += 1; - seal_header(System::finalize(), author_counter) - }) - .collect(); - - author_counter += 1; - System::reset_events(); - System::initialize(¤t_depth, &parent_hash, &Default::default()); - Authorship::on_initialize(current_depth); - Authorship::set_uncles(RuntimeOrigin::none(), uncles).unwrap(); - Authorship::on_finalize(current_depth); - max_item_count = - std::cmp::max(max_item_count, ::Uncles::get().len()); - - let new_parent = seal_header(System::finalize(), author_counter); - parent_hash = new_parent.hash(); - uncles = new_uncles; - current_depth += 1; - } - - assert_eq!(max_item_count, MaxUncleEntryItems::::get() as usize); - }); - } - #[test] fn sets_author_lazily() { new_test_ext().execute_with(|| { @@ -762,33 +207,4 @@ mod tests { assert_eq!(Authorship::author(), Some(author)); }); } - - #[test] - fn one_uncle_per_author_per_number() { - type Filter = OnePerAuthorPerHeight; - - let author_a = 42; - let author_b = 43; - - let mut acc: >::Accumulator = Default::default(); - let header_a1 = seal_header(create_header(1, Default::default(), [1; 32].into()), author_a); - let header_b1 = seal_header(create_header(1, Default::default(), [1; 32].into()), author_b); - - let header_a2_1 = - seal_header(create_header(2, Default::default(), [1; 32].into()), author_a); - let header_a2_2 = - seal_header(create_header(2, Default::default(), [2; 32].into()), author_a); - - let mut check_filter = move |uncle| Filter::filter_uncle(uncle, &mut acc); - - // same height, different author is OK. - assert_eq!(check_filter(&header_a1), Ok(Some(author_a))); - assert_eq!(check_filter(&header_b1), Ok(Some(author_b))); - - // same author, different height. - assert_eq!(check_filter(&header_a2_1), Ok(Some(author_a))); - - // same author, same height (author a, height 2) - assert!(check_filter(&header_a2_2).is_err()); - } } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index abae1b7e33..b09dc29f6d 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -52,15 +52,15 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Historical: pallet_session_historical::{Pallet}, - Offences: pallet_offences::{Pallet, Storage, Event}, - Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned}, - Staking: pallet_staking::{Pallet, Call, Storage, Config, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, + System: frame_system, + Authorship: pallet_authorship, + Balances: pallet_balances, + Historical: pallet_session_historical, + Offences: pallet_offences, + Babe: pallet_babe, + Staking: pallet_staking, + Session: pallet_session, + Timestamp: pallet_timestamp, } ); @@ -124,8 +124,6 @@ impl pallet_session::historical::Config for Test { impl pallet_authorship::Config for Test { type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type UncleGenerations = ConstU64<0>; - type FilterUncle = (); type EventHandler = (); } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index c618705af0..54f34008ab 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -51,15 +51,15 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned}, - Offences: pallet_offences::{Pallet, Storage, Event}, - Historical: pallet_session_historical::{Pallet}, + System: frame_system, + Authorship: pallet_authorship, + Timestamp: pallet_timestamp, + Balances: pallet_balances, + Staking: pallet_staking, + Session: pallet_session, + Grandpa: pallet_grandpa, + Offences: pallet_offences, + Historical: pallet_session_historical, } ); @@ -129,8 +129,6 @@ impl pallet_session::historical::Config for Test { impl pallet_authorship::Config for Test { type FindAuthor = (); - type UncleGenerations = ConstU64<0>; - type FilterUncle = (); type EventHandler = (); } diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index f23e610a48..8c1f46978e 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -607,10 +607,6 @@ impl fn note_author(author: ValidatorId) { Self::note_authorship(author); } - - fn note_uncle(author: ValidatorId, _age: T::BlockNumber) { - Self::note_authorship(author); - } } impl Pallet { diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index bcb13fa1be..783e68dfed 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -169,8 +169,6 @@ impl pallet_session::historical::Config for Runtime { impl pallet_authorship::Config for Runtime { type FindAuthor = (); - type UncleGenerations = ConstU64<5>; - type FilterUncle = (); type EventHandler = ImOnline; } diff --git a/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index 366119278d..2c026f7176 100644 --- a/frame/im-online/src/tests.rs +++ b/frame/im-online/src/tests.rs @@ -308,11 +308,10 @@ fn should_mark_online_validator_when_block_is_authored() { // when ImOnline::note_author(1); - ImOnline::note_uncle(2, 0); // then assert!(ImOnline::is_online(0)); - assert!(ImOnline::is_online(1)); + assert!(!ImOnline::is_online(1)); assert!(!ImOnline::is_online(2)); }); } @@ -338,7 +337,7 @@ fn should_not_send_a_report_if_already_online() { assert_eq!(Session::current_index(), 2); assert_eq!(Session::validators(), vec![1, 2, 3]); ImOnline::note_author(2); - ImOnline::note_uncle(3, 0); + ImOnline::note_author(3); // when UintAuthorityId::set_all_keys(vec![1, 2, 3]); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index ad27a82910..30db036d00 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -91,14 +91,14 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Historical: pallet_session::historical::{Pallet, Storage}, - VoterBagsList: pallet_bags_list::::{Pallet, Call, Storage, Event}, + System: frame_system, + Authorship: pallet_authorship, + Timestamp: pallet_timestamp, + Balances: pallet_balances, + Staking: pallet_staking, + Session: pallet_session, + Historical: pallet_session::historical, + VoterBagsList: pallet_bags_list::, } ); @@ -182,8 +182,6 @@ impl pallet_session::historical::Config for Test { } impl pallet_authorship::Config for Test { type FindAuthor = Author11; - type UncleGenerations = ConstU64<0>; - type FilterUncle = (); type EventHandler = Pallet; } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 7af9b0aaaa..e59c2c5a06 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -1217,8 +1217,6 @@ impl historical::SessionManager pallet_authorship::EventHandler for Pallet where T: Config + pallet_authorship::Config + pallet_session::Config, @@ -1226,14 +1224,6 @@ where fn note_author(author: T::AccountId) { Self::reward_by_ids(vec![(author, 20)]) } - fn note_uncle(uncle_author: T::AccountId, _age: T::BlockNumber) { - // defensive-only: block author must exist. - if let Some(block_author) = >::author() { - Self::reward_by_ids(vec![(block_author, 2), (uncle_author, 1)]) - } else { - crate::log!(warn, "block author not set, this should never happen"); - } - } } /// This is intended to be used with `FilterHistoricalOffences`. diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 9635717d4c..e200f621b3 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -2237,9 +2237,7 @@ fn reward_from_authorship_event_handler_works() { assert_eq!(>::author(), Some(11)); Pallet::::note_author(11); - Pallet::::note_uncle(21, 1); - // Rewarding the same two times works. - Pallet::::note_uncle(11, 1); + Pallet::::note_author(11); // Not mandatory but must be coherent with rewards assert_eq_uvec!(Session::validators(), vec![11, 21]); @@ -2248,10 +2246,7 @@ fn reward_from_authorship_event_handler_works() { // 11 is rewarded as a block producer and uncle referencer and uncle producer assert_eq!( ErasRewardPoints::::get(active_era()), - EraRewardPoints { - individual: vec![(11, 20 + 2 * 2 + 1), (21, 1)].into_iter().collect(), - total: 26, - }, + EraRewardPoints { individual: vec![(11, 20 * 2)].into_iter().collect(), total: 40 }, ); }) } diff --git a/frame/transaction-payment/asset-tx-payment/src/mock.rs b/frame/transaction-payment/asset-tx-payment/src/mock.rs index ddb02f5a61..60fb2e6c5e 100644 --- a/frame/transaction-payment/asset-tx-payment/src/mock.rs +++ b/frame/transaction-payment/asset-tx-payment/src/mock.rs @@ -45,12 +45,12 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic, { - System: system::{Pallet, Call, Config, Storage, Event}, - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event}, - Assets: pallet_assets::{Pallet, Call, Storage, Event}, - Authorship: pallet_authorship::{Pallet, Call, Storage}, - AssetTxPayment: pallet_asset_tx_payment::{Pallet, Event}, + System: system, + Balances: pallet_balances, + TransactionPayment: pallet_transaction_payment, + Assets: pallet_assets, + Authorship: pallet_authorship, + AssetTxPayment: pallet_asset_tx_payment, } ); @@ -187,8 +187,6 @@ impl FindAuthor for HardcodedAuthor { impl pallet_authorship::Config for Runtime { type FindAuthor = HardcodedAuthor; - type UncleGenerations = (); - type FilterUncle = (); type EventHandler = (); } diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml deleted file mode 100644 index 31ea3b2d4c..0000000000 --- a/primitives/authorship/Cargo.toml +++ /dev/null @@ -1,30 +0,0 @@ -[package] -name = "sp-authorship" -version = "4.0.0-dev" -authors = ["Parity Technologies "] -description = "Authorship primitives" -edition = "2021" -license = "Apache-2.0" -homepage = "https://substrate.io" -repository = "https://github.com/paritytech/substrate/" -readme = "README.md" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -async-trait = { version = "0.1.57", optional = true } -codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } -sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" } -sp-runtime = { version = "7.0.0", default-features = false, path = "../runtime" } -sp-std = { version = "5.0.0", default-features = false, path = "../std" } - -[features] -default = [ "std" ] -std = [ - "async-trait", - "codec/std", - "sp-inherents/std", - "sp-runtime/std", - "sp-std/std", -] diff --git a/primitives/authorship/README.md b/primitives/authorship/README.md deleted file mode 100644 index 1aa1805cfc..0000000000 --- a/primitives/authorship/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Authorship Primitives - -License: Apache-2.0 \ No newline at end of file diff --git a/primitives/authorship/src/lib.rs b/primitives/authorship/src/lib.rs deleted file mode 100644 index 6ff6607a89..0000000000 --- a/primitives/authorship/src/lib.rs +++ /dev/null @@ -1,101 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Authorship Primitives - -#![cfg_attr(not(feature = "std"), no_std)] - -use sp_std::{prelude::*, result::Result}; - -#[cfg(feature = "std")] -use codec::Decode; -use codec::Encode; -use sp_inherents::{Error, InherentData, InherentIdentifier, IsFatalError}; -use sp_runtime::{traits::Header as HeaderT, RuntimeString}; - -/// The identifier for the `uncles` inherent. -pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"uncles00"; - -/// Errors that can occur while checking the authorship inherent. -#[derive(Encode, sp_runtime::RuntimeDebug)] -#[cfg_attr(feature = "std", derive(Decode))] -pub enum InherentError { - Uncles(RuntimeString), -} - -impl IsFatalError for InherentError { - fn is_fatal_error(&self) -> bool { - match self { - InherentError::Uncles(_) => true, - } - } -} - -/// Auxiliary trait to extract uncles inherent data. -pub trait UnclesInherentData { - /// Get uncles. - fn uncles(&self) -> Result, Error>; -} - -impl UnclesInherentData for InherentData { - fn uncles(&self) -> Result, Error> { - Ok(self.get_data(&INHERENT_IDENTIFIER)?.unwrap_or_default()) - } -} - -/// Provider for inherent data. -#[cfg(feature = "std")] -pub struct InherentDataProvider { - uncles: Vec, -} - -#[cfg(feature = "std")] -impl InherentDataProvider { - /// Create a new inherent data provider with the given `uncles`. - pub fn new(uncles: Vec) -> Self { - InherentDataProvider { uncles } - } - - /// Create a new instance that is usable for checking inherents. - /// - /// This will always return an empty vec of uncles. - pub fn check_inherents() -> Self { - Self { uncles: Vec::new() } - } -} - -#[cfg(feature = "std")] -#[async_trait::async_trait] -impl sp_inherents::InherentDataProvider for InherentDataProvider { - async fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> { - inherent_data.put_data(INHERENT_IDENTIFIER, &self.uncles) - } - - async fn try_handle_error( - &self, - identifier: &InherentIdentifier, - mut error: &[u8], - ) -> Option> { - if *identifier != INHERENT_IDENTIFIER { - return None - } - - let error = InherentError::decode(&mut error).ok()?; - - Some(Err(Error::Application(Box::from(format!("{:?}", error))))) - } -} From a9c4334d96cbb63aff8e3141a5b3dcad8c636bb7 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Mon, 30 Jan 2023 14:32:09 +0900 Subject: [PATCH 72/80] Implement RIType traits for u8 array with an arbitrary size (#13256) --- primitives/runtime-interface/src/impls.rs | 115 +++++++++------------- 1 file changed, 48 insertions(+), 67 deletions(-) diff --git a/primitives/runtime-interface/src/impls.rs b/primitives/runtime-interface/src/impls.rs index e801931c30..e311b01dbe 100644 --- a/primitives/runtime-interface/src/impls.rs +++ b/primitives/runtime-interface/src/impls.rs @@ -276,84 +276,65 @@ impl IntoFFIValue for [T] { } } -/// Implement the traits for the `[u8; N]` arrays, where `N` is the input to this macro. -macro_rules! impl_traits_for_arrays { - ( - $( - $n:expr - ),* - $(,)? - ) => { - $( - /// The type is passed as `u32`. - /// - /// The `u32` is the pointer to the array. - impl RIType for [u8; $n] { - type FFIType = u32; - } - - #[cfg(not(feature = "std"))] - impl IntoFFIValue for [u8; $n] { - type Owned = (); +/// The type is passed as `u32`. +/// +/// The `u32` is the pointer to the array. +impl RIType for [u8; N] { + type FFIType = u32; +} - fn into_ffi_value(&self) -> WrappedFFIValue { - (self.as_ptr() as u32).into() - } - } +#[cfg(not(feature = "std"))] +impl IntoFFIValue for [u8; N] { + type Owned = (); - #[cfg(not(feature = "std"))] - impl FromFFIValue for [u8; $n] { - fn from_ffi_value(arg: u32) -> [u8; $n] { - let mut res = [0u8; $n]; - let data = unsafe { Vec::from_raw_parts(arg as *mut u8, $n, $n) }; + fn into_ffi_value(&self) -> WrappedFFIValue { + (self.as_ptr() as u32).into() + } +} - res.copy_from_slice(&data); +#[cfg(not(feature = "std"))] +impl FromFFIValue for [u8; N] { + fn from_ffi_value(arg: u32) -> [u8; N] { + let mut res = [0u8; N]; + let data = unsafe { Vec::from_raw_parts(arg as *mut u8, N, N) }; - res - } - } + res.copy_from_slice(&data); - #[cfg(feature = "std")] - impl FromFFIValue for [u8; $n] { - type SelfInstance = [u8; $n]; + res + } +} - fn from_ffi_value(context: &mut dyn FunctionContext, arg: u32) -> Result<[u8; $n]> { - let mut res = [0u8; $n]; - context.read_memory_into(Pointer::new(arg), &mut res)?; - Ok(res) - } - } +#[cfg(feature = "std")] +impl FromFFIValue for [u8; N] { + type SelfInstance = [u8; N]; - #[cfg(feature = "std")] - impl IntoFFIValue for [u8; $n] { - fn into_ffi_value(self, context: &mut dyn FunctionContext) -> Result { - let addr = context.allocate_memory($n)?; - context.write_memory(addr, &self)?; - Ok(addr.into()) - } - } + fn from_ffi_value(context: &mut dyn FunctionContext, arg: u32) -> Result<[u8; N]> { + let mut res = [0u8; N]; + context.read_memory_into(Pointer::new(arg), &mut res)?; + Ok(res) + } +} - #[cfg(feature = "std")] - impl IntoPreallocatedFFIValue for [u8; $n] { - type SelfInstance = [u8; $n]; - - fn into_preallocated_ffi_value( - self_instance: Self::SelfInstance, - context: &mut dyn FunctionContext, - allocated: u32, - ) -> Result<()> { - context.write_memory(Pointer::new(allocated), &self_instance) - } - } - )* +#[cfg(feature = "std")] +impl IntoFFIValue for [u8; N] { + fn into_ffi_value(self, context: &mut dyn FunctionContext) -> Result { + let addr = context.allocate_memory(N as u32)?; + context.write_memory(addr, &self)?; + Ok(addr.into()) } } -impl_traits_for_arrays! { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, +#[cfg(feature = "std")] +impl IntoPreallocatedFFIValue for [u8; N] { + type SelfInstance = [u8; N]; + + fn into_preallocated_ffi_value( + self_instance: Self::SelfInstance, + context: &mut dyn FunctionContext, + allocated: u32, + ) -> Result<()> { + context.write_memory(Pointer::new(allocated), &self_instance) + } } impl PassBy for sp_std::result::Result { From 129fee774a6d185d117a57fd1e81b3d0d05ad747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <123550+andresilva@users.noreply.github.com> Date: Mon, 30 Jan 2023 15:25:11 +0000 Subject: [PATCH 73/80] grandpa: cleanup stale entries in set id session mapping (#13237) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * grandpa: cleanup stale entries in set id session mapping * Update frame/grandpa/src/migrations.rs Co-authored-by: Bastian Köcher * grandpa: remove unused import * grandpa: migration off-by-one * Update frame/grandpa/src/lib.rs Co-authored-by: Anton * Update frame/grandpa/src/lib.rs Co-authored-by: Anton * grandpa: MaxSetIdSessionEntries as u64 * node-template: fix MaxSetIdSessionEntries type --------- Co-authored-by: Bastian Köcher Co-authored-by: Anton --- bin/node-template/runtime/src/lib.rs | 1 + bin/node/runtime/src/lib.rs | 5 +++ frame/grandpa/src/lib.rs | 30 +++++++++++++++--- frame/grandpa/src/migrations.rs | 46 ++++++++++++++++++++++++++++ frame/grandpa/src/mock.rs | 2 ++ frame/grandpa/src/tests.rs | 27 ++++++++++++++++ 6 files changed, 107 insertions(+), 4 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index baba5d9b05..4840459816 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -230,6 +230,7 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); type MaxAuthorities = ConstU32<32>; + type MaxSetIdSessionEntries = ConstU64<0>; } impl pallet_timestamp::Config for Runtime { diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 30165cdb6f..8e8ecc125d 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1310,6 +1310,10 @@ impl pallet_authority_discovery::Config for Runtime { type MaxAuthorities = MaxAuthorities; } +parameter_types! { + pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get(); +} + impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; @@ -1331,6 +1335,7 @@ impl pallet_grandpa::Config for Runtime { type WeightInfo = (); type MaxAuthorities = MaxAuthorities; + type MaxSetIdSessionEntries = MaxSetIdSessionEntries; } parameter_types! { diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index aa09b445c6..ea534947dd 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -121,6 +121,15 @@ pub mod pallet { /// Max Authorities in use #[pallet::constant] type MaxAuthorities: Get; + + /// The maximum number of entries to keep in the set id to session index mapping. + /// + /// Since the `SetIdSession` map is only used for validating equivocations this + /// value should relate to the bonding duration of whatever staking system is + /// being used (if any). If equivocation handling is not enabled then this value + /// can be zero. + #[pallet::constant] + type MaxSetIdSessionEntries: Get; } #[pallet::hooks] @@ -323,6 +332,12 @@ pub mod pallet { /// A mapping from grandpa set ID to the index of the *most recent* session for which its /// members were responsible. /// + /// This is only used for validating equivocation proofs. An equivocation proof must + /// contains a key-ownership proof for a given session, therefore we need a way to tie + /// together sessions and GRANDPA set ids, i.e. we need to validate that a validator + /// was the owner of a given key on a given session, and what the active set ID was + /// during that session. + /// /// TWOX-NOTE: `SetId` is not under user control. #[pallet::storage] #[pallet::getter(fn session_for_set)] @@ -643,10 +658,17 @@ where }; if res.is_ok() { - CurrentSetId::::mutate(|s| { + let current_set_id = CurrentSetId::::mutate(|s| { *s += 1; *s - }) + }); + + let max_set_id_session_entries = T::MaxSetIdSessionEntries::get().max(1); + if current_set_id >= max_set_id_session_entries { + SetIdSession::::remove(current_set_id - max_set_id_session_entries); + } + + current_set_id } else { // either the session module signalled that the validators have changed // or the set was stalled. but since we didn't successfully schedule @@ -659,8 +681,8 @@ where Self::current_set_id() }; - // if we didn't issue a change, we update the mapping to note that the current - // set corresponds to the latest equivalent session (i.e. now). + // update the mapping to note that the current set corresponds to the + // latest equivalent session (i.e. now). let session_index = >::current_index(); SetIdSession::::insert(current_set_id, &session_index); } diff --git a/frame/grandpa/src/migrations.rs b/frame/grandpa/src/migrations.rs index 7795afcd80..f4a28fff13 100644 --- a/frame/grandpa/src/migrations.rs +++ b/frame/grandpa/src/migrations.rs @@ -15,5 +15,51 @@ // See the License for the specific language governing permissions and // limitations under the License. +use frame_support::{ + traits::{Get, OnRuntimeUpgrade}, + weights::Weight, +}; + +use crate::{Config, CurrentSetId, SetIdSession, LOG_TARGET}; + /// Version 4. pub mod v4; + +/// This migration will clean up all stale set id -> session entries from the +/// `SetIdSession` storage map, only the latest `max_set_id_session_entries` +/// will be kept. +/// +/// This migration should be added with a runtime upgrade that introduces the +/// `MaxSetIdSessionEntries` constant to the pallet (although it could also be +/// done later on). +pub struct CleanupSetIdSessionMap(sp_std::marker::PhantomData); +impl OnRuntimeUpgrade for CleanupSetIdSessionMap { + fn on_runtime_upgrade() -> Weight { + // NOTE: since this migration will loop over all stale entries in the + // map we need to set some cutoff value, otherwise the migration might + // take too long to run. for scenarios where there are that many entries + // to cleanup a multiblock migration will be needed instead. + if CurrentSetId::::get() > 25_000 { + log::warn!( + target: LOG_TARGET, + "CleanupSetIdSessionMap migration was aborted since there are too many entries to cleanup." + ); + + return T::DbWeight::get().reads(1) + } + + cleanup_set_id_sesion_map::() + } +} + +fn cleanup_set_id_sesion_map() -> Weight { + let until_set_id = CurrentSetId::::get().saturating_sub(T::MaxSetIdSessionEntries::get()); + + for set_id in 0..=until_set_id { + SetIdSession::::remove(set_id); + } + + T::DbWeight::get() + .reads(1) + .saturating_add(T::DbWeight::get().writes(until_set_id + 1)) +} diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 54f34008ab..7d54966a49 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -219,6 +219,7 @@ impl pallet_offences::Config for Test { parameter_types! { pub const ReportLongevity: u64 = BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * Period::get(); + pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get(); } impl Config for Test { @@ -239,6 +240,7 @@ impl Config for Test { type WeightInfo = (); type MaxAuthorities = ConstU32<100>; + type MaxSetIdSessionEntries = MaxSetIdSessionEntries; } pub fn grandpa_log(log: ConsensusLog) -> DigestItem { diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index 626decd128..e090dcebb6 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -781,6 +781,33 @@ fn on_new_session_doesnt_start_new_set_if_schedule_change_failed() { }); } +#[test] +fn cleans_up_old_set_id_session_mappings() { + new_test_ext(vec![(1, 1), (2, 1), (3, 1)]).execute_with(|| { + let max_set_id_session_entries = MaxSetIdSessionEntries::get(); + + start_era(max_set_id_session_entries); + + // we should have a session id mapping for all the set ids from + // `max_set_id_session_entries` eras we have observed + for i in 1..=max_set_id_session_entries { + assert!(Grandpa::session_for_set(i as u64).is_some()); + } + + start_era(max_set_id_session_entries * 2); + + // we should keep tracking the new mappings for new eras + for i in max_set_id_session_entries + 1..=max_set_id_session_entries * 2 { + assert!(Grandpa::session_for_set(i as u64).is_some()); + } + + // but the old ones should have been pruned by now + for i in 1..=max_set_id_session_entries { + assert!(Grandpa::session_for_set(i as u64).is_none()); + } + }); +} + #[test] fn always_schedules_a_change_on_new_session_when_stalled() { new_test_ext(vec![(1, 1), (2, 1), (3, 1)]).execute_with(|| { From 8cfe326e4e33c5077fc67f197d6a13dd871881c7 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Wed, 1 Feb 2023 03:11:41 +0100 Subject: [PATCH 74/80] Benchmark's successful origin api update (#13146) * try successful origin unimplemented by default * error as a default impl for try_successful_origin * remove successful_origin func of EnsureOrigin trait * default impl -> unimplemented!() * update EnsureOriginWithArg * fix EnsureOriginWithArg * prefix unused arg with underscore * use try_successful_origin instead successful_origin, map err to Weightless * fix tests * remove default impl * unwrap for indirect origin dep * replace unwrap by expect with a message --------- Co-authored-by: parity-processbot <> --- frame/alliance/src/benchmarking.rs | 23 ++- frame/assets/src/benchmarking.rs | 14 +- frame/bounties/src/benchmarking.rs | 6 +- frame/democracy/src/benchmarking.rs | 42 +++-- frame/fast-unstake/src/benchmarking.rs | 5 +- frame/identity/src/benchmarking.rs | 23 ++- frame/lottery/src/benchmarking.rs | 14 +- frame/membership/src/lib.rs | 37 ++-- frame/nfts/src/benchmarking.rs | 11 +- frame/nis/src/benchmarking.rs | 5 +- frame/preimage/src/benchmarking.rs | 116 +++++++++---- frame/ranked-collective/src/benchmarking.rs | 37 ++-- frame/ranked-collective/src/lib.rs | 39 ----- frame/referenda/src/benchmarking.rs | 183 ++++++++++++++------ frame/scheduler/src/benchmarking.rs | 5 +- frame/support/src/traits/dispatch.rs | 38 +--- frame/system/src/tests.rs | 7 +- frame/tips/src/benchmarking.rs | 7 +- frame/treasury/src/benchmarking.rs | 11 +- frame/uniques/src/benchmarking.rs | 8 +- frame/whitelist/src/benchmarking.rs | 14 +- 21 files changed, 402 insertions(+), 243 deletions(-) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index f312e032bb..01b81ed66e 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -25,7 +25,7 @@ use sp_std::{ prelude::*, }; -use frame_benchmarking::v1::{account, benchmarks_instance_pallet}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; use frame_support::traits::{EnsureOrigin, Get, UnfilteredDispatchable}; use frame_system::{Pallet as System, RawOrigin as SystemOrigin}; @@ -581,7 +581,8 @@ benchmarks_instance_pallet! { let rule = rule(b"hello world"); let call = Call::::set_rule { rule: rule.clone() }; - let origin = T::AdminOrigin::successful_origin(); + let origin = + T::AdminOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(Alliance::::rule(), Some(rule.clone())); @@ -594,7 +595,8 @@ benchmarks_instance_pallet! { let announcement = announcement(b"hello world"); let call = Call::::announce { announcement: announcement.clone() }; - let origin = T::AnnouncementOrigin::successful_origin(); + let origin = + T::AnnouncementOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert!(Alliance::::announcements().contains(&announcement)); @@ -609,7 +611,8 @@ benchmarks_instance_pallet! { Announcements::::put(announcements); let call = Call::::remove_announcement { announcement: announcement.clone() }; - let origin = T::AnnouncementOrigin::successful_origin(); + let origin = + T::AnnouncementOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert!(Alliance::::announcements().is_empty()); @@ -665,7 +668,8 @@ benchmarks_instance_pallet! { let ally1_lookup = T::Lookup::unlookup(ally1.clone()); let call = Call::::elevate_ally { ally: ally1_lookup }; - let origin = T::MembershipManager::successful_origin(); + let origin = + T::MembershipManager::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert!(!Alliance::::is_ally(&ally1)); @@ -725,7 +729,8 @@ benchmarks_instance_pallet! { let fellow2_lookup = T::Lookup::unlookup(fellow2.clone()); let call = Call::::kick_member { who: fellow2_lookup }; - let origin = T::MembershipManager::successful_origin(); + let origin = + T::MembershipManager::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert!(!Alliance::::is_member(&fellow2)); @@ -754,7 +759,8 @@ benchmarks_instance_pallet! { unscrupulous_list.extend(websites.into_iter().map(UnscrupulousItem::Website)); let call = Call::::add_unscrupulous_items { items: unscrupulous_list.clone() }; - let origin = T::AnnouncementOrigin::successful_origin(); + let origin = + T::AnnouncementOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert_last_event::(Event::UnscrupulousItemAdded { items: unscrupulous_list }.into()); @@ -784,7 +790,8 @@ benchmarks_instance_pallet! { unscrupulous_list.extend(websites.into_iter().map(UnscrupulousItem::Website)); let call = Call::::remove_unscrupulous_items { items: unscrupulous_list.clone() }; - let origin = T::AnnouncementOrigin::successful_origin(); + let origin = + T::AnnouncementOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: { call.dispatch_bypass_filter(origin)? } verify { assert_last_event::(Event::UnscrupulousItemRemoved { items: unscrupulous_list }.into()); diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 9acf69f1e4..cf0ec353f6 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use frame_benchmarking::v1::{ - account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, + account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; use frame_support::{ dispatch::UnfilteredDispatchable, @@ -135,7 +135,8 @@ fn assert_event, I: 'static>(generic_event: >::Runti benchmarks_instance_pallet! { create { let asset_id = default_asset_id::(); - let origin = T::CreateOrigin::successful_origin(&asset_id.into()); + let origin = T::CreateOrigin::try_successful_origin(&asset_id.into()) + .map_err(|_| BenchmarkError::Weightless)?; let caller = T::CreateOrigin::ensure_origin(origin, &asset_id.into()).unwrap(); let caller_lookup = T::Lookup::unlookup(caller.clone()); T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); @@ -362,7 +363,8 @@ benchmarks_instance_pallet! { let (asset_id, _, _) = create_default_asset::(true); - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::force_set_metadata { id: asset_id, name: name.clone(), @@ -382,7 +384,8 @@ benchmarks_instance_pallet! { let origin = SystemOrigin::Signed(caller).into(); Assets::::set_metadata(origin, asset_id, dummy.clone(), dummy, 12)?; - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::force_clear_metadata { id: asset_id }; }: { call.dispatch_bypass_filter(origin)? } verify { @@ -392,7 +395,8 @@ benchmarks_instance_pallet! { force_asset_status { let (asset_id, caller, caller_lookup) = create_default_asset::(true); - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::force_asset_status { id: asset_id, owner: caller_lookup.clone(), diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index a43372978e..881f1c912e 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -173,7 +173,8 @@ benchmarks_instance_pallet! { let (caller, curator, fee, value, reason) = setup_bounty::(0, 0); Bounties::::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?; let bounty_id = BountyCount::::get() - 1; - let approve_origin = T::ApproveOrigin::successful_origin(); + let approve_origin = + T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: close_bounty(approve_origin, bounty_id) close_bounty_active { @@ -181,7 +182,8 @@ benchmarks_instance_pallet! { let (curator_lookup, bounty_id) = create_bounty::()?; Treasury::::on_initialize(T::BlockNumber::zero()); let bounty_id = BountyCount::::get() - 1; - let approve_origin = T::ApproveOrigin::successful_origin(); + let approve_origin = + T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: close_bounty(approve_origin, bounty_id) verify { assert_last_event::(Event::BountyCanceled { index: bounty_id }.into()) diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 66d9e2a007..f2d45b719f 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -19,7 +19,7 @@ use super::*; -use frame_benchmarking::v1::{account, benchmarks, whitelist_account}; +use frame_benchmarking::v1::{account, benchmarks, whitelist_account, BenchmarkError}; use frame_support::{ assert_noop, assert_ok, traits::{Currency, EnsureOrigin, Get, OnInitialize, UnfilteredDispatchable}, @@ -177,7 +177,8 @@ benchmarks! { } emergency_cancel { - let origin = T::CancellationOrigin::successful_origin(); + let origin = + T::CancellationOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let ref_index = add_referendum::(0).0; assert_ok!(Democracy::::referendum_status(ref_index)); }: _(origin, ref_index) @@ -200,10 +201,13 @@ benchmarks! { let (ref_index, hash) = add_referendum::(0); assert_ok!(Democracy::::referendum_status(ref_index)); // Place our proposal in the external queue, too. - assert_ok!( - Democracy::::external_propose(T::ExternalOrigin::successful_origin(), make_proposal::(0)) - ); - let origin = T::BlacklistOrigin::successful_origin(); + assert_ok!(Democracy::::external_propose( + T::ExternalOrigin::try_successful_origin() + .expect("ExternalOrigin has no successful origin required for the benchmark"), + make_proposal::(0) + )); + let origin = + T::BlacklistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(origin, hash, Some(ref_index)) verify { // Referendum has been canceled @@ -215,7 +219,8 @@ benchmarks! { // Worst case scenario, we external propose a previously blacklisted proposal external_propose { - let origin = T::ExternalOrigin::successful_origin(); + let origin = + T::ExternalOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let proposal = make_proposal::(0); // Add proposal to blacklist with block number 0 @@ -233,7 +238,8 @@ benchmarks! { } external_propose_majority { - let origin = T::ExternalMajorityOrigin::successful_origin(); + let origin = T::ExternalMajorityOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; let proposal = make_proposal::(0); }: _(origin, proposal) verify { @@ -242,7 +248,8 @@ benchmarks! { } external_propose_default { - let origin = T::ExternalDefaultOrigin::successful_origin(); + let origin = T::ExternalDefaultOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; let proposal = make_proposal::(0); }: _(origin, proposal) verify { @@ -251,13 +258,15 @@ benchmarks! { } fast_track { - let origin_propose = T::ExternalDefaultOrigin::successful_origin(); + let origin_propose = T::ExternalDefaultOrigin::try_successful_origin() + .expect("ExternalDefaultOrigin has no successful origin required for the benchmark"); let proposal = make_proposal::(0); let proposal_hash = proposal.hash(); Democracy::::external_propose_default(origin_propose, proposal)?; // NOTE: Instant origin may invoke a little bit more logic, but may not always succeed. - let origin_fast_track = T::FastTrackOrigin::successful_origin(); + let origin_fast_track = + T::FastTrackOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let voting_period = T::FastTrackVotingPeriod::get(); let delay = 0u32; }: _(origin_fast_track, proposal_hash, voting_period, delay.into()) @@ -269,7 +278,8 @@ benchmarks! { let proposal = make_proposal::(0); let proposal_hash = proposal.hash(); - let origin_propose = T::ExternalDefaultOrigin::successful_origin(); + let origin_propose = T::ExternalDefaultOrigin::try_successful_origin() + .expect("ExternalDefaultOrigin has no successful origin required for the benchmark"); Democracy::::external_propose_default(origin_propose, proposal)?; let mut vetoers: BoundedVec = Default::default(); @@ -279,7 +289,7 @@ benchmarks! { vetoers.sort(); Blacklist::::insert(proposal_hash, (T::BlockNumber::zero(), vetoers)); - let origin = T::VetoOrigin::successful_origin(); + let origin = T::VetoOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; ensure!(NextExternal::::get().is_some(), "no external proposal"); }: _(origin, proposal_hash) verify { @@ -293,7 +303,8 @@ benchmarks! { for i in 0 .. T::MaxProposals::get() { add_proposal::(i)?; } - let cancel_origin = T::CancelProposalOrigin::successful_origin(); + let cancel_origin = T::CancelProposalOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; }: _(cancel_origin, 0) cancel_referendum { @@ -313,7 +324,8 @@ benchmarks! { // Launch external LastTabledWasExternal::::put(false); - let origin = T::ExternalMajorityOrigin::successful_origin(); + let origin = T::ExternalMajorityOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; let proposal = make_proposal::(r); let call = Call::::external_propose_majority { proposal }; call.dispatch_bypass_filter(origin)?; diff --git a/frame/fast-unstake/src/benchmarking.rs b/frame/fast-unstake/src/benchmarking.rs index 77488b6447..e0e4186d78 100644 --- a/frame/fast-unstake/src/benchmarking.rs +++ b/frame/fast-unstake/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use crate::{types::*, Pallet as FastUnstake, *}; -use frame_benchmarking::v1::{benchmarks, whitelist_account}; +use frame_benchmarking::v1::{benchmarks, whitelist_account, BenchmarkError}; use frame_support::{ assert_ok, traits::{Currency, EnsureOrigin, Get, Hooks}, @@ -192,7 +192,8 @@ benchmarks! { } control { - let origin = ::ControlOrigin::successful_origin(); + let origin = ::ControlOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; } : _(origin, T::MaxErasToCheckPerBlock::get()) verify {} diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index 356bcb2e80..2d485af0f6 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use crate::Pallet as Identity; -use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_support::{ ensure, traits::{EnsureOrigin, Get}, @@ -42,7 +42,8 @@ fn add_registrars(r: u32) -> Result<(), &'static str> { let registrar: T::AccountId = account("registrar", i, SEED); let registrar_lookup = T::Lookup::unlookup(registrar.clone()); let _ = T::Currency::make_free_balance_be(®istrar, BalanceOf::::max_value()); - let registrar_origin = T::RegistrarOrigin::successful_origin(); + let registrar_origin = T::RegistrarOrigin::try_successful_origin() + .expect("RegistrarOrigin has no successful origin required for the benchmark"); Identity::::add_registrar(registrar_origin, registrar_lookup)?; Identity::::set_fee(RawOrigin::Signed(registrar.clone()).into(), i, 10u32.into())?; let fields = @@ -121,7 +122,8 @@ benchmarks! { add_registrar { let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::(r)?; ensure!(Registrars::::get().len() as u32 == r, "Registrars not set up correctly."); - let origin = T::RegistrarOrigin::successful_origin(); + let origin = + T::RegistrarOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let account = T::Lookup::unlookup(account("registrar", r + 1, SEED)); }: _(origin, account) verify { @@ -280,7 +282,8 @@ benchmarks! { let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::(r)?; - let registrar_origin = T::RegistrarOrigin::successful_origin(); + let registrar_origin = T::RegistrarOrigin::try_successful_origin() + .expect("RegistrarOrigin has no successful origin required for the benchmark"); Identity::::add_registrar(registrar_origin, caller_lookup)?; let registrars = Registrars::::get(); ensure!(registrars[r as usize].as_ref().unwrap().fee == 0u32.into(), "Fee already set."); @@ -297,7 +300,8 @@ benchmarks! { let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::(r)?; - let registrar_origin = T::RegistrarOrigin::successful_origin(); + let registrar_origin = T::RegistrarOrigin::try_successful_origin() + .expect("RegistrarOrigin has no successful origin required for the benchmark"); Identity::::add_registrar(registrar_origin, caller_lookup)?; let registrars = Registrars::::get(); ensure!(registrars[r as usize].as_ref().unwrap().account == caller, "id not set."); @@ -315,7 +319,8 @@ benchmarks! { let r in 1 .. T::MaxRegistrars::get() - 1 => add_registrars::(r)?; - let registrar_origin = T::RegistrarOrigin::successful_origin(); + let registrar_origin = T::RegistrarOrigin::try_successful_origin() + .expect("RegistrarOrigin has no successful origin required for the benchmark"); Identity::::add_registrar(registrar_origin, caller_lookup)?; let fields = IdentityFields( IdentityField::Display | IdentityField::Legal | IdentityField::Web | IdentityField::Riot @@ -347,7 +352,8 @@ benchmarks! { let info_hash = T::Hashing::hash_of(&info); Identity::::set_identity(user_origin.clone(), Box::new(info))?; - let registrar_origin = T::RegistrarOrigin::successful_origin(); + let registrar_origin = T::RegistrarOrigin::try_successful_origin() + .expect("RegistrarOrigin has no successful origin required for the benchmark"); Identity::::add_registrar(registrar_origin, caller_lookup)?; Identity::::request_judgement(user_origin, r, 10u32.into())?; }: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable, info_hash) @@ -385,7 +391,8 @@ benchmarks! { )?; } ensure!(IdentityOf::::contains_key(&target), "Identity not set"); - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(origin, target_lookup) verify { ensure!(!IdentityOf::::contains_key(&target), "Identity not removed"); diff --git a/frame/lottery/src/benchmarking.rs b/frame/lottery/src/benchmarking.rs index 658dd25a98..0db7fabb36 100644 --- a/frame/lottery/src/benchmarking.rs +++ b/frame/lottery/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; -use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_support::{ storage::bounded_vec::BoundedVec, traits::{EnsureOrigin, OnInitialize}, @@ -43,7 +43,8 @@ fn setup_lottery(repeat: bool) -> Result<(), &'static str> { ]; // Last call will be the match for worst case scenario. calls.push(frame_system::Call::::remark { remark: vec![] }.into()); - let origin = T::ManagerOrigin::successful_origin(); + let origin = T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"); Lottery::::set_calls(origin.clone(), calls)?; Lottery::::start_lottery(origin, price, length, delay, repeat)?; Ok(()) @@ -76,7 +77,8 @@ benchmarks! { set_calls { let n in 0 .. T::MaxCalls::get() as u32; let calls = vec![frame_system::Call::::remark { remark: vec![] }.into(); n as usize]; - let origin = T::ManagerOrigin::successful_origin(); + let origin = + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; assert!(CallIndices::::get().is_empty()); }: _(origin, calls) verify { @@ -89,7 +91,8 @@ benchmarks! { let price = BalanceOf::::max_value(); let end = 10u32.into(); let payout = 5u32.into(); - let origin = T::ManagerOrigin::successful_origin(); + let origin = + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(origin, price, end, payout, true) verify { assert!(crate::Lottery::::get().is_some()); @@ -98,7 +101,8 @@ benchmarks! { stop_repeat { setup_lottery::(true)?; assert_eq!(crate::Lottery::::get().unwrap().repeat, true); - let origin = T::ManagerOrigin::successful_origin(); + let origin = + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(origin) verify { assert_eq!(crate::Lottery::::get().unwrap().repeat, false); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 6d973a15fe..8b39a08ce6 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -362,15 +362,17 @@ impl, I: 'static> SortedMembers for Pallet { #[cfg(feature = "runtime-benchmarks")] mod benchmark { use super::{Pallet as Membership, *}; - use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist}; + use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist, BenchmarkError}; use frame_support::{assert_ok, traits::EnsureOrigin}; use frame_system::RawOrigin; const SEED: u32 = 0; fn set_members, I: 'static>(members: Vec, prime: Option) { - let reset_origin = T::ResetOrigin::successful_origin(); - let prime_origin = T::PrimeOrigin::successful_origin(); + let reset_origin = T::ResetOrigin::try_successful_origin() + .expect("ResetOrigin has no successful origin required for the benchmark"); + let prime_origin = T::PrimeOrigin::try_successful_origin() + .expect("PrimeOrigin has no successful origin required for the benchmark"); assert_ok!(>::reset_members(reset_origin, members.clone())); if let Some(prime) = prime.map(|i| members[i].clone()) { @@ -390,9 +392,11 @@ mod benchmark { let new_member = account::("add", m, SEED); let new_member_lookup = T::Lookup::unlookup(new_member.clone()); }: { - assert_ok!(>::add_member(T::AddOrigin::successful_origin(), new_member_lookup)); - } - verify { + assert_ok!(>::add_member( + T::AddOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + new_member_lookup, + )); + } verify { assert!(>::get().contains(&new_member)); #[cfg(test)] crate::tests::clean(); } @@ -408,7 +412,10 @@ mod benchmark { let to_remove = members.first().cloned().unwrap(); let to_remove_lookup = T::Lookup::unlookup(to_remove.clone()); }: { - assert_ok!(>::remove_member(T::RemoveOrigin::successful_origin(), to_remove_lookup)); + assert_ok!(>::remove_member( + T::RemoveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + to_remove_lookup, + )); } verify { assert!(!>::get().contains(&to_remove)); // prime is rejigged @@ -428,7 +435,7 @@ mod benchmark { let remove_lookup = T::Lookup::unlookup(remove.clone()); }: { assert_ok!(>::swap_member( - T::SwapOrigin::successful_origin(), + T::SwapOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, remove_lookup, add_lookup, )); @@ -448,7 +455,10 @@ mod benchmark { set_members::(members.clone(), Some(members.len() - 1)); let mut new_members = (m..2*m).map(|i| account("member", i, SEED)).collect::>(); }: { - assert_ok!(>::reset_members(T::ResetOrigin::successful_origin(), new_members.clone())); + assert_ok!(>::reset_members( + T::ResetOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + new_members.clone(), + )); } verify { new_members.sort(); assert_eq!(>::get(), new_members); @@ -485,7 +495,10 @@ mod benchmark { let prime_lookup = T::Lookup::unlookup(prime.clone()); set_members::(members, None); }: { - assert_ok!(>::set_prime(T::PrimeOrigin::successful_origin(), prime_lookup)); + assert_ok!(>::set_prime( + T::PrimeOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + prime_lookup, + )); } verify { assert!(>::get().is_some()); assert!(::get_prime().is_some()); @@ -498,7 +511,9 @@ mod benchmark { let prime = members.last().cloned().unwrap(); set_members::(members, None); }: { - assert_ok!(>::clear_prime(T::PrimeOrigin::successful_origin())); + assert_ok!(>::clear_prime( + T::PrimeOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + )); } verify { assert!(>::get().is_none()); assert!(::get_prime().is_none()); diff --git a/frame/nfts/src/benchmarking.rs b/frame/nfts/src/benchmarking.rs index 17ff28b822..a4007f6b2c 100644 --- a/frame/nfts/src/benchmarking.rs +++ b/frame/nfts/src/benchmarking.rs @@ -22,7 +22,7 @@ use super::*; use enumflags2::{BitFlag, BitFlags}; use frame_benchmarking::v1::{ - account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, + account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; use frame_support::{ assert_ok, @@ -151,7 +151,8 @@ fn default_item_config() -> ItemConfig { benchmarks_instance_pallet! { create { let collection = T::Helper::collection(0); - let origin = T::CreateOrigin::successful_origin(&collection); + let origin = T::CreateOrigin::try_successful_origin(&collection) + .map_err(|_| BenchmarkError::Weightless)?; let caller = T::CreateOrigin::ensure_origin(origin.clone(), &collection).unwrap(); whitelist_account!(caller); let admin = T::Lookup::unlookup(caller.clone()); @@ -311,7 +312,8 @@ benchmarks_instance_pallet! { force_collection_owner { let (collection, _, _) = create_collection::(); - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let target: T::AccountId = account("target", 0, SEED); let target_lookup = T::Lookup::unlookup(target.clone()); T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance()); @@ -326,7 +328,8 @@ benchmarks_instance_pallet! { force_collection_config { let (collection, caller, _) = create_collection::(); - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::force_collection_config { collection, config: make_collection_config::(CollectionSetting::DepositRequired.into()), diff --git a/frame/nis/src/benchmarking.rs b/frame/nis/src/benchmarking.rs index b01d414c4b..10d3a238a3 100644 --- a/frame/nis/src/benchmarking.rs +++ b/frame/nis/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller}; +use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller, BenchmarkError}; use frame_support::traits::{nonfungible::Inspect, Currency, EnsureOrigin, Get}; use frame_system::RawOrigin; use sp_arithmetic::Perquintill; @@ -100,7 +100,8 @@ benchmarks! { } fund_deficit { - let origin = T::FundOrigin::successful_origin(); + let origin = + T::FundOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let caller: T::AccountId = whitelisted_caller(); let bid = T::MinBid::get().max(One::one()); T::Currency::make_free_balance_be(&caller, bid); diff --git a/frame/preimage/src/benchmarking.rs b/frame/preimage/src/benchmarking.rs index f9526b67d4..56361b88c2 100644 --- a/frame/preimage/src/benchmarking.rs +++ b/frame/preimage/src/benchmarking.rs @@ -18,7 +18,7 @@ //! Preimage pallet benchmarking. use super::*; -use frame_benchmarking::v1::{account, benchmarks, whitelist_account}; +use frame_benchmarking::v1::{account, benchmarks, whitelist_account, BenchmarkError}; use frame_support::assert_ok; use frame_system::RawOrigin; use sp_runtime::traits::Bounded; @@ -62,7 +62,11 @@ benchmarks! { let caller = funded_account::("caller", 0); whitelist_account!(caller); let (preimage, hash) = sized_preimage_and_hash::(s); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); }: note_preimage(RawOrigin::Signed(caller), preimage) verify { assert!(Preimage::::have_preimage(&hash)); @@ -71,9 +75,15 @@ benchmarks! { note_no_deposit_preimage { let s in 0 .. MAX_SIZE; let (preimage, hash) = sized_preimage_and_hash::(s); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); - }: note_preimage(T::ManagerOrigin::successful_origin(), preimage) - verify { + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); + }: note_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + preimage + ) verify { assert!(Preimage::::have_preimage(&hash)); } @@ -90,9 +100,15 @@ benchmarks! { // Cheap unnote - will not unreserve since there's no deposit held. unnote_no_deposit_preimage { let (preimage, hash) = preimage_and_hash::(); - assert_ok!(Preimage::::note_preimage(T::ManagerOrigin::successful_origin(), preimage)); - }: unnote_preimage(T::ManagerOrigin::successful_origin(), hash) - verify { + assert_ok!(Preimage::::note_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + preimage, + )); + }: unnote_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { assert!(!Preimage::::have_preimage(&hash)); } @@ -102,8 +118,10 @@ benchmarks! { let noter = funded_account::("noter", 0); whitelist_account!(noter); assert_ok!(Preimage::::note_preimage(RawOrigin::Signed(noter.clone()).into(), preimage)); - }: _(T::ManagerOrigin::successful_origin(), hash) - verify { + }: _( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { let deposit = T::BaseDeposit::get() + T::ByteDeposit::get() * MAX_SIZE.into(); let s = RequestStatus::Requested { deposit: Some((noter, deposit)), count: 1, len: Some(MAX_SIZE) }; assert_eq!(StatusFor::::get(&hash), Some(s)); @@ -111,26 +129,40 @@ benchmarks! { // Cheap request - would unreserve the deposit but none was held. request_no_deposit_preimage { let (preimage, hash) = preimage_and_hash::(); - assert_ok!(Preimage::::note_preimage(T::ManagerOrigin::successful_origin(), preimage)); - }: request_preimage(T::ManagerOrigin::successful_origin(), hash) - verify { + assert_ok!(Preimage::::note_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + preimage, + )); + }: request_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { let s = RequestStatus::Requested { deposit: None, count: 2, len: Some(MAX_SIZE) }; assert_eq!(StatusFor::::get(&hash), Some(s)); } // Cheap request - the preimage is not yet noted, so deposit to unreserve. request_unnoted_preimage { let (_, hash) = preimage_and_hash::(); - }: request_preimage(T::ManagerOrigin::successful_origin(), hash) - verify { + }: request_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { let s = RequestStatus::Requested { deposit: None, count: 1, len: None }; assert_eq!(StatusFor::::get(&hash), Some(s)); } // Cheap request - the preimage is already requested, so just a counter bump. request_requested_preimage { let (_, hash) = preimage_and_hash::(); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); - }: request_preimage(T::ManagerOrigin::successful_origin(), hash) - verify { + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); + }: request_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { let s = RequestStatus::Requested { deposit: None, count: 2, len: None }; assert_eq!(StatusFor::::get(&hash), Some(s)); } @@ -138,27 +170,53 @@ benchmarks! { // Expensive unrequest - last reference and it's noted, so will destroy the preimage. unrequest_preimage { let (preimage, hash) = preimage_and_hash::(); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); - assert_ok!(Preimage::::note_preimage(T::ManagerOrigin::successful_origin(), preimage)); - }: _(T::ManagerOrigin::successful_origin(), hash) - verify { + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); + assert_ok!(Preimage::::note_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + preimage, + )); + }: _( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { assert_eq!(StatusFor::::get(&hash), None); } // Cheap unrequest - last reference, but it's not noted. unrequest_unnoted_preimage { let (_, hash) = preimage_and_hash::(); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); - }: unrequest_preimage(T::ManagerOrigin::successful_origin(), hash) - verify { + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); + }: unrequest_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { assert_eq!(StatusFor::::get(&hash), None); } // Cheap unrequest - not the last reference. unrequest_multi_referenced_preimage { let (_, hash) = preimage_and_hash::(); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); - assert_ok!(Preimage::::request_preimage(T::ManagerOrigin::successful_origin(), hash)); - }: unrequest_preimage(T::ManagerOrigin::successful_origin(), hash) - verify { + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); + assert_ok!(Preimage::::request_preimage( + T::ManagerOrigin::try_successful_origin() + .expect("ManagerOrigin has no successful origin required for the benchmark"), + hash, + )); + }: unrequest_preimage( + T::ManagerOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + hash + ) verify { let s = RequestStatus::Requested { deposit: None, count: 1, len: None }; assert_eq!(StatusFor::::get(&hash), Some(s)); } diff --git a/frame/ranked-collective/src/benchmarking.rs b/frame/ranked-collective/src/benchmarking.rs index 48df7f1f1e..ad81325bec 100644 --- a/frame/ranked-collective/src/benchmarking.rs +++ b/frame/ranked-collective/src/benchmarking.rs @@ -21,7 +21,9 @@ use super::*; #[allow(unused_imports)] use crate::Pallet as RankedCollective; -use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::v1::{ + account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, +}; use frame_support::{assert_ok, dispatch::UnfilteredDispatchable}; use frame_system::RawOrigin as SystemOrigin; @@ -35,13 +37,15 @@ fn make_member, I: 'static>(rank: Rank) -> T::AccountId { let who = account::("member", MemberCount::::get(0), SEED); let who_lookup = T::Lookup::unlookup(who.clone()); assert_ok!(Pallet::::add_member( - T::PromoteOrigin::successful_origin(), - who_lookup.clone() + T::PromoteOrigin::try_successful_origin() + .expect("PromoteOrigin has no successful origin required for the benchmark"), + who_lookup.clone(), )); for _ in 0..rank { assert_ok!(Pallet::::promote_member( - T::PromoteOrigin::successful_origin(), - who_lookup.clone() + T::PromoteOrigin::try_successful_origin() + .expect("PromoteOrigin has no successful origin required for the benchmark"), + who_lookup.clone(), )); } who @@ -51,7 +55,8 @@ benchmarks_instance_pallet! { add_member { let who = account::("member", 0, SEED); let who_lookup = T::Lookup::unlookup(who.clone()); - let origin = T::PromoteOrigin::successful_origin(); + let origin = + T::PromoteOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::add_member { who: who_lookup }; }: { call.dispatch_bypass_filter(origin)? } verify { @@ -67,7 +72,8 @@ benchmarks_instance_pallet! { let who_lookup = T::Lookup::unlookup(who.clone()); let last = make_member::(rank); let last_index = (0..=rank).map(|r| IdToIndex::::get(r, &last).unwrap()).collect::>(); - let origin = T::DemoteOrigin::successful_origin(); + let origin = + T::DemoteOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::remove_member { who: who_lookup, min_rank: rank }; }: { call.dispatch_bypass_filter(origin)? } verify { @@ -83,7 +89,8 @@ benchmarks_instance_pallet! { let rank = r as u16; let who = make_member::(rank); let who_lookup = T::Lookup::unlookup(who.clone()); - let origin = T::PromoteOrigin::successful_origin(); + let origin = + T::PromoteOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::promote_member { who: who_lookup }; }: { call.dispatch_bypass_filter(origin)? } verify { @@ -99,7 +106,8 @@ benchmarks_instance_pallet! { let who_lookup = T::Lookup::unlookup(who.clone()); let last = make_member::(rank); let last_index = IdToIndex::::get(rank, &last).unwrap(); - let origin = T::DemoteOrigin::successful_origin(); + let origin = + T::DemoteOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::demote_member { who: who_lookup }; }: { call.dispatch_bypass_filter(origin)? } verify { @@ -115,14 +123,19 @@ benchmarks_instance_pallet! { vote { let caller: T::AccountId = whitelisted_caller(); let caller_lookup = T::Lookup::unlookup(caller.clone()); - assert_ok!(Pallet::::add_member(T::PromoteOrigin::successful_origin(), caller_lookup.clone())); + assert_ok!(Pallet::::add_member( + T::PromoteOrigin::try_successful_origin() + .expect("PromoteOrigin has no successful origin required for the benchmark"), + caller_lookup.clone(), + )); // Create a poll let class = T::Polls::classes().into_iter().next().unwrap(); let rank = T::MinRankOfClass::convert(class.clone()); for _ in 0..rank { assert_ok!(Pallet::::promote_member( - T::PromoteOrigin::successful_origin(), - caller_lookup.clone() + T::PromoteOrigin::try_successful_origin() + .expect("PromoteOrigin has no successful origin required for the benchmark"), + caller_lookup.clone(), )); } diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index b057a57508..84be1243c8 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -259,19 +259,6 @@ impl, I: 'static, const MIN_RANK: u16> EnsureOrigin::get(MIN_RANK, 0).ok_or(())?; Ok(frame_system::RawOrigin::Signed(who).into()) } - - #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> T::RuntimeOrigin { - match Self::try_successful_origin() { - Ok(o) => o, - Err(()) => { - let who: T::AccountId = frame_benchmarking::whitelisted_caller(); - crate::Pallet::::do_add_member_to_rank(who.clone(), MIN_RANK) - .expect("failed to add ranked member"); - frame_system::RawOrigin::Signed(who).into() - }, - } - } } /// Guard to ensure that the given origin is a member of the collective. The account ID of the @@ -295,19 +282,6 @@ impl, I: 'static, const MIN_RANK: u16> EnsureOrigin::get(MIN_RANK, 0).ok_or(())?; Ok(frame_system::RawOrigin::Signed(who).into()) } - - #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> T::RuntimeOrigin { - match Self::try_successful_origin() { - Ok(o) => o, - Err(()) => { - let who: T::AccountId = frame_benchmarking::whitelisted_caller(); - crate::Pallet::::do_add_member_to_rank(who.clone(), MIN_RANK) - .expect("failed to add ranked member"); - frame_system::RawOrigin::Signed(who).into() - }, - } - } } /// Guard to ensure that the given origin is a member of the collective. The pair of both the @@ -331,19 +305,6 @@ impl, I: 'static, const MIN_RANK: u16> EnsureOrigin::get(MIN_RANK, 0).ok_or(())?; Ok(frame_system::RawOrigin::Signed(who).into()) } - - #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> T::RuntimeOrigin { - match Self::try_successful_origin() { - Ok(o) => o, - Err(()) => { - let who: T::AccountId = frame_benchmarking::whitelisted_caller(); - crate::Pallet::::do_add_member_to_rank(who.clone(), MIN_RANK) - .expect("failed to add ranked member"); - frame_system::RawOrigin::Signed(who).into() - }, - } - } } #[frame_support::pallet] diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index db5299e0d5..62b37857f2 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -20,7 +20,9 @@ use super::*; use crate::Pallet as Referenda; use assert_matches::assert_matches; -use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelist_account}; +use frame_benchmarking::v1::{ + account, benchmarks_instance_pallet, whitelist_account, BenchmarkError, +}; use frame_support::{ assert_ok, dispatch::UnfilteredDispatchable, @@ -48,8 +50,7 @@ fn dummy_call, I: 'static>() -> Bounded<>::RuntimeCa T::Preimages::bound(call).unwrap() } -fn create_referendum, I: 'static>() -> (T::RuntimeOrigin, ReferendumIndex) { - let origin: T::RuntimeOrigin = T::SubmitOrigin::successful_origin(); +fn create_referendum, I: 'static>(origin: T::RuntimeOrigin) -> ReferendumIndex { if let Ok(caller) = frame_system::ensure_signed(origin.clone()) { T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); whitelist_account!(caller); @@ -61,7 +62,7 @@ fn create_referendum, I: 'static>() -> (T::RuntimeOrigin, Referendu let call = crate::Call::::submit { proposal_origin, proposal, enactment_moment }; assert_ok!(call.dispatch_bypass_filter(origin.clone())); let index = ReferendumCount::::get() - 1; - (origin, index) + index } fn place_deposit, I: 'static>(index: ReferendumIndex) { @@ -75,6 +76,7 @@ fn nudge, I: 'static>(index: ReferendumIndex) { } fn fill_queue, I: 'static>( + origin: T::RuntimeOrigin, index: ReferendumIndex, spaces: u32, pass_after: u32, @@ -82,7 +84,7 @@ fn fill_queue, I: 'static>( // First, create enough other referendums to fill the track. let mut others = vec![]; for _ in 0..info::(index).max_deciding { - let (_origin, index) = create_referendum::(); + let index = create_referendum::(origin.clone()); place_deposit::(index); others.push(index); } @@ -90,7 +92,7 @@ fn fill_queue, I: 'static>( // We will also need enough referenda which are queued and passing, we want `MaxQueued - 1` // in order to force the maximum amount of work to insert ours into the queue. for _ in spaces..T::MaxQueued::get() { - let (_origin, index) = create_referendum::(); + let index = create_referendum::(origin.clone()); place_deposit::(index); make_passing_after::(index, Perbill::from_percent(pass_after)); others.push(index); @@ -194,7 +196,8 @@ fn is_not_confirming, I: 'static>(index: ReferendumIndex) -> bool { benchmarks_instance_pallet! { submit { - let origin: T::RuntimeOrigin = T::SubmitOrigin::successful_origin(); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; if let Ok(caller) = frame_system::ensure_signed(origin.clone()) { T::Currency::make_free_balance_be(&caller, BalanceOf::::max_value()); whitelist_account!(caller); @@ -210,15 +213,19 @@ benchmarks_instance_pallet! { } place_decision_deposit_preparing { - let (origin, index) = create_referendum::(); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); }: place_decision_deposit(origin, index) verify { assert!(Referenda::::ensure_ongoing(index).unwrap().decision_deposit.is_some()); } place_decision_deposit_queued { - let (origin, index) = create_referendum::(); - fill_queue::(index, 1, 90); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); + fill_queue::(origin.clone(), index, 1, 90); }: place_decision_deposit(origin, index) verify { let track = Referenda::::ensure_ongoing(index).unwrap().track; @@ -227,8 +234,10 @@ benchmarks_instance_pallet! { } place_decision_deposit_not_queued { - let (origin, index) = create_referendum::(); - fill_queue::(index, 0, 90); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); + fill_queue::(origin.clone(), index, 0, 90); let track = Referenda::::ensure_ongoing(index).unwrap().track; assert_eq!(TrackQueue::::get(&track).len() as u32, T::MaxQueued::get()); assert!(TrackQueue::::get(&track).into_iter().all(|(i, _)| i != index)); @@ -239,7 +248,9 @@ benchmarks_instance_pallet! { } place_decision_deposit_passing { - let (origin, index) = create_referendum::(); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); skip_prepare_period::(index); make_passing::(index); }: place_decision_deposit(origin, index) @@ -248,7 +259,9 @@ benchmarks_instance_pallet! { } place_decision_deposit_failing { - let (origin, index) = create_referendum::(); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); skip_prepare_period::(index); }: place_decision_deposit(origin, index) verify { @@ -256,19 +269,31 @@ benchmarks_instance_pallet! { } refund_decision_deposit { - let (origin, index) = create_referendum::(); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); place_deposit::(index); - assert_ok!(Referenda::::cancel(T::CancelOrigin::successful_origin(), index)); + assert_ok!(Referenda::::cancel( + T::CancelOrigin::try_successful_origin() + .expect("CancelOrigin has no successful origin required for the benchmark"), + index, + )); }: _(origin, index) verify { assert_matches!(ReferendumInfoFor::::get(index), Some(ReferendumInfo::Cancelled(_, _, None))); } refund_submission_deposit { - let (origin, index) = create_referendum::(); + let origin = + T::SubmitOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; + let index = create_referendum::(origin.clone()); let caller = frame_system::ensure_signed(origin.clone()).unwrap(); let balance = T::Currency::free_balance(&caller); - assert_ok!(Referenda::::cancel(T::CancelOrigin::successful_origin(), index)); + assert_ok!(Referenda::::cancel( + T::CancelOrigin::try_successful_origin() + .expect("CancelOrigin has no successful origin required for the benchmark"), + index, + )); assert_matches!(ReferendumInfoFor::::get(index), Some(ReferendumInfo::Cancelled(_, Some(_), _))); }: _(origin, index) verify { @@ -279,28 +304,42 @@ benchmarks_instance_pallet! { } cancel { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); - }: _(T::CancelOrigin::successful_origin(), index) - verify { + }: _( + T::CancelOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + index + ) verify { assert_matches!(ReferendumInfoFor::::get(index), Some(ReferendumInfo::Cancelled(..))); } kill { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); - }: _(T::KillOrigin::successful_origin(), index) - verify { + }: _( + T::KillOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?, + index + ) verify { assert_matches!(ReferendumInfoFor::::get(index), Some(ReferendumInfo::Killed(..))); } one_fewer_deciding_queue_empty { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); nudge::(index); let track = Referenda::::ensure_ongoing(index).unwrap().track; - assert_ok!(Referenda::::cancel(T::CancelOrigin::successful_origin(), index)); + assert_ok!(Referenda::::cancel( + T::CancelOrigin::try_successful_origin() + .expect("CancelOrigin has no successful origin required for the benchmark"), + index, + )); assert_eq!(DecidingCount::::get(&track), 1); }: one_fewer_deciding(RawOrigin::Root, track) verify { @@ -308,11 +347,17 @@ benchmarks_instance_pallet! { } one_fewer_deciding_failing { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin.clone()); // No spaces free in the queue. - let queued = fill_queue::(index, 0, 90); + let queued = fill_queue::(origin, index, 0, 90); let track = Referenda::::ensure_ongoing(index).unwrap().track; - assert_ok!(Referenda::::cancel(T::CancelOrigin::successful_origin(), queued[0])); + assert_ok!(Referenda::::cancel( + T::CancelOrigin::try_successful_origin() + .expect("CancelOrigin has no successful origin required for the benchmark"), + queued[0], + )); assert_eq!(TrackQueue::::get(&track).len() as u32, T::MaxQueued::get()); let deciding_count = DecidingCount::::get(&track); }: one_fewer_deciding(RawOrigin::Root, track) @@ -327,11 +372,17 @@ benchmarks_instance_pallet! { } one_fewer_deciding_passing { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin.clone()); // No spaces free in the queue. - let queued = fill_queue::(index, 0, 0); + let queued = fill_queue::(origin, index, 0, 0); let track = Referenda::::ensure_ongoing(index).unwrap().track; - assert_ok!(Referenda::::cancel(T::CancelOrigin::successful_origin(), queued[0])); + assert_ok!(Referenda::::cancel( + T::CancelOrigin::try_successful_origin() + .expect("CancelOrigin has no successful origin required for the benchmark"), + queued[0], + )); assert_eq!(TrackQueue::::get(&track).len() as u32, T::MaxQueued::get()); let deciding_count = DecidingCount::::get(&track); }: one_fewer_deciding(RawOrigin::Root, track) @@ -346,10 +397,12 @@ benchmarks_instance_pallet! { } nudge_referendum_requeued_insertion { + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); // First create our referendum and place the deposit. It will be failing. - let (_origin, index) = create_referendum::(); + let index = create_referendum::(origin.clone()); place_deposit::(index); - fill_queue::(index, 0, 90); + fill_queue::(origin, index, 0, 90); // Now nudge ours, with the track now full and the queue full of referenda with votes, // ours will not be in the queue. @@ -367,10 +420,12 @@ benchmarks_instance_pallet! { } nudge_referendum_requeued_slide { + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); // First create our referendum and place the deposit. It will be failing. - let (_origin, index) = create_referendum::(); + let index = create_referendum::(origin.clone()); place_deposit::(index); - fill_queue::(index, 1, 90); + fill_queue::(origin, index, 1, 90); // Now nudge ours, with the track now full, ours will be queued, but with no votes, it // will have the worst position. @@ -393,10 +448,12 @@ benchmarks_instance_pallet! { // free and this failing. It would result in `QUEUE_SIZE - 1` items being shifted for the // insertion at the beginning. + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); // First create our referendum and place the deposit. It will be failing. - let (_origin, index) = create_referendum::(); + let index = create_referendum::(origin.clone()); place_deposit::(index); - fill_queue::(index, 1, 0); + fill_queue::(origin, index, 1, 0); let track = Referenda::::ensure_ongoing(index).unwrap().track; assert_eq!(TrackQueue::::get(&track).len() as u32, T::MaxQueued::get() - 1); @@ -410,10 +467,12 @@ benchmarks_instance_pallet! { } nudge_referendum_not_queued { + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); // First create our referendum and place the deposit. It will be failing. - let (_origin, index) = create_referendum::(); + let index = create_referendum::(origin.clone()); place_deposit::(index); - fill_queue::(index, 0, 0); + fill_queue::(origin, index, 0, 0); let track = Referenda::::ensure_ongoing(index).unwrap().track; assert_eq!(TrackQueue::::get(&track).len() as u32, T::MaxQueued::get()); @@ -427,7 +486,9 @@ benchmarks_instance_pallet! { } nudge_referendum_no_deposit { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); skip_prepare_period::(index); }: nudge_referendum(RawOrigin::Root, index) verify { @@ -436,7 +497,9 @@ benchmarks_instance_pallet! { } nudge_referendum_preparing { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); }: nudge_referendum(RawOrigin::Root, index) verify { @@ -445,7 +508,9 @@ benchmarks_instance_pallet! { } nudge_referendum_timed_out { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); skip_timeout_period::(index); }: nudge_referendum(RawOrigin::Root, index) verify { @@ -454,7 +519,9 @@ benchmarks_instance_pallet! { } nudge_referendum_begin_deciding_failing { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); }: nudge_referendum(RawOrigin::Root, index) @@ -463,7 +530,9 @@ benchmarks_instance_pallet! { } nudge_referendum_begin_deciding_passing { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); make_passing::(index); skip_prepare_period::(index); @@ -473,7 +542,9 @@ benchmarks_instance_pallet! { } nudge_referendum_begin_confirming { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); nudge::(index); @@ -485,7 +556,9 @@ benchmarks_instance_pallet! { } nudge_referendum_end_confirming { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); make_passing::(index); @@ -498,7 +571,9 @@ benchmarks_instance_pallet! { } nudge_referendum_continue_not_confirming { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); nudge::(index); @@ -512,7 +587,9 @@ benchmarks_instance_pallet! { } nudge_referendum_continue_confirming { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); make_passing::(index); skip_prepare_period::(index); @@ -525,7 +602,9 @@ benchmarks_instance_pallet! { } nudge_referendum_approved { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); make_passing::(index); @@ -538,7 +617,9 @@ benchmarks_instance_pallet! { } nudge_referendum_rejected { - let (_origin, index) = create_referendum::(); + let origin = T::SubmitOrigin::try_successful_origin() + .expect("SubmitOrigin has no successful origin required for the benchmark"); + let index = create_referendum::(origin); place_deposit::(index); skip_prepare_period::(index); make_failing::(index); diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index 9ec82f5c84..94a833bd98 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -18,7 +18,7 @@ //! Scheduler pallet benchmarking. use super::*; -use frame_benchmarking::v1::{account, benchmarks}; +use frame_benchmarking::v1::{account, benchmarks, BenchmarkError}; use frame_support::{ ensure, traits::{schedule::Priority, BoundedInline}, @@ -244,7 +244,8 @@ benchmarks! { fill_schedule::(when, s)?; assert_eq!(Agenda::::get(when).len(), s as usize); - let schedule_origin = T::ScheduleOrigin::successful_origin(); + let schedule_origin = + T::ScheduleOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _>(schedule_origin, when, 0) verify { ensure!( diff --git a/frame/support/src/traits/dispatch.rs b/frame/support/src/traits/dispatch.rs index 36ddf5b507..50c6c22791 100644 --- a/frame/support/src/traits/dispatch.rs +++ b/frame/support/src/traits/dispatch.rs @@ -40,25 +40,12 @@ pub trait EnsureOrigin { /// Perform the origin check. fn try_origin(o: OuterOrigin) -> Result; - /// Returns an outer origin capable of passing `try_origin` check. - /// - /// NOTE: This should generally *NOT* be reimplemented. Instead implement - /// `try_successful_origin`. + /// Attempt to get an outer origin capable of passing `try_origin` check. May return `Err` if it + /// is impossible. /// /// ** Should be used for benchmarking only!!! ** #[cfg(feature = "runtime-benchmarks")] - fn successful_origin() -> OuterOrigin { - Self::try_successful_origin().expect("No origin exists which can satisfy the guard") - } - - /// Attept to get an outer origin capable of passing `try_origin` check. May return `Err` if it - /// is impossible. Default implementation just uses `successful_origin()`. - /// - /// ** Should be used for benchmarking only!!! ** - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin() -> Result { - Ok(Self::successful_origin()) - } + fn try_successful_origin() -> Result; } /// [`EnsureOrigin`] implementation that always fails. @@ -171,25 +158,12 @@ pub trait EnsureOriginWithArg { /// Perform the origin check, returning the origin value if unsuccessful. This allows chaining. fn try_origin(o: OuterOrigin, a: &Argument) -> Result; - /// Returns an outer origin capable of passing `try_origin` check. - /// - /// NOTE: This should generally *NOT* be reimplemented. Instead implement - /// `try_successful_origin`. - /// - /// ** Should be used for benchmarking only!!! ** - #[cfg(feature = "runtime-benchmarks")] - fn successful_origin(a: &Argument) -> OuterOrigin { - Self::try_successful_origin(a).expect("No origin exists which can satisfy the guard") - } - - /// Attept to get an outer origin capable of passing `try_origin` check. May return `Err` if it - /// is impossible. Default implementation just uses `successful_origin()`. + /// Attempt to get an outer origin capable of passing `try_origin` check. May return `Err` if it + /// is impossible. /// /// ** Should be used for benchmarking only!!! ** #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin(a: &Argument) -> Result { - Ok(Self::successful_origin(a)) - } + fn try_successful_origin(a: &Argument) -> Result; } pub struct AsEnsureOriginWithArg(sp_std::marker::PhantomData); diff --git a/frame/system/src/tests.rs b/frame/system/src/tests.rs index 8223f66744..f441e78559 100644 --- a/frame/system/src/tests.rs +++ b/frame/system/src/tests.rs @@ -679,10 +679,13 @@ fn ensure_signed_stuff_works() { #[cfg(feature = "runtime-benchmarks")] { - let successful_origin: RuntimeOrigin = EnsureSigned::successful_origin(); + let successful_origin: RuntimeOrigin = EnsureSigned::try_successful_origin() + .expect("EnsureSigned has no successful origin required for the test"); assert_ok!(EnsureSigned::try_origin(successful_origin)); - let successful_origin: RuntimeOrigin = EnsureSignedBy::::successful_origin(); + let successful_origin: RuntimeOrigin = + EnsureSignedBy::::try_successful_origin() + .expect("EnsureSignedBy has no successful origin required for the test"); assert_ok!(EnsureSignedBy::::try_origin(successful_origin)); } } diff --git a/frame/tips/src/benchmarking.rs b/frame/tips/src/benchmarking.rs index 8ffc53b45e..5b1a102b8e 100644 --- a/frame/tips/src/benchmarking.rs +++ b/frame/tips/src/benchmarking.rs @@ -19,7 +19,9 @@ #![cfg(feature = "runtime-benchmarks")] -use frame_benchmarking::v1::{account, benchmarks_instance_pallet, whitelisted_caller}; +use frame_benchmarking::v1::{ + account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError, +}; use frame_support::ensure; use frame_system::RawOrigin; use sp_runtime::traits::Saturating; @@ -196,7 +198,8 @@ benchmarks_instance_pallet! { let reason_hash = T::Hashing::hash(&reason[..]); let hash = T::Hashing::hash_of(&(&reason_hash, &beneficiary)); ensure!(Tips::::contains_key(hash), "tip does not exist"); - let reject_origin = T::RejectOrigin::successful_origin(); + let reject_origin = + T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(reject_origin, hash) impl_benchmark_test_suite!(TipsMod, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index eb44744506..0947618a2b 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::{Pallet as Treasury, *}; -use frame_benchmarking::v1::{account, benchmarks_instance_pallet}; +use frame_benchmarking::v1::{account, benchmarks_instance_pallet, BenchmarkError}; use frame_support::{ dispatch::UnfilteredDispatchable, ensure, @@ -99,7 +99,8 @@ benchmarks_instance_pallet! { beneficiary_lookup )?; let proposal_id = Treasury::::proposal_count() - 1; - let reject_origin = T::RejectOrigin::successful_origin(); + let reject_origin = + T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(reject_origin, proposal_id) approve_proposal { @@ -112,7 +113,8 @@ benchmarks_instance_pallet! { beneficiary_lookup )?; let proposal_id = Treasury::::proposal_count() - 1; - let approve_origin = T::ApproveOrigin::successful_origin(); + let approve_origin = + T::ApproveOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(approve_origin, proposal_id) remove_approval { @@ -124,7 +126,8 @@ benchmarks_instance_pallet! { )?; let proposal_id = Treasury::::proposal_count() - 1; Treasury::::approve_proposal(RawOrigin::Root.into(), proposal_id)?; - let reject_origin = T::RejectOrigin::successful_origin(); + let reject_origin = + T::RejectOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; }: _(reject_origin, proposal_id) on_initialize_proposals { diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index 5ecb093a5d..2656582f0e 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -21,7 +21,7 @@ use super::*; use frame_benchmarking::v1::{ - account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, + account, benchmarks_instance_pallet, whitelist_account, whitelisted_caller, BenchmarkError, }; use frame_support::{ dispatch::UnfilteredDispatchable, @@ -137,7 +137,8 @@ fn assert_last_event, I: 'static>(generic_event: >:: benchmarks_instance_pallet! { create { let collection = T::Helper::collection(0); - let origin = T::CreateOrigin::successful_origin(&collection); + let origin = T::CreateOrigin::try_successful_origin(&collection) + .map_err(|_| BenchmarkError::Weightless)?; let caller = T::CreateOrigin::ensure_origin(origin.clone(), &collection).unwrap(); whitelist_account!(caller); let admin = T::Lookup::unlookup(caller.clone()); @@ -290,7 +291,8 @@ benchmarks_instance_pallet! { force_item_status { let (collection, caller, caller_lookup) = create_collection::(); - let origin = T::ForceOrigin::successful_origin(); + let origin = + T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::force_item_status { collection, owner: caller_lookup.clone(), diff --git a/frame/whitelist/src/benchmarking.rs b/frame/whitelist/src/benchmarking.rs index e64842b34d..582f4a7997 100644 --- a/frame/whitelist/src/benchmarking.rs +++ b/frame/whitelist/src/benchmarking.rs @@ -20,7 +20,7 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use frame_benchmarking::v1::benchmarks; +use frame_benchmarking::v1::{benchmarks, BenchmarkError}; use frame_support::{ensure, traits::EnsureOrigin}; #[cfg(test)] @@ -28,7 +28,8 @@ use crate::Pallet as Whitelist; benchmarks! { whitelist_call { - let origin = T::WhitelistOrigin::successful_origin(); + let origin = + T::WhitelistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call_hash = Default::default(); }: _(origin, call_hash) verify { @@ -43,7 +44,8 @@ benchmarks! { } remove_whitelisted_call { - let origin = T::WhitelistOrigin::successful_origin(); + let origin = + T::WhitelistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call_hash = Default::default(); Pallet::::whitelist_call(origin.clone(), call_hash) .expect("whitelisting call must be successful"); @@ -70,7 +72,8 @@ benchmarks! { // NOTE: we remove `10` because we need some bytes to encode the variants and vec length let n in 1 .. T::Preimages::MAX_LENGTH as u32 - 10; - let origin = T::DispatchWhitelistedOrigin::successful_origin(); + let origin = T::DispatchWhitelistedOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; let remark = sp_std::vec![1u8; n as usize]; let call: ::RuntimeCall = frame_system::Call::remark { remark }.into(); let call_weight = call.get_dispatch_info().weight; @@ -98,7 +101,8 @@ benchmarks! { dispatch_whitelisted_call_with_preimage { let n in 1 .. 10_000; - let origin = T::DispatchWhitelistedOrigin::successful_origin(); + let origin = T::DispatchWhitelistedOrigin::try_successful_origin() + .map_err(|_| BenchmarkError::Weightless)?; let remark = sp_std::vec![1u8; n as usize]; let call: ::RuntimeCall = frame_system::Call::remark { remark }.into(); From c4b2db5a050dad1129a18ebe9c4e3013038e1ad1 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Wed, 1 Feb 2023 10:38:41 -0300 Subject: [PATCH 75/80] hooks default impl missing where clause (#13264) * hooks default impl missing where clause * add tests * Update frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs --------- Co-authored-by: parity-processbot <> --- .../procedural/src/pallet/expand/hooks.rs | 2 +- .../tests/pallet_ui/duplicate_store_attr.rs | 3 +-- .../pass/where_clause_missing_hooks.rs | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs diff --git a/frame/support/procedural/src/pallet/expand/hooks.rs b/frame/support/procedural/src/pallet/expand/hooks.rs index c41a65b57b..987d0691b1 100644 --- a/frame/support/procedural/src/pallet/expand/hooks.rs +++ b/frame/support/procedural/src/pallet/expand/hooks.rs @@ -76,7 +76,7 @@ pub fn expand_hooks(def: &mut Def) -> proc_macro2::TokenStream { quote::quote! { impl<#type_impl_gen> #frame_support::traits::Hooks<::BlockNumber> - for Pallet<#type_use_gen> {} + for #pallet_ident<#type_use_gen> #where_clause {} } } else { proc_macro2::TokenStream::new() diff --git a/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs b/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs index d675ddefe9..ab318034ac 100644 --- a/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs +++ b/frame/support/test/tests/pallet_ui/duplicate_store_attr.rs @@ -22,5 +22,4 @@ mod pallet { type Foo = StorageValue<_, u8>; } -fn main() { -} +fn main() {} diff --git a/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs b/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs new file mode 100644 index 0000000000..bf5f223062 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pass/where_clause_missing_hooks.rs @@ -0,0 +1,19 @@ +#[frame_support::pallet] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config where ::Index: From {} + + #[pallet::pallet] + pub struct Pallet(core::marker::PhantomData); + + #[pallet::call] + impl Pallet where ::Index: From {} + + impl Pallet where ::Index: From { + fn foo(x: u128) { + let _index = ::Index::from(x); + } + } +} + +fn main() {} From b2b2e650f204d9ee2a7b67f5b9cc6ab146ded877 Mon Sep 17 00:00:00 2001 From: Matteo Muraca <56828990+muraca@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:11:34 +0100 Subject: [PATCH 76/80] implemented `contains_prefix` for StorageDoubleMap and StorageNMap (#13232) * implemented `contains_prefix` for StorageDoubleMap and StorageNMap Signed-off-by: muraca * match prefix to next_key Signed-off-by: muraca * warning unexpected behaviour with empty keys Signed-off-by: muraca * clarifications for unhashed::contains_prefixed_key Signed-off-by: muraca * added tests for StorageNMap Signed-off-by: muraca --------- Signed-off-by: muraca --- .../src/storage/generator/double_map.rs | 7 +++ frame/support/src/storage/generator/nmap.rs | 7 +++ frame/support/src/storage/mod.rs | 47 ++++++++++++++++++- frame/support/src/storage/unhashed.rs | 10 ++++ 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/frame/support/src/storage/generator/double_map.rs b/frame/support/src/storage/generator/double_map.rs index c95dcee9d7..b60bb79566 100644 --- a/frame/support/src/storage/generator/double_map.rs +++ b/frame/support/src/storage/generator/double_map.rs @@ -233,6 +233,13 @@ where .into() } + fn contains_prefix(k1: KArg1) -> bool + where + KArg1: EncodeLike, + { + unhashed::contains_prefixed_key(Self::storage_double_map_final_key1(k1).as_ref()) + } + fn iter_prefix_values(k1: KArg1) -> storage::PrefixIterator where KArg1: ?Sized + EncodeLike, diff --git a/frame/support/src/storage/generator/nmap.rs b/frame/support/src/storage/generator/nmap.rs index 79f3d72044..8cf1459431 100755 --- a/frame/support/src/storage/generator/nmap.rs +++ b/frame/support/src/storage/generator/nmap.rs @@ -208,6 +208,13 @@ where ) } + fn contains_prefix(partial_key: KP) -> bool + where + K: HasKeyPrefix, + { + unhashed::contains_prefixed_key(&Self::storage_n_map_partial_key(partial_key)) + } + fn iter_prefix_values(partial_key: KP) -> PrefixIterator where K: HasKeyPrefix, diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 28f2dee992..dd91d8cc2a 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -563,6 +563,12 @@ pub trait StorageDoubleMap { where KArg1: ?Sized + EncodeLike; + /// Does any value under the first key `k1` (explicitly) exist in storage? + /// Might have unexpected behaviour with empty keys, e.g. `[]`. + fn contains_prefix(k1: KArg1) -> bool + where + KArg1: EncodeLike; + /// Iterate over values that share the first key. fn iter_prefix_values(k1: KArg1) -> PrefixIterator where @@ -739,6 +745,12 @@ pub trait StorageNMap { where K: HasKeyPrefix; + /// Does any value under a `partial_key` prefix (explicitly) exist in storage? + /// Might have unexpected behaviour with empty keys, e.g. `[]`. + fn contains_prefix(partial_key: KP) -> bool + where + K: HasKeyPrefix; + /// Iterate over values that share the partial prefix key. fn iter_prefix_values(partial_key: KP) -> PrefixIterator where @@ -1485,7 +1497,7 @@ pub fn storage_prefix(pallet_name: &[u8], storage_name: &[u8]) -> [u8; 32] { #[cfg(test)] mod test { use super::*; - use crate::{assert_ok, hash::Identity, Twox128}; + use crate::{assert_ok, hash::Identity, pallet_prelude::NMapKey, Twox128}; use bounded_vec::BoundedVec; use frame_support::traits::ConstU32; use generator::StorageValue as _; @@ -1780,6 +1792,39 @@ mod test { #[crate::storage_alias] type FooDoubleMap = StorageDoubleMap>>; + #[crate::storage_alias] + type FooTripleMap = StorageNMap< + Prefix, + (NMapKey, NMapKey, NMapKey), + u64, + >; + + #[test] + fn contains_prefix_works() { + TestExternalities::default().execute_with(|| { + // Test double maps + assert!(FooDoubleMap::iter_prefix_values(1).next().is_none()); + assert_eq!(FooDoubleMap::contains_prefix(1), false); + + assert_ok!(FooDoubleMap::try_append(1, 1, 4)); + assert_ok!(FooDoubleMap::try_append(2, 1, 4)); + assert!(FooDoubleMap::iter_prefix_values(1).next().is_some()); + assert!(FooDoubleMap::contains_prefix(1)); + FooDoubleMap::remove(1, 1); + assert_eq!(FooDoubleMap::contains_prefix(1), false); + + // Test N Maps + assert!(FooTripleMap::iter_prefix_values((1,)).next().is_none()); + assert_eq!(FooTripleMap::contains_prefix((1,)), false); + + FooTripleMap::insert((1, 1, 1), 4); + FooTripleMap::insert((2, 1, 1), 4); + assert!(FooTripleMap::iter_prefix_values((1,)).next().is_some()); + assert!(FooTripleMap::contains_prefix((1,))); + FooTripleMap::remove((1, 1, 1)); + assert_eq!(FooTripleMap::contains_prefix((1,)), false); + }); + } #[test] fn try_append_works() { diff --git a/frame/support/src/storage/unhashed.rs b/frame/support/src/storage/unhashed.rs index 850e93e7d7..8388c5f885 100644 --- a/frame/support/src/storage/unhashed.rs +++ b/frame/support/src/storage/unhashed.rs @@ -154,6 +154,16 @@ pub fn clear_prefix( MultiRemovalResults { maybe_cursor, backend: i, unique: i, loops: i } } +/// Returns `true` if the storage contains any key, which starts with a certain prefix, +/// and is longer than said prefix. +/// This means that a key which equals the prefix will not be counted. +pub fn contains_prefixed_key(prefix: &[u8]) -> bool { + match sp_io::storage::next_key(prefix) { + Some(key) => key.starts_with(prefix), + None => false, + } +} + /// Get a Vec of bytes from storage. pub fn get_raw(key: &[u8]) -> Option> { sp_io::storage::get(key).map(|value| value.to_vec()) From 3bc3742d5c0c5269353d7809d9f8f91104a93273 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Wed, 1 Feb 2023 18:17:05 +0100 Subject: [PATCH 77/80] Calling proxy doesn't remove announcement (#13267) * Calling proxy doesn't remove announcement * Update frame/proxy/src/tests.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fmt --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- frame/proxy/src/lib.rs | 2 -- frame/proxy/src/tests.rs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index d98534d16a..dfe8c86ca5 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -183,8 +183,6 @@ pub mod pallet { /// Dispatch the given `call` from an account that the sender is authorised for through /// `add_proxy`. /// - /// Removes any corresponding announcement(s). - /// /// The dispatch origin for this call must be _Signed_. /// /// Parameters: diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 3eb3ab3705..0e7db3512f 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -288,6 +288,23 @@ fn announcer_must_be_proxy() { }); } +#[test] +fn calling_proxy_doesnt_remove_announcement() { + new_test_ext().execute_with(|| { + assert_ok!(Proxy::add_proxy(RuntimeOrigin::signed(1), 2, ProxyType::Any, 0)); + + let call = Box::new(call_transfer(6, 1)); + let call_hash = BlakeTwo256::hash_of(&call); + + assert_ok!(Proxy::announce(RuntimeOrigin::signed(2), 1, call_hash)); + assert_ok!(Proxy::proxy(RuntimeOrigin::signed(2), 1, None, call)); + + // The announcement is not removed by calling proxy. + let announcements = Announcements::::get(2); + assert_eq!(announcements.0, vec![Announcement { real: 1, call_hash, height: 1 }]); + }); +} + #[test] fn delayed_requires_pre_announcement() { new_test_ext().execute_with(|| { From 5a281ced23f8802b44d2a0fb6e1e08f6013b2554 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 7 Feb 2023 19:15:01 +0100 Subject: [PATCH 78/80] Fix block pruning (#13323) --- client/db/src/lib.rs | 84 +++++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index f217eb6480..f54f1bdb13 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -1806,7 +1806,13 @@ impl Backend { } let new_displaced = self.blockchain.leaves.write().finalize_height(f_num); - self.prune_blocks(transaction, f_num, &new_displaced, current_transaction_justifications)?; + self.prune_blocks( + transaction, + f_num, + f_hash, + &new_displaced, + current_transaction_justifications, + )?; Ok(()) } @@ -1815,6 +1821,7 @@ impl Backend { &self, transaction: &mut Transaction, finalized_number: NumberFor, + finalized_hash: Block::Hash, displaced: &FinalizationOutcome>, current_transaction_justifications: &mut HashMap, ) -> ClientResult<()> { @@ -1843,10 +1850,10 @@ impl Backend { self.prune_block(transaction, BlockId::::number(number))?; } - self.prune_displaced_branches(transaction, finalized_number, displaced)?; + self.prune_displaced_branches(transaction, finalized_hash, displaced)?; }, BlocksPruning::KeepFinalized => { - self.prune_displaced_branches(transaction, finalized_number, displaced)?; + self.prune_displaced_branches(transaction, finalized_hash, displaced)?; }, } Ok(()) @@ -1855,28 +1862,21 @@ impl Backend { fn prune_displaced_branches( &self, transaction: &mut Transaction, - finalized: NumberFor, + finalized: Block::Hash, displaced: &FinalizationOutcome>, ) -> ClientResult<()> { // Discard all blocks from displaced branches for h in displaced.leaves() { - let mut number = finalized; - let mut hash = *h; - // Follow displaced chains back until we reach a finalized block. - // Since leaves are discarded due to finality, they can't have parents - // that are canonical, but not yet finalized. So we stop deleting as soon as - // we reach canonical chain. - while self.blockchain.hash(number)? != Some(hash) { - match self.blockchain.header(hash)? { - Some(header) => { - self.blockchain.insert_persisted_body_if_pinned(hash)?; - - self.prune_block(transaction, BlockId::::hash(hash))?; - number = header.number().saturating_sub(One::one()); - hash = *header.parent_hash(); + match sp_blockchain::tree_route(&self.blockchain, *h, finalized) { + Ok(tree_route) => + for r in tree_route.retracted() { + self.blockchain.insert_persisted_body_if_pinned(r.hash)?; + self.prune_block(transaction, BlockId::::hash(r.hash))?; }, - None => break, - } + Err(sp_blockchain::Error::UnknownBlock(_)) => { + // Sometimes routes can't be calculated. E.g. after warp sync. + }, + Err(e) => Err(e)?, } } Ok(()) @@ -3569,6 +3569,50 @@ pub(crate) mod tests { assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap()); } + #[test] + fn prune_blocks_on_finalize_and_reorg() { + // 0 - 1b + // \ - 1a - 2a - 3a + // \ - 2b + + let backend = Backend::::new_test_with_tx_storage(BlocksPruning::Some(10), 10); + + let make_block = |index, parent, val: u64| { + insert_block(&backend, index, parent, None, H256::random(), vec![val.into()], None) + .unwrap() + }; + + let block_0 = make_block(0, Default::default(), 0x00); + let block_1a = make_block(1, block_0, 0x1a); + let block_1b = make_block(1, block_0, 0x1b); + let block_2a = make_block(2, block_1a, 0x2a); + let block_2b = make_block(2, block_1a, 0x2b); + let block_3a = make_block(3, block_2a, 0x3a); + + // Make sure 1b is head + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, block_0).unwrap(); + op.mark_head(block_1b).unwrap(); + backend.commit_operation(op).unwrap(); + + // Finalize 3a + let mut op = backend.begin_operation().unwrap(); + backend.begin_state_operation(&mut op, block_0).unwrap(); + op.mark_head(block_3a).unwrap(); + op.mark_finalized(block_1a, None).unwrap(); + op.mark_finalized(block_2a, None).unwrap(); + op.mark_finalized(block_3a, None).unwrap(); + backend.commit_operation(op).unwrap(); + + let bc = backend.blockchain(); + assert_eq!(None, bc.body(block_1b).unwrap()); + assert_eq!(None, bc.body(block_2b).unwrap()); + assert_eq!(Some(vec![0x00.into()]), bc.body(block_0).unwrap()); + assert_eq!(Some(vec![0x1a.into()]), bc.body(block_1a).unwrap()); + assert_eq!(Some(vec![0x2a.into()]), bc.body(block_2a).unwrap()); + assert_eq!(Some(vec![0x3a.into()]), bc.body(block_3a).unwrap()); + } + #[test] fn indexed_data_block_body() { let backend = Backend::::new_test_with_tx_storage(BlocksPruning::Some(1), 10); From 15e218a5c777b5e19fa7106be88f87852c3ac4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <123550+andresilva@users.noreply.github.com> Date: Sun, 12 Feb 2023 12:35:01 +0000 Subject: [PATCH 79/80] grandpa: don't error if best block and finality target are inconsistent (#13364) * grandpa: don't error if best block and finality target are inconsistent * grandpa: add test for best block override * grandpa: make clippy happy * grandpa: log selectchain override as debug instead of warn --- client/finality-grandpa/src/environment.rs | 35 ++++- client/finality-grandpa/src/tests.rs | 144 +++++++++++++++++++-- 2 files changed, 166 insertions(+), 13 deletions(-) diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 40ec720c4e..a9aa204f12 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -1213,7 +1213,7 @@ where // NOTE: this is purposefully done after `finality_target` to prevent a case // where in-between these two requests there is a block import and // `finality_target` returns something higher than `best_chain`. - let best_header = match select_chain.best_chain().await { + let mut best_header = match select_chain.best_chain().await { Ok(best_header) => best_header, Err(err) => { warn!( @@ -1227,12 +1227,30 @@ where }, }; - if target_header.number() > best_header.number() { - return Err(Error::Safety( - "SelectChain returned a finality target higher than its best block".into(), - )) + let is_descendent_of = is_descendent_of(&*client, None); + + if target_header.number() > best_header.number() || + target_header.number() == best_header.number() && + target_header.hash() != best_header.hash() || + !is_descendent_of(&target_header.hash(), &best_header.hash())? + { + debug!( + target: LOG_TARGET, + "SelectChain returned a finality target inconsistent with its best block. Restricting best block to target block" + ); + + best_header = target_header.clone(); } + debug!( + target: LOG_TARGET, + "SelectChain: finality target: #{} ({}), best block: #{} ({})", + target_header.number(), + target_header.hash(), + best_header.number(), + best_header.hash(), + ); + // check if our vote is currently being limited due to a pending change, // in which case we will restrict our target header to the given limit if let Some(target_number) = limit.filter(|limit| limit < target_header.number()) { @@ -1254,6 +1272,13 @@ where .header(*target_header.parent_hash())? .expect("Header known to exist after `finality_target` call; qed"); } + + debug!( + target: LOG_TARGET, + "Finality target restricted to #{} ({}) due to pending authority set change", + target_header.number(), + target_header.hash() + ) } // restrict vote according to the given voting rule, if the voting rule diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 07ea464914..05561ad856 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -244,6 +244,35 @@ impl SelectChain for MockSelectChain { } } +// A mock voting rule that allows asserting an expected value for best block +#[derive(Clone, Default)] +struct AssertBestBlock(Arc>>); + +impl VotingRule for AssertBestBlock +where + B: HeaderBackend, +{ + fn restrict_vote( + &self, + _backend: Arc, + _base: &::Header, + best_target: &::Header, + _current_target: &::Header, + ) -> VotingRuleResult { + if let Some(expected) = *self.0.lock() { + assert_eq!(best_target.hash(), expected); + } + + Box::pin(std::future::ready(None)) + } +} + +impl AssertBestBlock { + fn set_expected_best_block(&self, hash: Hash) { + *self.0.lock() = Some(hash); + } +} + const TEST_GOSSIP_DURATION: Duration = Duration::from_millis(500); fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList { @@ -1566,16 +1595,115 @@ async fn grandpa_environment_passes_actual_best_block_to_voting_rules() { .1, 10, ); +} - // returning a finality target that's higher than the best block is an - // inconsistent state that should be handled - let hashof42 = client.expect_block_hash_from_id(&BlockId::Number(42)).unwrap(); - select_chain.set_best_chain(client.expect_header(hashof21).unwrap()); - select_chain.set_finality_target(client.expect_header(hashof42).unwrap().hash()); +#[tokio::test] +async fn grandpa_environment_checks_if_best_block_is_descendent_of_finality_target() { + use finality_grandpa::voter::Environment; + + let peers = &[Ed25519Keyring::Alice]; + let voters = make_ids(peers); + + let mut net = GrandpaTestNet::new(TestApi::new(voters), 1, 0); + let peer = net.peer(0); + let network_service = peer.network_service().clone(); + let link = peer.data.lock().take().unwrap(); + let client = peer.client().as_client().clone(); + let select_chain = MockSelectChain::default(); + let voting_rule = AssertBestBlock::default(); + let env = test_environment_with_select_chain( + &link, + None, + network_service.clone(), + select_chain.clone(), + voting_rule.clone(), + ); + + // create a chain that is 10 blocks long + peer.push_blocks(10, false); + + let hashof5_a = client.expect_block_hash_from_id(&BlockId::Number(5)).unwrap(); + let hashof10_a = client.expect_block_hash_from_id(&BlockId::Number(10)).unwrap(); + + // create a fork starting at block 4 that is 6 blocks long + let fork = peer.generate_blocks_at( + BlockId::Number(4), + 6, + BlockOrigin::File, + |builder| { + let mut block = builder.build().unwrap().block; + block.header.digest_mut().push(DigestItem::Other(vec![1])); + block + }, + false, + false, + true, + ForkChoiceStrategy::LongestChain, + ); + + let hashof5_b = *fork.first().unwrap(); + let hashof10_b = *fork.last().unwrap(); + + // returning a finality target that's higher than the best block is inconsistent, + // therefore the best block should be set to be the same block as the target + select_chain.set_best_chain(client.expect_header(hashof5_a).unwrap()); + select_chain.set_finality_target(client.expect_header(hashof10_a).unwrap().hash()); + voting_rule.set_expected_best_block(hashof10_a); + + // the voting rule will internally assert that the best block that was passed was `hashof10_a`, + // instead of the one returned by `SelectChain` + assert_eq!( + env.best_chain_containing(peer.client().info().finalized_hash) + .await + .unwrap() + .unwrap() + .0, + hashof10_a, + ); + + // best block and finality target are blocks at the same height but on different forks, + // we should override the initial best block (#5B) with the target block (#5A) + select_chain.set_best_chain(client.expect_header(hashof5_b).unwrap()); + select_chain.set_finality_target(client.expect_header(hashof5_a).unwrap().hash()); + voting_rule.set_expected_best_block(hashof5_a); + + assert_eq!( + env.best_chain_containing(peer.client().info().finalized_hash) + .await + .unwrap() + .unwrap() + .0, + hashof5_a, + ); - assert_matches!( - env.best_chain_containing(peer.client().info().finalized_hash).await, - Err(CommandOrError::Error(Error::Safety(_))) + // best block is higher than finality target but it's on a different fork, + // we should override the initial best block (#5A) with the target block (#5B) + select_chain.set_best_chain(client.expect_header(hashof10_b).unwrap()); + select_chain.set_finality_target(client.expect_header(hashof5_a).unwrap().hash()); + voting_rule.set_expected_best_block(hashof5_a); + + assert_eq!( + env.best_chain_containing(peer.client().info().finalized_hash) + .await + .unwrap() + .unwrap() + .0, + hashof5_a, + ); + + // best block is higher than finality target and it's on the same fork, + // the best block passed to the voting rule should not be overriden + select_chain.set_best_chain(client.expect_header(hashof10_a).unwrap()); + select_chain.set_finality_target(client.expect_header(hashof5_a).unwrap().hash()); + voting_rule.set_expected_best_block(hashof10_a); + + assert_eq!( + env.best_chain_containing(peer.client().info().finalized_hash) + .await + .unwrap() + .unwrap() + .0, + hashof5_a, ); } From 18bb7c7c841b101c19a8d1881b893ae8e37de460 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Mon, 13 Feb 2023 14:28:03 +0100 Subject: [PATCH 80/80] benchmarks: EnsureRankedMember must add ranked members (#13297) (#13348) Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi --- frame/ranked-collective/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 84be1243c8..a65d184d6b 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -256,8 +256,7 @@ impl, I: 'static, const MIN_RANK: u16> EnsureOrigin Result { - let who = IndexToId::::get(MIN_RANK, 0).ok_or(())?; - Ok(frame_system::RawOrigin::Signed(who).into()) + EnsureRankedMember::::try_successful_origin() } } @@ -279,8 +278,7 @@ impl, I: 'static, const MIN_RANK: u16> EnsureOrigin Result { - let who = IndexToId::::get(MIN_RANK, 0).ok_or(())?; - Ok(frame_system::RawOrigin::Signed(who).into()) + EnsureRankedMember::::try_successful_origin() } } @@ -302,7 +300,9 @@ impl, I: 'static, const MIN_RANK: u16> EnsureOrigin Result { - let who = IndexToId::::get(MIN_RANK, 0).ok_or(())?; + let who = frame_benchmarking::account::("successful_origin", 0, 0); + crate::Pallet::::do_add_member_to_rank(who.clone(), MIN_RANK) + .expect("Could not add members for benchmarks"); Ok(frame_system::RawOrigin::Signed(who).into()) } }