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
Add Weightless benchmark bailing
#12829
Merged
Merged
Changes from 2 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 |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
|
|
||
| use super::*; | ||
|
|
||
| use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller}; | ||
| use frame_benchmarking::{account, benchmarks_instance_pallet, whitelisted_caller, BenchmarkError}; | ||
| use frame_system::RawOrigin; | ||
| use sp_runtime::traits::Bounded; | ||
|
|
||
|
|
@@ -31,13 +31,14 @@ use pallet_treasury::Pallet as Treasury; | |
| const SEED: u32 = 0; | ||
|
|
||
| // Create bounties that are approved for use in `on_initialize`. | ||
| fn create_approved_bounties<T: Config<I>, I: 'static>(n: u32) -> Result<(), &'static str> { | ||
| fn create_approved_bounties<T: Config<I>, I: 'static>(n: u32) -> Result<(), BenchmarkError> { | ||
| for i in 0..n { | ||
| let (caller, _curator, _fee, value, reason) = | ||
| setup_bounty::<T, I>(i, T::MaximumReasonLength::get()); | ||
| Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?; | ||
| let bounty_id = BountyCount::<T, I>::get() - 1; | ||
| let approve_origin = T::ApproveOrigin::successful_origin(); | ||
| let approve_origin = | ||
| T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
|
Member
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. We should probably change all benchmarking code to use
Member
Author
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. Yes eventually… this was an oversight when originally writing them. |
||
| Bounties::<T, I>::approve_bounty(approve_origin, bounty_id)?; | ||
| } | ||
| ensure!(BountyApprovals::<T, I>::get().len() == n as usize, "Not all bounty approved"); | ||
|
|
@@ -62,13 +63,14 @@ fn setup_bounty<T: Config<I>, I: 'static>( | |
| } | ||
|
|
||
| fn create_bounty<T: Config<I>, I: 'static>( | ||
| ) -> Result<(AccountIdLookupOf<T>, BountyIndex), &'static str> { | ||
| ) -> Result<(AccountIdLookupOf<T>, BountyIndex), BenchmarkError> { | ||
| let (caller, curator, fee, value, reason) = | ||
| setup_bounty::<T, I>(0, T::MaximumReasonLength::get()); | ||
| let curator_lookup = T::Lookup::unlookup(curator.clone()); | ||
| Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?; | ||
| let bounty_id = BountyCount::<T, I>::get() - 1; | ||
| let approve_origin = T::ApproveOrigin::successful_origin(); | ||
| let approve_origin = | ||
| T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
| Bounties::<T, I>::approve_bounty(approve_origin.clone(), bounty_id)?; | ||
| Treasury::<T, I>::on_initialize(T::BlockNumber::zero()); | ||
| Bounties::<T, I>::propose_curator(approve_origin, bounty_id, curator_lookup.clone(), fee)?; | ||
|
|
@@ -97,7 +99,7 @@ benchmarks_instance_pallet! { | |
| let (caller, curator, fee, value, reason) = setup_bounty::<T, I>(0, T::MaximumReasonLength::get()); | ||
| Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?; | ||
| let bounty_id = BountyCount::<T, I>::get() - 1; | ||
| let approve_origin = T::SpendOrigin::successful_origin(); | ||
| let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
| }: _<T::RuntimeOrigin>(approve_origin, bounty_id) | ||
|
|
||
| propose_curator { | ||
|
|
@@ -106,10 +108,9 @@ benchmarks_instance_pallet! { | |
| let curator_lookup = T::Lookup::unlookup(curator); | ||
| Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?; | ||
| let bounty_id = BountyCount::<T, I>::get() - 1; | ||
| let approve_origin = T::SpendOrigin::successful_origin(); | ||
| Bounties::<T, I>::approve_bounty(approve_origin, bounty_id)?; | ||
| let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
| Bounties::<T, I>::approve_bounty(approve_origin.clone(), bounty_id)?; | ||
| Treasury::<T, I>::on_initialize(T::BlockNumber::zero()); | ||
| let approve_origin = T::SpendOrigin::successful_origin(); | ||
| }: _<T::RuntimeOrigin>(approve_origin, bounty_id, curator_lookup, fee) | ||
|
|
||
| // Worst case when curator is inactive and any sender unassigns the curator. | ||
|
|
@@ -128,7 +129,7 @@ benchmarks_instance_pallet! { | |
| let curator_lookup = T::Lookup::unlookup(curator.clone()); | ||
| Bounties::<T, I>::propose_bounty(RawOrigin::Signed(caller).into(), value, reason)?; | ||
| let bounty_id = BountyCount::<T, I>::get() - 1; | ||
| let approve_origin = T::SpendOrigin::successful_origin(); | ||
| let approve_origin = T::SpendOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; | ||
| Bounties::<T, I>::approve_bounty(approve_origin.clone(), bounty_id)?; | ||
| Treasury::<T, I>::on_initialize(T::BlockNumber::zero()); | ||
| Bounties::<T, I>::propose_curator(approve_origin, bounty_id, curator_lookup, fee)?; | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.