Fix new_session
benchmark in pallet_collator_selection
#3189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue was discovered by enabling async backing on all parachains in this PR.
The reason it happened is because with the move to async backing, the
DAYS
andHOURS
constants doubled compared to the previously imported values from parachain_common, which led to thePeriod
doubling. This matters because inpallet_collator_selection::Config
, the allowed period of inactivity for collators is aPeriod
. When a new session is initialized, candidates which don't meet the criteria here are removed.The benchmark code hardcoded the last active block value which is safe from kick to the pervious value of a period,
1800
, with the chain starting at0
. When running the check,KickThreshold
was1800
, so it would pass, but it obviously doesn't work if thePeriod
isn't1800
.This PR fixes the benchmark by setting the
new_block
value toT::KickThreshold::get()
, which will work for any chosenPeriod
.Opening this PR against the original branch to expedite the merge.