Skip to content

Conversation

@moliholy
Copy link
Contributor

@moliholy moliholy commented Apr 8, 2025

Similar to #4756 for pallet-nfts, the changes proposed in this PR intend to make benchmarks for pallet-identity signature-agnostic by the inclusion of a benchmark helper with sane defaults to handle the signing operations.

@moliholy moliholy requested a review from a team as a code owner April 8, 2025 10:35
@moliholy moliholy changed the title Make pallet-identity benchmarks generic Do not make pallet-identity benchmarks signature-dependent Apr 8, 2025

#[cfg(feature = "runtime-benchmarks")]
/// A set of helper functions for benchmarking.
type Helper: BenchmarkHelper<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type Helper: BenchmarkHelper<
type BenchmarkHelper: ::BenchmarkHelper<

Copy link
Contributor Author

@moliholy moliholy Apr 8, 2025

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BenchmarkHelper is more expressive.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 63c1e13.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Adds a default implementation for the empty tuple that leaves the code equivalent.
- 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 = ();
```

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 63c1e13.

Comment on lines 155 to 156
fn signer() -> (Public, AccountId);
fn sign(signer: &Public, message: &[u8]) -> Signature;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

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:

  1. Again it differs from pallet-nfts equivalent code.
  2. 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 00e81d4.

@paritytech-review-bot paritytech-review-bot bot requested a review from a team April 14, 2025 11:59
@moliholy
Copy link
Contributor Author

@bkchr everything addressed.

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@bkchr bkchr added the T2-pallets This PR/Issue is related to a particular pallet. label Apr 14, 2025
@bkchr bkchr requested a review from ggwpez April 14, 2025 21:07
@moliholy
Copy link
Contributor Author

moliholy commented May 5, 2025

@ggwpez just a friendly ping 😄

@moliholy
Copy link
Contributor Author

@bkchr just another friendly ping 🙏


crates:
- name: pallet-identity
bump: patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a config item is a breaking change though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addrressed in 7bb7da3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI says otherwise, by the way.

type MaxUsernameLength: Get<u32>;

#[cfg(feature = "runtime-benchmarks")]
/// A set of helper functions for benchmarking.
Copy link
Member

Choose a reason for hiding this comment

The 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 () means?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also please include a line what the default config () means?

Missed that part. Done in 926e317.

Copy link
Member

@ggwpez ggwpez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good modulo the comments, thanks.

@bkchr
Copy link
Member

bkchr commented Jun 3, 2025

@moliholy ping

@moliholy moliholy force-pushed the feat/identity-benchmarks-generic branch from b6e3da0 to 7bb7da3 Compare June 3, 2025 11:57
@moliholy
Copy link
Contributor Author

moliholy commented Jun 3, 2025

@ggwpez thanks for the review! Everything addressed.

@bkchr ping received. Ready to merge 🚀

@bkchr bkchr added this pull request to the merge queue Jun 5, 2025
Merged via the queue into paritytech:master with commit 6cb6f5b Jun 5, 2025
274 of 277 checks passed
@moliholy moliholy deleted the feat/identity-benchmarks-generic branch June 6, 2025 08:29
pgherveou pushed a commit that referenced this pull request Jun 11, 2025
Similar to #4756 for `pallet-nfts`, the changes proposed in this PR
intend to make benchmarks for `pallet-identity` signature-agnostic by
the inclusion of a benchmark helper with sane defaults to handle the
signing operations.
ordian added a commit that referenced this pull request Jun 12, 2025
* master: (62 commits)
  release/build-macos-binaries: add missing FEATURES argument  (#8816)
  Add XCM Precompile to `pallet-xcm` (#8693)
  [Release|CI/CD] Exclude test runtimes from the runtimes build (#8820)
  Add freebsd sysinfo for telemetry (#7985)
  release-reusable-rc-build: add optional `features` input that can be considered for nodes building (#8755)
  [Staking] Cleanups and some improvements (#8701)
  Fix typos in 3 files in Implementers Guide (#8799)
  Update `RemoteExporter` docs to reflect removal of `forward_id_for` (#8795)
  Snowbridge: enforce fee when registering Polkadot native asset (#8725)
  Bump the ci_dependencies group across 1 directory with 7 updates (#8788)
  Docker hub 'master' image short sha (#8790)
  [Release|CI/CD] Combine branch-off and RC automation flows (#8754)
  Move Transaction depth limit checks (#8750)
  Add genesis presets for remaining runtimes in polkadot-parachain-bin (#8426)
  Do not make pallet-identity benchmarks signature-dependent (#8179)
  Introduction of Approval Slashes [Disabling Strategy Stage 4] (#6827)
  [AHM] Prepare For Westend Cleanup (#8715)
  Actually use RP offset in YAP parachain (#8745)
  [AHM] Relax the requirement for RC-Client to receive +1 session reports (#8702)
  Don't read storage items in logging (#8749)
  ...
EgorPopelyaev added a commit that referenced this pull request Jul 25, 2025
Backport #8179 into
stable2412.

This is to allow runtimes in `stable2412` that don't use SR25519 to
correctly benchmark `pallet-identity`

---------

Co-authored-by: Egor_P <[email protected]>
fellowship-merge-bot bot pushed a commit to polkadot-fellows/runtimes that referenced this pull request Aug 7, 2025
This brings in `stable2506` Polkadot SDK, and integrates many new
features.

Integrated breaking changes to be verified by the original authors:

- [x] ~paritytech/polkadot-sdk#8127 @kianenigma
@Ank4n~
     This will come in with AHM, and not before.
- [x] paritytech/polkadot-sdk#7597 @gui1117 
- [x] paritytech/polkadot-sdk#8254 @bkchr 
- [x] paritytech/polkadot-sdk#7592 @bkontur 
- [x] paritytech/polkadot-sdk#8382
@UtkarshBhardwaj007
- [x] paritytech/polkadot-sdk#8021 @serban300 
- [x] paritytech/polkadot-sdk#8344 @serban300 
- [x] paritytech/polkadot-sdk#8262 @athei 
- [x] paritytech/polkadot-sdk#8584 @athei 
- [x] paritytech/polkadot-sdk#8299 @skunert
- [x] paritytech/polkadot-sdk#8652 @pgherveou 
- [x] paritytech/polkadot-sdk#8554 @pgherveou 
- [x] paritytech/polkadot-sdk#8281 @mrshiposha 
- [x] paritytech/polkadot-sdk#7730
@franciscoaguirre
- [x] paritytech/polkadot-sdk#8599 @yrong
@claravanstaden
- [x] paritytech/polkadot-sdk#8531 @bkontur 
- [x] paritytech/polkadot-sdk#8409 @kianenigma 
- [x] paritytech/polkadot-sdk#9137
@franciscoaguirre
- [x] paritytech/polkadot-sdk#7944 @bkontur 
- [x] paritytech/polkadot-sdk#8179 @bkontur 
- [x] paritytech/polkadot-sdk#8037 @yrong

---------

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: claravanstaden <[email protected]>
Co-authored-by: Branislav Kontur <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Alain Brenzikofer <[email protected]>
Co-authored-by: kianenigma <[email protected]>
Co-authored-by: Francisco Aguirre <[email protected]>
Co-authored-by: ron <[email protected]>
Co-authored-by: joe petrowski <[email protected]>
Co-authored-by: Overkillus <[email protected]>
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
Similar to #4756 for `pallet-nfts`, the changes proposed in this PR
intend to make benchmarks for `pallet-identity` signature-agnostic by
the inclusion of a benchmark helper with sane defaults to handle the
signing operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T2-pallets This PR/Issue is related to a particular pallet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants