Fix Benchmark Regressions in Polkadot Parachain Auction System (#5139)

* integration tests use offset

* fix slots

* fix auctions

* add auctions benchmark

* fix crowdloan
This commit is contained in:
Shawn Tabrizi
2022-03-17 11:56:50 -04:00
committed by GitHub
parent 16fe04dc79
commit dd6fdf0f14
5 changed files with 52 additions and 15 deletions
+14 -2
View File
@@ -1772,6 +1772,10 @@ mod benchmarking {
// Worst case scenario a new bid comes in which kicks out an existing bid for the same slot.
bid {
// If there is an offset, we need to be on that block to be able to do lease things.
let (_, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration = T::BlockNumber::max_value();
let lease_period_index = LeasePeriodOf::<T>::zero();
@@ -1818,8 +1822,12 @@ mod benchmarking {
// Worst case: 10 bidders taking all wining spots, and we need to calculate the winner for auction end.
// Entire winner map should be full and removed at the end of the benchmark.
on_initialize {
// If there is an offset, we need to be on that block to be able to do lease things.
let (lease_length, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: T::BlockNumber = 99u32.into();
let duration: T::BlockNumber = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero();
let now = frame_system::Pallet::<T>::block_number();
Auctions::<T>::new_auction(RawOrigin::Root.into(), duration, lease_period_index)?;
@@ -1857,8 +1865,12 @@ mod benchmarking {
// Worst case: 10 bidders taking all wining spots, and winning data is full.
cancel_auction {
// If there is an offset, we need to be on that block to be able to do lease things.
let (lease_length, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: T::BlockNumber = 99u32.into();
let duration: T::BlockNumber = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero();
let now = frame_system::Pallet::<T>::block_number();
Auctions::<T>::new_auction(RawOrigin::Root.into(), duration, lease_period_index)?;