-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 3 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,15 @@ | ||
| # 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. | ||
|
|
||
| crates: | ||
| - name: pallet-identity | ||
| bump: minor | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -150,6 +150,32 @@ pub mod pallet { | |||||||||||||
| use super::*; | ||||||||||||||
| use frame_support::pallet_prelude::*; | ||||||||||||||
|
|
||||||||||||||
| #[cfg(feature = "runtime-benchmarks")] | ||||||||||||||
| pub trait BenchmarkHelper<Public, AccountId, Signature> { | ||||||||||||||
| fn signer() -> (Public, AccountId); | ||||||||||||||
| fn sign(signer: &Public, message: &[u8]) -> Signature; | ||||||||||||||
|
||||||||||||||
| fn signer() -> (Public, AccountId); | |
| fn sign(signer: &Public, message: &[u8]) -> Signature; | |
| /// Sign the given `message` with a random account. | |
| /// | |
| /// Should return the public key of this random account and the signature. | |
| fn sign_message(message: &[u8]) -> (Public, Signature); |
Just make this one function. In the benchmarking code you can get the AccountId by calling into_account on the public_key.
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.
I get the intention of reducing the interface to only one function, but still I don't like the idea, mainly because:
- Again it differs from
pallet-nftsequivalent code. - This prevents from signing twice with the exact same account. Not that it's needed now but adds unnecessary constrains that might bite devs in future iterations of the pallet and likely force to revert the changes and introduce extra noise.
Just my two cents. If you still prefer your proposed approach I'll happily change it, but I thought it was worth discussing.
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 00e81d4.
Outdated
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.
| type Helper: BenchmarkHelper< | |
| type BenchmarkHelper: ::BenchmarkHelper< |
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.
I do not have a preference at all on how to name this parameter, but in pallet-nfts it's named Helper, so I thought out of consistency it should be named the same. Just to confirm.
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.
BenchmarkHelper is more expressive.
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.
And we also have a lot of other pallets naming it BenchmarkHelper.
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.
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.