This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Tips Benchmarking to be Runtime Agnostic #10368
Merged
paritytech-processbot
merged 4 commits into
paritytech:master
from
ferrell-code:fer-tips-benchmark
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,20 +84,17 @@ fn setup_pot_account<T: Config>() { | |
| let _ = T::Currency::make_free_balance_be(&pot_account, value); | ||
| } | ||
|
|
||
| const MAX_BYTES: u32 = 16384; | ||
| const MAX_TIPPERS: u32 = 100; | ||
|
|
||
| benchmarks! { | ||
| report_awesome { | ||
| let r in 0 .. MAX_BYTES; | ||
| let r in 0 .. T::MaximumReasonLength::get(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly I think we should say something in the doc |
||
| let (caller, reason, awesome_person) = setup_awesome::<T>(r); | ||
| // Whitelist caller account from further DB operations. | ||
| let caller_key = frame_system::Account::<T>::hashed_key_for(&caller); | ||
| frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into()); | ||
| }: _(RawOrigin::Signed(caller), reason, awesome_person) | ||
|
|
||
| retract_tip { | ||
| let r = MAX_BYTES; | ||
| let r = T::MaximumReasonLength::get(); | ||
| let (caller, reason, awesome_person) = setup_awesome::<T>(r); | ||
| TipsMod::<T>::report_awesome( | ||
| RawOrigin::Signed(caller.clone()).into(), | ||
|
|
@@ -112,8 +109,8 @@ benchmarks! { | |
| }: _(RawOrigin::Signed(caller), hash) | ||
|
|
||
| tip_new { | ||
| let r in 0 .. MAX_BYTES; | ||
| let t in 1 .. MAX_TIPPERS; | ||
| let r in 0 .. T::MaximumReasonLength::get(); | ||
| let t in 1 .. T::Tippers::max_len() as u32; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe it also worth mentionning it that ContainsLengthBound::max_len implementation of Tippers is used in benchmark. |
||
|
|
||
| let (caller, reason, beneficiary, value) = setup_tip::<T>(r, t)?; | ||
| // Whitelist caller account from further DB operations. | ||
|
|
@@ -122,7 +119,7 @@ benchmarks! { | |
| }: _(RawOrigin::Signed(caller), reason, beneficiary, value) | ||
|
|
||
| tip { | ||
| let t in 1 .. MAX_TIPPERS; | ||
| let t in 1 .. T::Tippers::max_len() as u32; | ||
| let (member, reason, beneficiary, value) = setup_tip::<T>(0, t)?; | ||
| let value = T::Currency::minimum_balance().saturating_mul(100u32.into()); | ||
| TipsMod::<T>::tip_new( | ||
|
|
@@ -142,7 +139,7 @@ benchmarks! { | |
| }: _(RawOrigin::Signed(caller), hash, value) | ||
|
|
||
| close_tip { | ||
| let t in 1 .. MAX_TIPPERS; | ||
| let t in 1 .. T::Tippers::max_len() as u32; | ||
|
|
||
| // Make sure pot is funded | ||
| setup_pot_account::<T>(); | ||
|
|
@@ -171,7 +168,7 @@ benchmarks! { | |
| }: _(RawOrigin::Signed(caller), hash) | ||
|
|
||
| slash_tip { | ||
| let t in 1 .. MAX_TIPPERS; | ||
| let t in 1 .. T::Tippers::max_len() as u32; | ||
|
|
||
| // Make sure pot is funded | ||
| setup_pot_account::<T>(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should add in the doc of MaximumReasonLength that this value is used in benchmark, so changing it requires running the benchmark again.
(so it can't be changed without runtime upgrade).