-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update benchmarks #790
base: develop
Are you sure you want to change the base?
Conversation
b342045
to
f123833
Compare
f123833
to
63bf5eb
Compare
// Implementation of `MembershipChanged` equivalent to using `()` but that | ||
// returns `Some(AccountId::new([0; 32]))` in `get_prime()` only when | ||
// benchmarking. TODO: Remove once we upgrade with a version containing the fix: https://github.com/paritytech/polkadot-sdk/pull/6439 | ||
pub struct MockMembershipChangedForBenchmarks; |
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.
We didn't have benchmarks for the tips membership instance, and once I added that I found a bug in the pallet that happens when using ()
for the MembershipChanged
implementation. The pallet will not require this anymore, but until we upgrade to a version with the fix, we need to provide an implementation that for benchmarks, always returns Some
as the prime member. So that's why we need this type.
|
||
frame_support::parameter_types! { | ||
pub const MaxBalance: crate::Balance = crate::Balance::max_value(); | ||
} | ||
|
||
/// Workaround for a bug in the benchmarking code around instances. | ||
/// Upstream fix PR: https://github.com/paritytech/polkadot-sdk/pull/6435 | ||
#[allow(unused_imports)] |
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.
See paritytech/polkadot-sdk#6435 for the issue and the fix.
[pallet_collective, Council] | ||
[pallet_technical_committee_collective, TechnicalCommittee] | ||
// pallet_membership instances | ||
[pallet_membership, TipsMembership] |
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.
We didn't run benchmarks for this instance at all before.
use frame_support::{traits::Get, weights::Weight}; | ||
use sp_std::marker::PhantomData; | ||
|
||
// TODO: Remove once the benchmarking stuff fully supports pallet instances. |
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.
Unfortunately this has to now be done by hand every time a weight file for a pallet instance is generated. We could use the pallets in the lib.rs
and simply use super::*
here, but I don't have a strong opinion about it.
Part of https://github.com/KILTprotocol/ticket/issues/3650, built on top of #787.
What started as a simple fix for the web3name pallet benchmarks, turned out to be a bigger changeset due to a couple of bugs found in the Substrate code, which are mentioned in the self-review I gave myself below.
In a gist, what I did is:
BenchmarkHelper
type.pallet_collective
andpallet_membership
pallets which we deploy multiple timespallet_membership
deployments of theTipsMembership
pallet