From 11404be1a19f4dfde455e54eedb4bb669d7dee7d Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Wed, 26 Jul 2023 11:39:09 +0300 Subject: [PATCH] Update weights --- pallets/airdrop/src/lib.rs | 4 +- pallets/airdrop/src/weights.rs | 92 +++++++++++++++++++++------------ runtime/vara/src/lib.rs | 2 +- runtime/vara/src/weights/mod.rs | 1 + 4 files changed, 64 insertions(+), 35 deletions(-) diff --git a/pallets/airdrop/src/lib.rs b/pallets/airdrop/src/lib.rs index 48fa3fd7cd6..613686b1c98 100644 --- a/pallets/airdrop/src/lib.rs +++ b/pallets/airdrop/src/lib.rs @@ -109,7 +109,7 @@ pub mod pallet { /// Emits the following events: /// - `TokensDeposited{ dest, amount }` #[pallet::call_index(0)] - #[pallet::weight(::WeightInfo::transfer())] + #[pallet::weight(::WeightInfo::transfer(1))] pub fn transfer( origin: OriginFor, source: T::AccountId, @@ -146,7 +146,7 @@ pub mod pallet { /// Emits the following events: /// - `VestingScheduleRemoved{ who, schedule_index }` #[pallet::call_index(1)] - #[pallet::weight(::WeightInfo::transfer())] + #[pallet::weight(::WeightInfo::transfer_vested(1))] pub fn transfer_vested( origin: OriginFor, source: T::AccountId, diff --git a/pallets/airdrop/src/weights.rs b/pallets/airdrop/src/weights.rs index 50614d97c6f..ddaa539a3d9 100644 --- a/pallets/airdrop/src/weights.rs +++ b/pallets/airdrop/src/weights.rs @@ -1,7 +1,6 @@ - // This file is part of Gear. -// Copyright (C) 2021-2023 Gear Technologies Inc. +// Copyright (C) 2022-2023 Gear Technologies Inc. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify @@ -17,51 +16,80 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//! Autogenerated weights for pallet_gear +//! Autogenerated weights for pallet_airdrop //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-08-25, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("local"), DB CACHE: 128 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-07-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vara-dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/gear-node -// benchmark -// pallet -// --pallet -// pallet_airdrop -// --extrinsic=transfer -// --steps -// 50 -// --repeat -// 20 -// --chain=vara-dev -// --output -// . +// ./target/production/gear benchmark pallet --chain=vara-dev --steps=50 --repeat=20 --pallet=pallet_airdrop --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=pallet_airdrop.rs --template=.maintain/frame-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(clippy::unnecessary_cast)] -use frame_support::{traits::Get, weights::{constants::RocksDbWeight, Weight}}; +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; -/// Weight functions for pallet_airdrop. +/// Weight functions needed for pallet_airdrop. pub trait WeightInfo { - fn transfer() -> Weight; + fn transfer(q: u32, ) -> Weight; + fn transfer_vested(q: u32, ) -> Weight; } -/// Weight functions for `pallet_airdrop`. -pub struct AirdropWeight(PhantomData); -impl WeightInfo for AirdropWeight { - fn transfer() -> Weight { - (Weight::from_parts(18_000_000, 0)) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } +/// Weights for pallet_airdrop using the Gear node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// The range of component `q` is `[1, 256]`. + fn transfer(_q: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `6196` + // Minimum execution time: 25_027_000 picoseconds. + Weight::from_parts(25_985_030, 6196) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// The range of component `q` is `[1, 256]`. + fn transfer_vested(q: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `550` + // Estimated: `15482` + // Minimum execution time: 65_271_000 picoseconds. + Weight::from_parts(67_109_074, 15482) + // Standard Error: 328 + .saturating_add(Weight::from_parts(336, 0).saturating_mul(q.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } } +// For backwards compatibility and tests impl WeightInfo for () { - fn transfer() -> Weight { - Weight::zero().saturating_add(RocksDbWeight::get().writes(1_u64)) + /// The range of component `q` is `[1, 256]`. + fn transfer(_q: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `103` + // Estimated: `6196` + // Minimum execution time: 25_027_000 picoseconds. + Weight::from_parts(25_985_030, 6196) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// The range of component `q` is `[1, 256]`. + fn transfer_vested(q: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `550` + // Estimated: `15482` + // Minimum execution time: 65_271_000 picoseconds. + Weight::from_parts(67_109_074, 15482) + // Standard Error: 328 + .saturating_add(Weight::from_parts(336, 0).saturating_mul(q.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) } } diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs index 0b5d77cae4e..0f160e0438b 100644 --- a/runtime/vara/src/lib.rs +++ b/runtime/vara/src/lib.rs @@ -816,7 +816,7 @@ impl pallet_gear_messenger::Config for Runtime { impl pallet_airdrop::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_airdrop::weights::AirdropWeight; + type WeightInfo = weights::pallet_airdrop::SubstrateWeight; type VestingSchedule = Vesting; } diff --git a/runtime/vara/src/weights/mod.rs b/runtime/vara/src/weights/mod.rs index b4eebedfe52..170d6f59e22 100644 --- a/runtime/vara/src/weights/mod.rs +++ b/runtime/vara/src/weights/mod.rs @@ -19,6 +19,7 @@ //! A list of the different weight modules for our runtime. pub mod frame_system; +pub mod pallet_airdrop; pub mod pallet_balances; pub mod pallet_gear; pub mod pallet_gear_voucher;