Skip to content

Commit

Permalink
Generate weights
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Aug 15, 2024
1 parent 992a4d1 commit 74a83ab
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pallets/attestation/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ benchmarks! {
&attestee, // TSS Account ID
[0; 32], // x25519 public key
nonce,
0, // Block number
1, // Block number
);
let quote = tdx_quote::Quote::mock(signing_key.clone(), input_data.0).as_bytes().to_vec();

Expand Down
6 changes: 4 additions & 2 deletions pallets/attestation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use pallet::*;
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;

// pub mod weights;
pub mod weights;

#[cfg(test)]
mod mock;
Expand All @@ -37,7 +37,7 @@ pub mod pallet {
use sp_std::vec::Vec;
use tdx_quote::Quote;

// pub use crate::weights::WeightInfo;
pub use crate::weights::WeightInfo;

#[pallet::pallet]
#[pallet::without_storage_info]
Expand All @@ -47,6 +47,8 @@ pub mod pallet {
pub trait Config: frame_system::Config + pallet_staking_extension::Config {
/// The overarching event type.
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Describes the weights of the dispatchables exposed by this pallet.
type WeightInfo: WeightInfo;
}

#[pallet::genesis_config]
Expand Down
1 change: 1 addition & 0 deletions pallets/attestation/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ frame_support::construct_runtime!(

impl pallet_attestation::Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
}

parameter_types! {
Expand Down
87 changes: 87 additions & 0 deletions pallets/attestation/src/weights.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (C) 2023 Entropy Cryptography Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Autogenerated weights for `pallet_attestation`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 33.0.0
//! DATE: 2024-08-15, STEPS: `5`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `turnip`, CPU: `Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024

// Executed Command:
// ./target/release/entropy
// benchmark
// pallet
// --chain
// dev
// --pallet=pallet_attestation
// --extrinsic=*
// --steps=5
// --repeat=2
// --header=.maintain/AGPL-3.0-header.txt
// --output=./runtime/src/weights/

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;

pub trait WeightInfo {
fn attest() -> Weight;
}

/// Weight functions for `pallet_attestation`.
pub struct SubstrateWeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeightInfo<T> {
/// Storage: `Attestation::PendingAttestations` (r:1 w:1)
/// Proof: `Attestation::PendingAttestations` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0)
/// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `StakingExtension::ThresholdServers` (r:1 w:0)
/// Proof: `StakingExtension::ThresholdServers` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn attest() -> Weight {
// Proof Size summary in bytes:
// Measured: `661`
// Estimated: `4126`
// Minimum execution time: 2_573_915_000 picoseconds.
Weight::from_parts(2_582_997_000, 0)
.saturating_add(Weight::from_parts(0, 4126))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
}

impl WeightInfo for () {
/// Storage: `Attestation::PendingAttestations` (r:1 w:1)
/// Proof: `Attestation::PendingAttestations` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0)
/// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `StakingExtension::ThresholdServers` (r:1 w:0)
/// Proof: `StakingExtension::ThresholdServers` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn attest() -> Weight {
// Proof Size summary in bytes:
// Measured: `661`
// Estimated: `4126`
// Minimum execution time: 2_573_915_000 picoseconds.
Weight::from_parts(2_582_997_000, 0)
.saturating_add(Weight::from_parts(0, 4126))
.saturating_add(RocksDbWeight::get().reads(3))
.saturating_add(RocksDbWeight::get().writes(1))
}
}
7 changes: 7 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,11 @@ impl pallet_parameters::Config for Runtime {
type WeightInfo = weights::pallet_parameters::WeightInfo<Runtime>;
}

impl pallet_attestation::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// type WeightInfo = weights::pallet_attestation::WeightInfo<Runtime>;
}

construct_runtime!(
pub enum Runtime
{
Expand Down Expand Up @@ -1545,6 +1550,7 @@ construct_runtime!(
TransactionPause: pallet_transaction_pause = 54,
Propagation: pallet_propagation = 55,
Parameters: pallet_parameters = 56,
Attestation: pallet_attestation = 57,
}
);

Expand Down Expand Up @@ -1602,6 +1608,7 @@ extern crate frame_benchmarking;
mod benches {
define_benchmarks!(
[frame_benchmarking, BaselineBench::<Runtime>]
[pallet_attestation, Attestation]
[pallet_babe, Babe]
[pallet_bags_list, BagsList]
[pallet_balances, Balances]
Expand Down
64 changes: 64 additions & 0 deletions runtime/src/weights/pallet_attestation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (C) 2023 Entropy Cryptography Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Autogenerated weights for `pallet_attestation`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 33.0.0
//! DATE: 2024-08-15, STEPS: `5`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `turnip`, CPU: `Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024

// Executed Command:
// ./target/release/entropy
// benchmark
// pallet
// --chain
// dev
// --pallet=pallet_attestation
// --extrinsic=*
// --steps=5
// --repeat=2
// --header=.maintain/AGPL-3.0-header.txt
// --output=./runtime/src/weights/

#![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;

/// Weight functions for `pallet_attestation`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_attestation::WeightInfo for WeightInfo<T> {
/// Storage: `Attestation::PendingAttestations` (r:1 w:1)
/// Proof: `Attestation::PendingAttestations` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0)
/// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `StakingExtension::ThresholdServers` (r:1 w:0)
/// Proof: `StakingExtension::ThresholdServers` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn attest() -> Weight {
// Proof Size summary in bytes:
// Measured: `661`
// Estimated: `4126`
// Minimum execution time: 2_573_915_000 picoseconds.
Weight::from_parts(2_582_997_000, 0)
.saturating_add(Weight::from_parts(0, 4126))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
}

0 comments on commit 74a83ab

Please sign in to comment.