diff --git a/pallets/shield/src/benchmarking.rs b/pallets/shield/src/benchmarking.rs index a88061287e..1414779314 100644 --- a/pallets/shield/src/benchmarking.rs +++ b/pallets/shield/src/benchmarking.rs @@ -3,16 +3,15 @@ use super::*; use frame_benchmarking::v2::*; use frame_support::{BoundedVec, pallet_prelude::ConstU32}; use frame_system::{RawOrigin, pallet_prelude::BlockNumberFor}; -use sp_core::{crypto::KeyTypeId, sr25519}; -use sp_io::crypto::sr25519_generate; -use sp_runtime::{AccountId32, traits::Hash as HashT}; +use sp_core::sr25519; +use sp_runtime::traits::Hash as HashT; use sp_std::vec; -/// Helper to build bounded bytes (public key) of a given length. -fn bounded_pk(len: usize) -> BoundedVec> { - let v = vec![7u8; len]; - BoundedVec::>::try_from(v).expect("within bound; qed") -} +// /// Helper to build bounded bytes (public key) of a given length. +// fn bounded_pk(len: usize) -> BoundedVec> { +// let v = vec![7u8; len]; +// BoundedVec::>::try_from(v).expect("within bound; qed") +// } /// Helper to build bounded bytes (ciphertext) of a given length. fn bounded_ct(len: usize) -> BoundedVec> { @@ -20,20 +19,20 @@ fn bounded_ct(len: usize) -> BoundedVec> { BoundedVec::>::try_from(v).expect("within bound; qed") } -/// Seed Aura authorities so `EnsureAuraAuthority` passes for a given sr25519 pubkey. -/// -/// We avoid requiring `ByteArray` on `AuthorityId` by relying on: -/// `::AuthorityId: From`. -fn seed_aura_authority_from_sr25519(pubkey: &sr25519::Public) -where - T: pallet::Config + pallet_aura::Config, - ::AuthorityId: From, -{ - let auth_id: ::AuthorityId = (*pubkey).into(); - pallet_aura::Authorities::::mutate(|auths| { - let _ = auths.try_push(auth_id); - }); -} +// /// Seed Aura authorities so `EnsureAuraAuthority` passes for a given sr25519 pubkey. +// /// +// /// We avoid requiring `ByteArray` on `AuthorityId` by relying on: +// /// `::AuthorityId: From`. +// fn seed_aura_authority_from_sr25519(pubkey: &sr25519::Public) +// where +// T: pallet::Config + pallet_aura::Config, +// ::AuthorityId: From, +// { +// let auth_id: ::AuthorityId = (*pubkey).into(); +// pallet_aura::Authorities::::mutate(|auths| { +// let _ = auths.try_push(auth_id); +// }); +// } #[benchmarks( where @@ -45,30 +44,31 @@ where mod benches { use super::*; - /// Benchmark `announce_next_key`. - #[benchmark] - fn announce_next_key() { - // Generate a deterministic dev key in the host keystore (for benchmarks). - // Any 4-byte KeyTypeId works for generation; it does not affect AccountId derivation. - const KT: KeyTypeId = KeyTypeId(*b"benc"); - let alice_pub: sr25519::Public = sr25519_generate(KT, Some("//Alice".as_bytes().to_vec())); - let alice_acc: AccountId32 = alice_pub.into(); - - // Make this account an Aura authority for the generic runtime. - seed_aura_authority_from_sr25519::(&alice_pub); - - // Valid Kyber768 public key length per pallet check. - const KYBER768_PK_LEN: usize = 1184; - let public_key: BoundedVec> = bounded_pk::<2048>(KYBER768_PK_LEN); - - // Measure: dispatch the extrinsic. - #[extrinsic_call] - announce_next_key(RawOrigin::Signed(alice_acc.clone()), public_key.clone()); - - // Assert: NextKey should be set exactly. - let stored = NextKey::::get().expect("must be set by announce_next_key"); - assert_eq!(stored, public_key); - } + // We use the custom value for announce_next_key to charge a higher fee, not the benchmark result. + // /// Benchmark `announce_next_key`. + // #[benchmark] + // fn announce_next_key() { + // // Generate a deterministic dev key in the host keystore (for benchmarks). + // // Any 4-byte KeyTypeId works for generation; it does not affect AccountId derivation. + // const KT: KeyTypeId = KeyTypeId(*b"benc"); + // let alice_pub: sr25519::Public = sr25519_generate(KT, Some("//Alice".as_bytes().to_vec())); + // let alice_acc: AccountId32 = alice_pub.into(); + + // // Make this account an Aura authority for the generic runtime. + // seed_aura_authority_from_sr25519::(&alice_pub); + + // // Valid Kyber768 public key length per pallet check. + // const KYBER768_PK_LEN: usize = 1184; + // let public_key: BoundedVec> = bounded_pk::<2048>(KYBER768_PK_LEN); + + // // Measure: dispatch the extrinsic. + // #[extrinsic_call] + // announce_next_key(RawOrigin::Signed(alice_acc.clone()), public_key.clone()); + + // // Assert: NextKey should be set exactly. + // let stored = NextKey::::get().expect("must be set by announce_next_key"); + // assert_eq!(stored, public_key); + // } /// Benchmark `submit_encrypted`. #[benchmark] diff --git a/pallets/shield/src/lib.rs b/pallets/shield/src/lib.rs index 22cf3240a1..eed0161f20 100644 --- a/pallets/shield/src/lib.rs +++ b/pallets/shield/src/lib.rs @@ -247,7 +247,7 @@ pub mod pallet { /// the following block. #[pallet::call_index(0)] #[pallet::weight(( - Weight::from_parts(9_979_000, 0) + Weight::from_parts(20_999_999_999, 0) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 48e49b76c9..1af76d502b 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -241,7 +241,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 366, + spec_version: 367, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,