-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pallet-proofs): add benchmarks (#657)
- Loading branch information
1 parent
1f404ac
commit 81d899e
Showing
11 changed files
with
193 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#![cfg(feature = "runtime-benchmarks")] | ||
|
||
use frame_benchmarking::v2::*; | ||
use frame_system::RawOrigin; | ||
|
||
use super::*; | ||
#[allow(unused)] | ||
use crate::Pallet as ProofsPallet; | ||
|
||
#[frame_benchmarking::v2::benchmarks( | ||
where T: crate::Config | ||
)] | ||
mod benchmarks { | ||
use rand::SeedableRng; | ||
use rand_xorshift::XorShiftRng; | ||
|
||
use super::*; | ||
use crate::crypto::groth16::{Bls12, VerifyingKey}; | ||
|
||
// Copies from the tests module to simplify imports, etc | ||
const TEST_SEED: [u8; 16] = [ | ||
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06, 0xbc, | ||
0xe5, | ||
]; | ||
|
||
#[benchmark] | ||
fn set_porep_verifying_key() { | ||
let mut rng = XorShiftRng::from_seed(TEST_SEED); | ||
let vkey = VerifyingKey::<Bls12>::random(&mut rng); | ||
let mut vkey_bytes = vec![0u8; vkey.serialised_bytes()]; | ||
vkey.clone() | ||
.into_bytes(&mut vkey_bytes.as_mut_slice()) | ||
.unwrap(); | ||
|
||
#[extrinsic_call] | ||
_(RawOrigin::Signed(whitelisted_caller()), vkey_bytes); | ||
|
||
assert!(PoRepVerifyingKey::<T>::get().is_some()); | ||
} | ||
|
||
#[benchmark] | ||
fn set_post_verifying_key() { | ||
let mut rng = XorShiftRng::from_seed(TEST_SEED); | ||
let vkey = VerifyingKey::<Bls12>::random(&mut rng); | ||
let mut vkey_bytes = vec![0u8; vkey.serialised_bytes()]; | ||
vkey.clone() | ||
.into_bytes(&mut vkey_bytes.as_mut_slice()) | ||
.unwrap(); | ||
|
||
#[extrinsic_call] | ||
_(RawOrigin::Signed(whitelisted_caller()), vkey_bytes); | ||
|
||
assert!(PoStVerifyingKey::<T>::get().is_some()); | ||
} | ||
|
||
impl_benchmark_test_suite! { | ||
ProofsPallet, | ||
crate::mock::new_test_ext(), | ||
crate::mock::Test, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
//! Autogenerated weights for `pallet_proofs` | ||
//! | ||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 | ||
//! DATE: 2024-12-23, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` | ||
//! WORST CASE MAP SIZE: `1000000` | ||
//! HOSTNAME: `parthenon`, CPU: `12th Gen Intel(R) Core(TM) i7-12700H` | ||
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024 | ||
// Executed Command: | ||
// target/release/polka-storage-node | ||
// benchmark | ||
// pallet | ||
// --wasm-execution=compiled | ||
// --pallet | ||
// pallet_proofs | ||
// --extrinsic | ||
// * | ||
// --steps | ||
// 50 | ||
// --repeat | ||
// 20 | ||
// --output | ||
// pallets/proofs/weights.rs | ||
// --template | ||
// node/benchmark_template.hbs | ||
|
||
#![cfg_attr(rustfmt, rustfmt_skip)] | ||
#![allow(unused_parens)] | ||
#![allow(unused_imports)] | ||
#![allow(missing_docs)] | ||
|
||
use frame_support::{traits::Get, weights::Weight}; | ||
use core::marker::PhantomData; | ||
|
||
pub trait WeightInfo { | ||
fn set_porep_verifying_key() -> Weight; | ||
fn set_post_verifying_key() -> Weight; | ||
} | ||
|
||
/// Weight functions for `pallet_proofs`. | ||
pub struct Weights<T>(PhantomData<T>); | ||
impl<T: frame_system::Config> WeightInfo for Weights<T> { | ||
/// Storage: `Proofs::PoRepVerifyingKey` (r:0 w:1) | ||
/// Proof: `Proofs::PoRepVerifyingKey` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) | ||
fn set_porep_verifying_key() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 9_847_752_000 picoseconds. | ||
Weight::from_parts(10_481_480_000, 0) | ||
.saturating_add(Weight::from_parts(0, 0)) | ||
.saturating_add(T::DbWeight::get().writes(1)) | ||
} | ||
/// Storage: `Proofs::PoStVerifyingKey` (r:0 w:1) | ||
/// Proof: `Proofs::PoStVerifyingKey` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) | ||
fn set_post_verifying_key() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 9_854_299_000 picoseconds. | ||
Weight::from_parts(10_455_634_000, 0) | ||
.saturating_add(Weight::from_parts(0, 0)) | ||
.saturating_add(T::DbWeight::get().writes(1)) | ||
} | ||
} | ||
|
||
impl WeightInfo for () { | ||
/// Storage: `Proofs::PoRepVerifyingKey` (r:0 w:1) | ||
/// Proof: `Proofs::PoRepVerifyingKey` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) | ||
fn set_porep_verifying_key() -> Weight { | ||
use frame_support::weights::constants::RocksDbWeight; | ||
|
||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 9_847_752_000 picoseconds. | ||
Weight::from_parts(10_481_480_000, 0) | ||
.saturating_add(Weight::from_parts(0, 0)) | ||
.saturating_add(RocksDbWeight::get().writes(1)) | ||
} | ||
/// Storage: `Proofs::PoStVerifyingKey` (r:0 w:1) | ||
/// Proof: `Proofs::PoStVerifyingKey` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) | ||
fn set_post_verifying_key() -> Weight { | ||
use frame_support::weights::constants::RocksDbWeight; | ||
|
||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 9_854_299_000 picoseconds. | ||
Weight::from_parts(10_455_634_000, 0) | ||
.saturating_add(Weight::from_parts(0, 0)) | ||
.saturating_add(RocksDbWeight::get().writes(1)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters