From 74a83abc434ee266bc6fb5eef35c9fe4eb777a28 Mon Sep 17 00:00:00 2001 From: peg Date: Thu, 15 Aug 2024 22:40:44 +0200 Subject: [PATCH] Generate weights --- pallets/attestation/src/benchmarking.rs | 2 +- pallets/attestation/src/lib.rs | 6 +- pallets/attestation/src/mock.rs | 1 + pallets/attestation/src/weights.rs | 87 +++++++++++++++++++++++ runtime/src/lib.rs | 7 ++ runtime/src/weights/pallet_attestation.rs | 64 +++++++++++++++++ 6 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 pallets/attestation/src/weights.rs create mode 100644 runtime/src/weights/pallet_attestation.rs diff --git a/pallets/attestation/src/benchmarking.rs b/pallets/attestation/src/benchmarking.rs index 1828faea4..e47d2ab86 100644 --- a/pallets/attestation/src/benchmarking.rs +++ b/pallets/attestation/src/benchmarking.rs @@ -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(); diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 767ffaa84..040bb6f03 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -21,7 +21,7 @@ pub use pallet::*; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; -// pub mod weights; +pub mod weights; #[cfg(test)] mod mock; @@ -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] @@ -47,6 +47,8 @@ pub mod pallet { pub trait Config: frame_system::Config + pallet_staking_extension::Config { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// Describes the weights of the dispatchables exposed by this pallet. + type WeightInfo: WeightInfo; } #[pallet::genesis_config] diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index 09e8947b3..11b799d44 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -62,6 +62,7 @@ frame_support::construct_runtime!( impl pallet_attestation::Config for Test { type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); } parameter_types! { diff --git a/pallets/attestation/src/weights.rs b/pallets/attestation/src/weights.rs new file mode 100644 index 000000000..3c8ef6e18 --- /dev/null +++ b/pallets/attestation/src/weights.rs @@ -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 . + +//! 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(PhantomData); +impl WeightInfo for SubstrateWeightInfo { + /// 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)) + } +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index ad26f4020..c62ed21fb 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1493,6 +1493,11 @@ impl pallet_parameters::Config for Runtime { type WeightInfo = weights::pallet_parameters::WeightInfo; } +impl pallet_attestation::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + // type WeightInfo = weights::pallet_attestation::WeightInfo; +} + construct_runtime!( pub enum Runtime { @@ -1545,6 +1550,7 @@ construct_runtime!( TransactionPause: pallet_transaction_pause = 54, Propagation: pallet_propagation = 55, Parameters: pallet_parameters = 56, + Attestation: pallet_attestation = 57, } ); @@ -1602,6 +1608,7 @@ extern crate frame_benchmarking; mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] + [pallet_attestation, Attestation] [pallet_babe, Babe] [pallet_bags_list, BagsList] [pallet_balances, Balances] diff --git a/runtime/src/weights/pallet_attestation.rs b/runtime/src/weights/pallet_attestation.rs new file mode 100644 index 000000000..57381723d --- /dev/null +++ b/runtime/src/weights/pallet_attestation.rs @@ -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 . + +//! 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(PhantomData); +impl pallet_attestation::WeightInfo for WeightInfo { + /// 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)) + } +}