@@ -3,37 +3,36 @@ use super::*;
33use frame_benchmarking:: v2:: * ;
44use frame_support:: { BoundedVec , pallet_prelude:: ConstU32 } ;
55use frame_system:: { RawOrigin , pallet_prelude:: BlockNumberFor } ;
6- use sp_core:: { crypto:: KeyTypeId , sr25519} ;
7- use sp_io:: crypto:: sr25519_generate;
8- use sp_runtime:: { AccountId32 , traits:: Hash as HashT } ;
6+ use sp_core:: sr25519;
7+ use sp_runtime:: traits:: Hash as HashT ;
98use sp_std:: vec;
109
11- /// Helper to build bounded bytes (public key) of a given length.
12- fn bounded_pk < const N : u32 > ( len : usize ) -> BoundedVec < u8 , ConstU32 < N > > {
13- let v = vec ! [ 7u8 ; len] ;
14- BoundedVec :: < u8 , ConstU32 < N > > :: try_from ( v) . expect ( "within bound; qed" )
15- }
10+ // // / Helper to build bounded bytes (public key) of a given length.
11+ // fn bounded_pk<const N: u32>(len: usize) -> BoundedVec<u8, ConstU32<N>> {
12+ // let v = vec![7u8; len];
13+ // BoundedVec::<u8, ConstU32<N>>::try_from(v).expect("within bound; qed")
14+ // }
1615
1716/// Helper to build bounded bytes (ciphertext) of a given length.
1817fn bounded_ct < const N : u32 > ( len : usize ) -> BoundedVec < u8 , ConstU32 < N > > {
1918 let v = vec ! [ 0u8 ; len] ;
2019 BoundedVec :: < u8 , ConstU32 < N > > :: try_from ( v) . expect ( "within bound; qed" )
2120}
2221
23- /// Seed Aura authorities so `EnsureAuraAuthority` passes for a given sr25519 pubkey.
24- ///
25- /// We avoid requiring `ByteArray` on `AuthorityId` by relying on:
26- /// `<T as pallet_aura::Config>::AuthorityId: From<sr25519::Public>`.
27- fn seed_aura_authority_from_sr25519 < T > ( pubkey : & sr25519:: Public )
28- where
29- T : pallet:: Config + pallet_aura:: Config ,
30- <T as pallet_aura:: Config >:: AuthorityId : From < sr25519:: Public > ,
31- {
32- let auth_id: <T as pallet_aura:: Config >:: AuthorityId = ( * pubkey) . into ( ) ;
33- pallet_aura:: Authorities :: < T > :: mutate ( |auths| {
34- let _ = auths. try_push ( auth_id) ;
35- } ) ;
36- }
22+ // // / Seed Aura authorities so `EnsureAuraAuthority` passes for a given sr25519 pubkey.
23+ // // /
24+ // // / We avoid requiring `ByteArray` on `AuthorityId` by relying on:
25+ // // / `<T as pallet_aura::Config>::AuthorityId: From<sr25519::Public>`.
26+ // fn seed_aura_authority_from_sr25519<T>(pubkey: &sr25519::Public)
27+ // where
28+ // T: pallet::Config + pallet_aura::Config,
29+ // <T as pallet_aura::Config>::AuthorityId: From<sr25519::Public>,
30+ // {
31+ // let auth_id: <T as pallet_aura::Config>::AuthorityId = (*pubkey).into();
32+ // pallet_aura::Authorities::<T>::mutate(|auths| {
33+ // let _ = auths.try_push(auth_id);
34+ // });
35+ // }
3736
3837#[ benchmarks(
3938 where
@@ -45,30 +44,31 @@ where
4544mod benches {
4645 use super :: * ;
4746
48- /// Benchmark `announce_next_key`.
49- #[ benchmark]
50- fn announce_next_key ( ) {
51- // Generate a deterministic dev key in the host keystore (for benchmarks).
52- // Any 4-byte KeyTypeId works for generation; it does not affect AccountId derivation.
53- const KT : KeyTypeId = KeyTypeId ( * b"benc" ) ;
54- let alice_pub: sr25519:: Public = sr25519_generate ( KT , Some ( "//Alice" . as_bytes ( ) . to_vec ( ) ) ) ;
55- let alice_acc: AccountId32 = alice_pub. into ( ) ;
56-
57- // Make this account an Aura authority for the generic runtime.
58- seed_aura_authority_from_sr25519 :: < T > ( & alice_pub) ;
59-
60- // Valid Kyber768 public key length per pallet check.
61- const KYBER768_PK_LEN : usize = 1184 ;
62- let public_key: BoundedVec < u8 , ConstU32 < 2048 > > = bounded_pk :: < 2048 > ( KYBER768_PK_LEN ) ;
63-
64- // Measure: dispatch the extrinsic.
65- #[ extrinsic_call]
66- announce_next_key ( RawOrigin :: Signed ( alice_acc. clone ( ) ) , public_key. clone ( ) ) ;
67-
68- // Assert: NextKey should be set exactly.
69- let stored = NextKey :: < T > :: get ( ) . expect ( "must be set by announce_next_key" ) ;
70- assert_eq ! ( stored, public_key) ;
71- }
47+ // We use the custom value for announce_next_key to charge a higher fee, not the benchmark result.
48+ // /// Benchmark `announce_next_key`.
49+ // #[benchmark]
50+ // fn announce_next_key() {
51+ // // Generate a deterministic dev key in the host keystore (for benchmarks).
52+ // // Any 4-byte KeyTypeId works for generation; it does not affect AccountId derivation.
53+ // const KT: KeyTypeId = KeyTypeId(*b"benc");
54+ // let alice_pub: sr25519::Public = sr25519_generate(KT, Some("//Alice".as_bytes().to_vec()));
55+ // let alice_acc: AccountId32 = alice_pub.into();
56+
57+ // // Make this account an Aura authority for the generic runtime.
58+ // seed_aura_authority_from_sr25519::<T>(&alice_pub);
59+
60+ // // Valid Kyber768 public key length per pallet check.
61+ // const KYBER768_PK_LEN: usize = 1184;
62+ // let public_key: BoundedVec<u8, ConstU32<2048>> = bounded_pk::<2048>(KYBER768_PK_LEN);
63+
64+ // // Measure: dispatch the extrinsic.
65+ // #[extrinsic_call]
66+ // announce_next_key(RawOrigin::Signed(alice_acc.clone()), public_key.clone());
67+
68+ // // Assert: NextKey should be set exactly.
69+ // let stored = NextKey::<T>::get().expect("must be set by announce_next_key");
70+ // assert_eq!(stored, public_key);
71+ // }
7272
7373 /// Benchmark `submit_encrypted`.
7474 #[ benchmark]
0 commit comments