From 716e1604625b07ceccb70ab41896e7971d42a4c6 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 14:04:59 +0100 Subject: [PATCH 01/16] add already leased Co-Authored-By: parity-processbot <> --- runtime/common/src/auctions.rs | 9 ++++++++ runtime/common/src/slots.rs | 39 +++++++++++++++++++++++++++++++++- runtime/common/src/traits.rs | 7 ++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/runtime/common/src/auctions.rs b/runtime/common/src/auctions.rs index 1a705207b631..1a40b0e22a3d 100644 --- a/runtime/common/src/auctions.rs +++ b/runtime/common/src/auctions.rs @@ -753,6 +753,15 @@ mod tests { fn lease_period_index() -> Self::LeasePeriod { (System::block_number() / Self::lease_period()).into() } + + fn already_leased( + _para_id: ParaId, + _first_period: Self::LeasePeriod, + _last_period: Self::LeasePeriod + ) -> bool { + // TODO + false + } } ord_parameter_types!{ diff --git a/runtime/common/src/slots.rs b/runtime/common/src/slots.rs index 536ebc9b5ace..f46aa1803e00 100644 --- a/runtime/common/src/slots.rs +++ b/runtime/common/src/slots.rs @@ -22,7 +22,7 @@ //! must handled by a separately, through the trait interface that this pallet provides or the root dispatchables. use sp_std::prelude::*; -use sp_runtime::traits::{CheckedSub, Zero, CheckedConversion}; +use sp_runtime::traits::{CheckedSub, Zero, CheckedConversion, Saturating}; use frame_support::{ decl_module, decl_storage, decl_event, decl_error, dispatch::DispatchResult, traits::{Currency, ReservableCurrency, Get}, weights::Weight, @@ -421,6 +421,43 @@ impl Leaser for Module { fn lease_period_index() -> Self::LeasePeriod { >::block_number() / T::LeasePeriod::get() } + + fn already_leased( + para_id: ParaId, + first_period: Self::LeasePeriod, + last_period: Self::LeasePeriod, + ) -> bool { + let current_lease_period = Self::lease_period_index(); + + // Can't look in the past, so we pick whichever is the biggest. + let start_period = first_period.max(current_lease_period); + // Find the offset to look into the lease period list. + // Subtraction is safe because of max above. + let offset = match (start_period - current_lease_period).checked_into::() { + Some(offset) => offset, + None => return false, + }; + + // This calculates how deep we should look in the vec for a potential lease. + let period_count = match last_period.saturating_sub(start_period).checked_into::() { + Some(period_count) => period_count, + None => return false, + }; + + // Get the leases, and check each item in the vec which is part of the range we ar checking. + let leases = Leases::::get(para_id); + for slot in offset .. offset + period_count { + if let Some(maybe_lease) = leases.get(slot) { + // If there exists any lease period, we exit early and return true. + if maybe_lease.is_some() { + return true + } + } + } + + // If we got here, then we did not find any overlapping leases. + false + } } diff --git a/runtime/common/src/traits.rs b/runtime/common/src/traits.rs index fb157cbf841c..dcda1c0aadc9 100644 --- a/runtime/common/src/traits.rs +++ b/runtime/common/src/traits.rs @@ -135,6 +135,13 @@ pub trait Leaser { /// Returns the current lease period. fn lease_period_index() -> Self::LeasePeriod; + + /// Returns true if the parachain already has a lease in any of `slot_range`. + fn already_leased( + para_id: ParaId, + first_period: Self::LeasePeriod, + last_period: Self::LeasePeriod + ) -> bool; } pub trait Auctioneer { From d4b3f90d5a740c0efbc0bbe7bd5fc1cd9b330c33 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 15:08:40 +0100 Subject: [PATCH 02/16] add unit test Co-Authored-By: parity-processbot <> --- runtime/common/src/auctions.rs | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/runtime/common/src/auctions.rs b/runtime/common/src/auctions.rs index 1a40b0e22a3d..fc304ea91507 100644 --- a/runtime/common/src/auctions.rs +++ b/runtime/common/src/auctions.rs @@ -149,6 +149,8 @@ pub mod pallet { NotAuction, /// Auction has already ended. AuctionEnded, + /// The para is already leased out for part of this range. + AlreadyLeasedOut, } /// Number of auctions started so far. @@ -418,6 +420,9 @@ impl Pallet { let now = frame_system::Pallet::::block_number(); ensure!(now < late_end, Error::::AuctionEnded); + // We also make sure that the bid is not for any existing leases the para already has. + ensure!(!T::Leaser::already_leased(para, first_slot, last_slot), Error::::AlreadyLeasedOut); + // Our range. let range = SlotRange::new_bounded(first_lease_period, first_slot, last_slot)?; // Range as an array index. @@ -755,12 +760,15 @@ mod tests { } fn already_leased( - _para_id: ParaId, - _first_period: Self::LeasePeriod, - _last_period: Self::LeasePeriod + para_id: ParaId, + first_period: Self::LeasePeriod, + last_period: Self::LeasePeriod ) -> bool { - // TODO - false + leases().into_iter().any(|((para, period), _data)| { + para == para_id && + first_period <= period && + period <= last_period + }) } } @@ -1334,6 +1342,42 @@ mod tests { }); } + #[test] + fn handle_bid_checks_existing_lease_periods() { + new_test_ext().execute_with(|| { + run_to_block(1); + assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 1, 2, 3, 1)); + assert_eq!(Balances::reserved_balance(1), 1); + assert_eq!(Balances::free_balance(1), 9); + run_to_block(9); + + assert_eq!(leases(), vec![ + ((0.into(), 2), LeaseData { leaser: 1, amount: 1 }), + ((0.into(), 3), LeaseData { leaser: 1, amount: 1 }), + ]); + assert_eq!(TestLeaser::deposit_held(0.into(), &1), 1); + + // Para 1 just won an auction above and won some lease periods. + // No bids can work which overlap these periods. + assert_ok!(Auctions::new_auction(Origin::signed(6), 5, 1)); + assert_noop!( + Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 4, 1), + Error::::AlreadyLeasedOut, + ); + assert_noop!( + Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 2, 1), + Error::::AlreadyLeasedOut, + ); + assert_noop!( + Auctions::bid(Origin::signed(1), 0.into(), 2, 3, 4, 1), + Error::::AlreadyLeasedOut, + ); + // This is okay, not an overlapping bid. + assert_ok!(Auctions::bid(Origin::signed(1), 0.into(), 2, 1, 1, 1)); + }); + } + // Here we will test that taking only 10 samples during the ending period works as expected. #[test] fn less_winning_samples_work() { From be4014d8fbcb245c882e9867baf6eac0d6842a70 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 16:28:22 +0100 Subject: [PATCH 03/16] add integration test and fix Co-Authored-By: parity-processbot <> --- runtime/common/src/integration_tests.rs | 151 ++++++++++++++++++++++++ runtime/common/src/slots.rs | 2 +- 2 files changed, 152 insertions(+), 1 deletion(-) diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index bdef226a0ae8..1456a297f0d9 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -1092,3 +1092,154 @@ fn gap_bids_work() { assert_eq!(Balances::reserved_balance(&20), 0); }); } + +// This test verifies that if a parachain already has won some lease periods, that it cannot bid for +// any of those same lease periods again. +#[test] +fn cant_bid_on_existing_lease_periods() { + new_test_ext().execute_with(|| { + assert!(System::block_number().is_one()); // So events are emitted + Balances::make_free_balance_be(&1, 1_000_000_000); + // First register 2 parathreads + assert_ok!(Registrar::reserve(Origin::signed(1))); + assert_ok!(Registrar::register( + Origin::signed(1), + ParaId::from(2000), + test_genesis_head(10), + test_validation_code(10), + )); + + // Start a new auction in the future + let starting_block = System::block_number(); + let duration = 99u32; + let lease_period_index_start = 4u32; + assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + + // 2 sessions later they are parathreads + run_to_session(2); + + // Open a crowdloan for Para 1 for slots 0-3 + assert_ok!(Crowdloan::create( + Origin::signed(1), + ParaId::from(2000), + 1_000_000, // Cap + lease_period_index_start + 0, // First Slot + lease_period_index_start + 1, // Last Slot + 400, // Long block end + None, + )); + let crowdloan_account = Crowdloan::fund_account_id(ParaId::from(2000)); + + // Bunch of contributions + let mut total = 0; + for i in 10 .. 20 { + Balances::make_free_balance_be(&i, 1_000_000_000); + assert_ok!(Crowdloan::contribute(Origin::signed(i), ParaId::from(2000), 900 - i, None)); + total += 900 - i; + } + assert!(total > 0); + assert_eq!(Balances::free_balance(&crowdloan_account), total); + + // Finish the auction. + run_to_block(starting_block + 110); + + // Appropriate Paras should have won slots + assert_eq!( + slots::Leases::::get(ParaId::from(2000)), + // -- 1 --- 2 --- 3 --- 4 --- 5 ------------- 6 ------------------------ 7 ------------- + vec![None, None, None, Some((crowdloan_account, 8855)), Some((crowdloan_account, 8855))], + ); + + // Let's start another auction for the same range + let starting_block = System::block_number(); + let duration = 99u32; + let lease_period_index_start = 4u32; + assert_ok!(Auctions::new_auction(Origin::root(), duration, lease_period_index_start)); + + // Poke the crowdloan into `NewRaise` + assert_ok!(Crowdloan::poke(Origin::signed(1), ParaId::from(2000))); + assert_eq!(Crowdloan::new_raise(), vec![ParaId::from(2000)]); + + // Beginning of ending block. + run_to_block(starting_block + 100); + + // Bids cannot be made which intersect + assert_noop!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start + 0, + lease_period_index_start + 1, + 100, + ), AuctionsError::::AlreadyLeasedOut, + ); + + assert_noop!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start + 1, + lease_period_index_start + 2, + 100, + ), AuctionsError::::AlreadyLeasedOut, + ); + + assert_noop!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start - 1, + lease_period_index_start + 0, + 100, + ), AuctionsError::::AlreadyLeasedOut, + ); + + assert_noop!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start + 0, + lease_period_index_start + 0, + 100, + ), AuctionsError::::AlreadyLeasedOut, + ); + + assert_noop!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start + 1, + lease_period_index_start + 1, + 100, + ), AuctionsError::::AlreadyLeasedOut, + ); + + assert_noop!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start - 1, + lease_period_index_start + 5, + 100, + ), AuctionsError::::AlreadyLeasedOut, + ); + + // Will work when not overlapping + assert_ok!( + Auctions::bid( + Origin::signed(crowdloan_account), + ParaId::from(2000), + 2, + lease_period_index_start + 2, + lease_period_index_start + 3, + 100, + ) + ); + }); +} diff --git a/runtime/common/src/slots.rs b/runtime/common/src/slots.rs index f46aa1803e00..a403e188d00b 100644 --- a/runtime/common/src/slots.rs +++ b/runtime/common/src/slots.rs @@ -446,7 +446,7 @@ impl Leaser for Module { // Get the leases, and check each item in the vec which is part of the range we ar checking. let leases = Leases::::get(para_id); - for slot in offset .. offset + period_count { + for slot in offset ..= offset + period_count { if let Some(maybe_lease) = leases.get(slot) { // If there exists any lease period, we exit early and return true. if maybe_lease.is_some() { From e33e1b7d6a9227aeba0577478e682452611d92a6 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 16:30:04 +0100 Subject: [PATCH 04/16] better doc Co-Authored-By: parity-processbot <> --- runtime/common/src/traits.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/common/src/traits.rs b/runtime/common/src/traits.rs index dcda1c0aadc9..a43e731620aa 100644 --- a/runtime/common/src/traits.rs +++ b/runtime/common/src/traits.rs @@ -136,7 +136,8 @@ pub trait Leaser { /// Returns the current lease period. fn lease_period_index() -> Self::LeasePeriod; - /// Returns true if the parachain already has a lease in any of `slot_range`. + /// Returns true if the parachain already has a lease in any of lease periods in the inclusive + /// range `[first_period, last_period]`. fn already_leased( para_id: ParaId, first_period: Self::LeasePeriod, From b6832335d347534ef64a3b2d36253986e48b9e84 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 21:31:50 +0100 Subject: [PATCH 05/16] Update runtime/common/src/slots.rs --- runtime/common/src/slots.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/slots.rs b/runtime/common/src/slots.rs index a403e188d00b..83f265266817 100644 --- a/runtime/common/src/slots.rs +++ b/runtime/common/src/slots.rs @@ -435,7 +435,7 @@ impl Leaser for Module { // Subtraction is safe because of max above. let offset = match (start_period - current_lease_period).checked_into::() { Some(offset) => offset, - None => return false, + None => return true, }; // This calculates how deep we should look in the vec for a potential lease. From 9aa5309f7d3950331f65bdf84ec7bf762af9ee22 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 21:32:03 +0100 Subject: [PATCH 06/16] Update runtime/common/src/slots.rs --- runtime/common/src/slots.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/slots.rs b/runtime/common/src/slots.rs index 83f265266817..659c0d218631 100644 --- a/runtime/common/src/slots.rs +++ b/runtime/common/src/slots.rs @@ -441,7 +441,7 @@ impl Leaser for Module { // This calculates how deep we should look in the vec for a potential lease. let period_count = match last_period.saturating_sub(start_period).checked_into::() { Some(period_count) => period_count, - None => return false, + None => return true, }; // Get the leases, and check each item in the vec which is part of the range we ar checking. From 62e800bbc974adcc740a11a16ec713e84b88dc03 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 21:33:16 +0100 Subject: [PATCH 07/16] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- runtime/common/src/slots.rs | 8 +++----- runtime/common/src/traits.rs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/runtime/common/src/slots.rs b/runtime/common/src/slots.rs index 659c0d218631..4fd633fc3e80 100644 --- a/runtime/common/src/slots.rs +++ b/runtime/common/src/slots.rs @@ -444,14 +444,12 @@ impl Leaser for Module { None => return true, }; - // Get the leases, and check each item in the vec which is part of the range we ar checking. + // Get the leases, and check each item in the vec which is part of the range we are checking. let leases = Leases::::get(para_id); for slot in offset ..= offset + period_count { - if let Some(maybe_lease) = leases.get(slot) { + if let Some(Some(_)) = leases.get(slot) { // If there exists any lease period, we exit early and return true. - if maybe_lease.is_some() { - return true - } + return true } } diff --git a/runtime/common/src/traits.rs b/runtime/common/src/traits.rs index a43e731620aa..ffd11b35cd6c 100644 --- a/runtime/common/src/traits.rs +++ b/runtime/common/src/traits.rs @@ -137,7 +137,7 @@ pub trait Leaser { fn lease_period_index() -> Self::LeasePeriod; /// Returns true if the parachain already has a lease in any of lease periods in the inclusive - /// range `[first_period, last_period]`. + /// range `[first_period, last_period]`, intersected with the unbounded range [`current_lease_period`..] . fn already_leased( para_id: ParaId, first_period: Self::LeasePeriod, From 0051604c9c89e0a7e6f5fa7f4ef039e4ca840b6d Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 21:35:29 +0100 Subject: [PATCH 08/16] Update runtime/common/src/integration_tests.rs --- runtime/common/src/integration_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index 1456a297f0d9..64610b043ac0 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -1100,7 +1100,7 @@ fn cant_bid_on_existing_lease_periods() { new_test_ext().execute_with(|| { assert!(System::block_number().is_one()); // So events are emitted Balances::make_free_balance_be(&1, 1_000_000_000); - // First register 2 parathreads + // First register a parathread assert_ok!(Registrar::reserve(Origin::signed(1))); assert_ok!(Registrar::register( Origin::signed(1), From 6d6f47df4db3539510b8a26d9c5f0f919dbef3a2 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 24 Jun 2021 21:36:32 +0100 Subject: [PATCH 09/16] Update runtime/common/src/integration_tests.rs --- runtime/common/src/integration_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/common/src/integration_tests.rs b/runtime/common/src/integration_tests.rs index 64610b043ac0..32c30389ec3c 100644 --- a/runtime/common/src/integration_tests.rs +++ b/runtime/common/src/integration_tests.rs @@ -1146,7 +1146,7 @@ fn cant_bid_on_existing_lease_periods() { // Appropriate Paras should have won slots assert_eq!( slots::Leases::::get(ParaId::from(2000)), - // -- 1 --- 2 --- 3 --- 4 --- 5 ------------- 6 ------------------------ 7 ------------- + // -- 1 --- 2 --- 3 ------------- 4 ------------------------ 5 ------------- vec![None, None, None, Some((crowdloan_account, 8855)), Some((crowdloan_account, 8855))], ); From 63f5db5bc84e652effa0d430e9717889d16610da Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 24 Jun 2021 20:48:38 +0000 Subject: [PATCH 10/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_auctions.rs --- .../kusama/src/weights/runtime_common_auctions.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/kusama/src/weights/runtime_common_auctions.rs b/runtime/kusama/src/weights/runtime_common_auctions.rs index a33dc0f5d171..025c70098ae3 100644 --- a/runtime/kusama/src/weights/runtime_common_auctions.rs +++ b/runtime/kusama/src/weights/runtime_common_auctions.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for runtime_common::auctions //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-18, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-06-24, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 // Executed Command: @@ -31,7 +31,7 @@ // --wasm-execution=compiled // --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/ +// --output=./runtime/kusama/src/weights/runtime_common_auctions.rs #![allow(unused_parens)] @@ -44,22 +44,22 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::auctions::WeightInfo for WeightInfo { fn new_auction() -> Weight { - (24_014_000 as Weight) + (29_711_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn bid() -> Weight { - (134_189_000 as Weight) + (155_737_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn on_initialize() -> Weight { - (23_127_259_000 as Weight) + (32_833_378_000 as Weight) .saturating_add(T::DbWeight::get().reads(3688 as Weight)) .saturating_add(T::DbWeight::get().writes(3683 as Weight)) } fn cancel_auction() -> Weight { - (4_854_786_000 as Weight) + (7_044_760_000 as Weight) .saturating_add(T::DbWeight::get().reads(73 as Weight)) .saturating_add(T::DbWeight::get().writes(3673 as Weight)) } From ba1f1d36e6e7294ed88ecbd21d63adfb11e81a68 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 24 Jun 2021 21:33:12 +0000 Subject: [PATCH 11/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_auctions.rs --- runtime/kusama/src/weights/runtime_common_auctions.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/kusama/src/weights/runtime_common_auctions.rs b/runtime/kusama/src/weights/runtime_common_auctions.rs index 025c70098ae3..f33b909ae1d2 100644 --- a/runtime/kusama/src/weights/runtime_common_auctions.rs +++ b/runtime/kusama/src/weights/runtime_common_auctions.rs @@ -44,22 +44,22 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::auctions::WeightInfo for WeightInfo { fn new_auction() -> Weight { - (29_711_000 as Weight) + (29_554_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn bid() -> Weight { - (155_737_000 as Weight) + (154_464_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn on_initialize() -> Weight { - (32_833_378_000 as Weight) + (33_239_172_000 as Weight) .saturating_add(T::DbWeight::get().reads(3688 as Weight)) .saturating_add(T::DbWeight::get().writes(3683 as Weight)) } fn cancel_auction() -> Weight { - (7_044_760_000 as Weight) + (7_021_314_000 as Weight) .saturating_add(T::DbWeight::get().reads(73 as Weight)) .saturating_add(T::DbWeight::get().writes(3673 as Weight)) } From 35cfc7af0a9b15682ec82f04a451439c27da585c Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 24 Jun 2021 22:41:58 +0000 Subject: [PATCH 12/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::crowdloan --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_crowdloan.rs --- .../src/weights/runtime_common_crowdloan.rs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/runtime/kusama/src/weights/runtime_common_crowdloan.rs b/runtime/kusama/src/weights/runtime_common_crowdloan.rs index 5e568bb64a95..0f4382bb1a16 100644 --- a/runtime/kusama/src/weights/runtime_common_crowdloan.rs +++ b/runtime/kusama/src/weights/runtime_common_crowdloan.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for runtime_common::crowdloan //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-18, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-06-24, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 // Executed Command: @@ -31,7 +31,7 @@ // --wasm-execution=compiled // --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/ +// --output=./runtime/kusama/src/weights/runtime_common_crowdloan.rs #![allow(unused_parens)] @@ -44,53 +44,53 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::crowdloan::WeightInfo for WeightInfo { fn create() -> Weight { - (84_286_000 as Weight) + (93_538_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn contribute() -> Weight { - (575_519_000 as Weight) + (581_495_000 as Weight) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn withdraw() -> Weight { - (111_859_000 as Weight) + (127_588_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn refund(k: u32, ) -> Weight { - (45_601_000 as Weight) - // Standard Error: 27_000 - .saturating_add((44_795_000 as Weight).saturating_mul(k as Weight)) + (0 as Weight) + // Standard Error: 52_000 + .saturating_add((56_719_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(k as Weight))) } fn dissolve() -> Weight { - (65_923_000 as Weight) + (68_758_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn edit() -> Weight { - (41_378_000 as Weight) + (42_049_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn add_memo() -> Weight { - (59_890_000 as Weight) + (65_306_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn poke() -> Weight { - (45_687_000 as Weight) + (51_610_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize(n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 20_000 - .saturating_add((106_096_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 32_000 + .saturating_add((131_978_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) From 8b6f38ebf2a2a72820109a315749660dde4990dc Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 24 Jun 2021 22:48:38 +0000 Subject: [PATCH 13/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::auctions --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_auctions.rs --- .../westend/src/weights/runtime_common_auctions.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/westend/src/weights/runtime_common_auctions.rs b/runtime/westend/src/weights/runtime_common_auctions.rs index 211df82e7010..c4d398faacd3 100644 --- a/runtime/westend/src/weights/runtime_common_auctions.rs +++ b/runtime/westend/src/weights/runtime_common_auctions.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for runtime_common::auctions //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-18, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-06-24, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: @@ -31,7 +31,7 @@ // --wasm-execution=compiled // --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/westend/src/weights/ +// --output=./runtime/westend/src/weights/runtime_common_auctions.rs #![allow(unused_parens)] @@ -44,22 +44,22 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::auctions::WeightInfo for WeightInfo { fn new_auction() -> Weight { - (23_671_000 as Weight) + (29_966_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn bid() -> Weight { - (134_592_000 as Weight) + (152_563_000 as Weight) .saturating_add(T::DbWeight::get().reads(8 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn on_initialize() -> Weight { - (23_367_994_000 as Weight) + (32_736_787_000 as Weight) .saturating_add(T::DbWeight::get().reads(3688 as Weight)) .saturating_add(T::DbWeight::get().writes(3683 as Weight)) } fn cancel_auction() -> Weight { - (4_894_434_000 as Weight) + (7_057_595_000 as Weight) .saturating_add(T::DbWeight::get().reads(73 as Weight)) .saturating_add(T::DbWeight::get().writes(3673 as Weight)) } From 4a196e287b3cd4f336ac7c574ff3a42d59c9a175 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Thu, 24 Jun 2021 23:42:38 +0000 Subject: [PATCH 14/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::crowdloan --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_crowdloan.rs --- .../src/weights/runtime_common_crowdloan.rs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/runtime/westend/src/weights/runtime_common_crowdloan.rs b/runtime/westend/src/weights/runtime_common_crowdloan.rs index 4a5531231d89..060e481ed66e 100644 --- a/runtime/westend/src/weights/runtime_common_crowdloan.rs +++ b/runtime/westend/src/weights/runtime_common_crowdloan.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for runtime_common::crowdloan //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-18, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-06-24, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: @@ -31,7 +31,7 @@ // --wasm-execution=compiled // --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/westend/src/weights/ +// --output=./runtime/westend/src/weights/runtime_common_crowdloan.rs #![allow(unused_parens)] @@ -44,53 +44,53 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::crowdloan::WeightInfo for WeightInfo { fn create() -> Weight { - (84_082_000 as Weight) + (95_715_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn contribute() -> Weight { - (478_991_000 as Weight) + (500_788_000 as Weight) .saturating_add(T::DbWeight::get().reads(7 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn withdraw() -> Weight { - (109_723_000 as Weight) + (127_448_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn refund(k: u32, ) -> Weight { - (38_261_000 as Weight) - // Standard Error: 39_000 - .saturating_add((43_247_000 as Weight).saturating_mul(k as Weight)) + (0 as Weight) + // Standard Error: 53_000 + .saturating_add((56_113_000 as Weight).saturating_mul(k as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(k as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(k as Weight))) } fn dissolve() -> Weight { - (64_812_000 as Weight) + (71_359_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn edit() -> Weight { - (40_331_000 as Weight) + (43_194_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn add_memo() -> Weight { - (58_745_000 as Weight) + (65_648_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn poke() -> Weight { - (45_385_000 as Weight) + (51_082_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize(n: u32, ) -> Weight { (0 as Weight) - // Standard Error: 22_000 - .saturating_add((103_814_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 31_000 + .saturating_add((134_501_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight))) .saturating_add(T::DbWeight::get().writes(3 as Weight)) From 649f0ff3368a3b810adcb8f9d7b1e7c263f7c561 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Fri, 25 Jun 2021 07:31:33 +0000 Subject: [PATCH 15/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::slots --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_slots.rs --- .../kusama/src/weights/runtime_common_slots.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/kusama/src/weights/runtime_common_slots.rs b/runtime/kusama/src/weights/runtime_common_slots.rs index d1665f2b1cd7..0762ded1a116 100644 --- a/runtime/kusama/src/weights/runtime_common_slots.rs +++ b/runtime/kusama/src/weights/runtime_common_slots.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for runtime_common::slots //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-18, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-06-25, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 // Executed Command: @@ -31,7 +31,7 @@ // --wasm-execution=compiled // --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/kusama/src/weights/ +// --output=./runtime/kusama/src/weights/runtime_common_slots.rs #![allow(unused_parens)] @@ -44,16 +44,16 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::slots::WeightInfo for WeightInfo { fn force_lease() -> Weight { - (44_787_000 as Weight) + (54_624_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn manage_lease_period_start(c: u32, t: u32, ) -> Weight { (0 as Weight) - // Standard Error: 15_000 - .saturating_add((14_770_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 15_000 - .saturating_add((32_752_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 36_000 + .saturating_add((19_526_000 as Weight).saturating_mul(c as Weight)) + // Standard Error: 36_000 + .saturating_add((42_887_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight))) @@ -62,12 +62,12 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (191_793_000 as Weight) + (230_377_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(9 as Weight)) } fn trigger_onboard() -> Weight { - (45_111_000 as Weight) + (45_884_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } From 54437cc913e77d538f9c369bc4b466f20091834e Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Fri, 25 Jun 2021 10:27:54 +0000 Subject: [PATCH 16/16] cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::slots --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_slots.rs --- .../src/weights/runtime_common_slots.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/westend/src/weights/runtime_common_slots.rs b/runtime/westend/src/weights/runtime_common_slots.rs index 425bfa8cc0af..4a9f022327e3 100644 --- a/runtime/westend/src/weights/runtime_common_slots.rs +++ b/runtime/westend/src/weights/runtime_common_slots.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for runtime_common::slots //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-18, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-06-25, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: @@ -31,7 +31,7 @@ // --wasm-execution=compiled // --heap-pages=4096 // --header=./file_header.txt -// --output=./runtime/westend/src/weights/ +// --output=./runtime/westend/src/weights/runtime_common_slots.rs #![allow(unused_parens)] @@ -44,16 +44,16 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl runtime_common::slots::WeightInfo for WeightInfo { fn force_lease() -> Weight { - (45_514_000 as Weight) + (53_939_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn manage_lease_period_start(c: u32, t: u32, ) -> Weight { (0 as Weight) - // Standard Error: 16_000 - .saturating_add((15_275_000 as Weight).saturating_mul(c as Weight)) - // Standard Error: 16_000 - .saturating_add((33_435_000 as Weight).saturating_mul(t as Weight)) + // Standard Error: 37_000 + .saturating_add((19_723_000 as Weight).saturating_mul(c as Weight)) + // Standard Error: 37_000 + .saturating_add((42_186_000 as Weight).saturating_mul(t as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight))) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight))) @@ -62,12 +62,12 @@ impl runtime_common::slots::WeightInfo for WeightInfo Weight { - (195_795_000 as Weight) + (249_570_000 as Weight) .saturating_add(T::DbWeight::get().reads(9 as Weight)) .saturating_add(T::DbWeight::get().writes(9 as Weight)) } fn trigger_onboard() -> Weight { - (43_567_000 as Weight) + (49_692_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) }