-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Do not make pallet-identity benchmarks signature-dependent #8179
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
Changes from all commits
f628b2c
8e54bb6
96f4ad7
4753d31
71bc451
63c1e13
00e81d4
be9c6ca
32cf21e
430f5de
24a3f45
7bb7da3
d001cb1
926e317
40eff65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
| # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
|
||
| title: Do not make pallet-identity benchmarks signature-dependent | ||
|
|
||
| doc: | ||
| - audience: Runtime Dev | ||
| description: | | ||
| - Includes a `BenchmarkHelper` configuration item in `pallet-identity` to handle signing operations. | ||
| - Abstracts away the explicit link with Sr25519 schema in the benchmarks, allowing chains with a different one to be able to run them and calculate the weights. | ||
| - Adds a default implementation for the empty tuple that leaves the code equivalent. | ||
|
|
||
| Adding the following to your implementation of the `frame_identity::Config` should be enough: | ||
| ```diff | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| type BenchmarkHelper = (); | ||
| ``` | ||
|
|
||
| crates: | ||
| - name: pallet-identity | ||
| bump: major | ||
| - name: polkadot-runtime-common | ||
| bump: patch | ||
| - name: westend-runtime | ||
| bump: patch | ||
| - name: rococo-runtime | ||
| bump: patch | ||
| - name: pallet-alliance | ||
| bump: patch | ||
| - name: people-rococo-runtime | ||
| bump: patch | ||
| - name: people-westend-runtime | ||
| bump: patch | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,26 @@ pub mod pallet { | |
| use super::*; | ||
| use frame_support::pallet_prelude::*; | ||
|
|
||
| #[cfg(feature = "runtime-benchmarks")] | ||
| pub trait BenchmarkHelper<Public, Signature> { | ||
| fn sign_message(message: &[u8]) -> (Public, Signature); | ||
| } | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| impl BenchmarkHelper<sp_runtime::MultiSigner, sp_runtime::MultiSignature> for () { | ||
| fn sign_message(message: &[u8]) -> (sp_runtime::MultiSigner, sp_runtime::MultiSignature) { | ||
| let public = sp_io::crypto::sr25519_generate(0.into(), None); | ||
| let signature = sp_runtime::MultiSignature::Sr25519( | ||
| sp_io::crypto::sr25519_sign( | ||
| 0.into(), | ||
| &public.into_account().try_into().unwrap(), | ||
| message, | ||
| ) | ||
| .unwrap(), | ||
| ); | ||
| (public.into(), signature) | ||
| } | ||
| } | ||
|
|
||
| #[pallet::config] | ||
| pub trait Config: frame_system::Config { | ||
| /// The overarching event type. | ||
|
|
@@ -227,6 +247,11 @@ pub mod pallet { | |
| #[pallet::constant] | ||
| type MaxUsernameLength: Get<u32>; | ||
|
|
||
| /// A set of helper functions for benchmarking. | ||
|
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. The comment normally goes above the feature gate. Can you also please include a line what the default config
Contributor
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. That was copy-pasted from elsewhere in the repository, so for sure there will be more cases around in other parts not covered in this PR. Just the heads up. Addressed in 7bb7da3.
Contributor
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.
Missed that part. Done in 926e317. |
||
| /// The default configuration `()` uses the `SR25519` signature schema. | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| type BenchmarkHelper: BenchmarkHelper<Self::SigningPublicKey, Self::OffchainSignature>; | ||
|
|
||
| /// Weight information for extrinsics in this pallet. | ||
| type WeightInfo: WeightInfo; | ||
| } | ||
|
|
||
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.
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.
Will add once we address my previous comment.
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.
Done in 63c1e13.