Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Benchmarking: Innovation Staking #313

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pallets/economy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ version = '2.0.0-rc6'
targets = ['x86_64-unknown-linux-gnu']

[dependencies]
log = { workspace = true }
serde = { workspace = true, optional = true, features = ["derive"] }
codec = { workspace = true, package = "parity-scale-codec" }
scale-info = { workspace = true }
Expand Down Expand Up @@ -55,6 +56,7 @@ runtime-benchmarks = [
default = ['std']
std = [
"serde",
"log/std",
"codec/std",
"sp-runtime/std",
"frame-support/std",
Expand Down
6 changes: 2 additions & 4 deletions pallets/economy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Encode, HasCompact};
use frame_benchmarking::log;
use frame_support::traits::ExistenceRequirement;
use frame_support::{
ensure,
Expand Down Expand Up @@ -79,7 +78,6 @@ pub mod weights;

#[frame_support::pallet]
pub mod pallet {
use frame_benchmarking::log;
use sp_runtime::traits::{CheckedAdd, CheckedSub, Saturating};
use sp_runtime::ArithmeticError;

Expand Down Expand Up @@ -501,7 +499,7 @@ pub mod pallet {
/// `amount`: the stake amount
///
/// Emit `SelfStakedToEconomy101` event or `EstateStakedToEconomy101` event if successful
#[pallet::weight(T::WeightInfo::stake_a())]
#[pallet::weight(T::WeightInfo::stake_on_innovation())]
#[transactional]
pub fn stake_on_innovation(origin: OriginFor<T>, amount: BalanceOf<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand Down Expand Up @@ -552,7 +550,7 @@ pub mod pallet {
/// `amount`: the unstake amount
///
/// Emit `UnstakedInnovation` event if successful
#[pallet::weight(T::WeightInfo::stake_a())]
#[pallet::weight(T::WeightInfo::unstake_on_innovation())]
#[transactional]
pub fn unstake_on_innovation(origin: OriginFor<T>, amount: BalanceOf<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand Down
159 changes: 36 additions & 123 deletions pallets/economy/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Autogenerated weights for economy
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-21, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-02-20, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -47,178 +47,91 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weight functions needed for economy.
pub trait WeightInfo { fn set_bit_power_exchange_rate() -> Weight; fn set_power_balance() -> Weight; fn stake_a() -> Weight; fn stake_b() -> Weight; fn unstake_a() -> Weight; fn unstake_b() -> Weight; fn unstake_new_estate_owner() -> Weight; fn withdraw_unreserved() -> Weight;}
pub trait WeightInfo { fn stake_a() -> Weight; fn stake_b() -> Weight; fn stake_on_innovation() -> Weight; fn unstake_a() -> Weight; fn unstake_b() -> Weight; fn unstake_new_estate_owner() -> Weight; fn unstake_on_innovation() -> Weight; fn withdraw_unreserved() -> Weight;}

/// Weights for economy using the for collator node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { // Storage: Economy BitPowerExchangeRate (r:0 w:1)
// Proof Skipped: Economy BitPowerExchangeRate (max_values: Some(1), max_size: None, mode: Measured)
fn set_bit_power_exchange_rate() -> Weight {
// Proof Size summary in bytes:
// Measured: `919`
// Estimated: `919`
// Minimum execution time: 11_685 nanoseconds.
Weight::from_parts(12_108_000, 919)
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: Economy PowerBalance (r:0 w:1)
// Proof Skipped: Economy PowerBalance (max_values: None, max_size: None, mode: Measured)
fn set_power_balance() -> Weight {
// Proof Size summary in bytes:
// Measured: `919`
// Estimated: `919`
// Minimum execution time: 12_284 nanoseconds.
Weight::from_parts(12_785_000, 919)
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: Mining Round (r:1 w:0)
// Proof Skipped: Mining Round (max_values: Some(1), max_size: None, mode: Measured)
// Storage: Economy ExitQueue (r:1 w:0)
// Proof Skipped: Economy ExitQueue (max_values: None, max_size: None, mode: Measured)
// Storage: Economy StakingInfo (r:1 w:1)
// Proof Skipped: Economy StakingInfo (max_values: None, max_size: None, mode: Measured)
// Storage: Economy TotalStake (r:1 w:1)
// Proof Skipped: Economy TotalStake (max_values: Some(1), max_size: None, mode: Measured)
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn stake_a() -> Weight {
// Proof Size summary in bytes:
// Measured: `1496`
// Estimated: `11924`
// Minimum execution time: 29_836 nanoseconds.
Weight::from_parts(30_929_000, 11924)
Weight::from_parts(52_209_000, 4929)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: Mining Round (r:1 w:0)
// Proof Skipped: Mining Round (max_values: Some(1), max_size: None, mode: Measured)
// Storage: Economy EstateExitQueue (r:1 w:0)
// Proof Skipped: Economy EstateExitQueue (max_values: None, max_size: None, mode: Measured)
// Storage: Estate Estates (r:1 w:0)
// Proof Skipped: Estate Estates (max_values: None, max_size: None, mode: Measured)
// Storage: Estate EstateOwner (r:1 w:0)
// Proof Skipped: Estate EstateOwner (max_values: None, max_size: None, mode: Measured)
// Storage: OrmlNFT Tokens (r:1 w:0)
// Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured)
// Storage: Economy EstateStakingInfo (r:1 w:1)
// Proof Skipped: Economy EstateStakingInfo (max_values: None, max_size: None, mode: Measured)
// Storage: Economy TotalEstateStake (r:1 w:1)
// Proof Skipped: Economy TotalEstateStake (max_values: Some(1), max_size: None, mode: Measured)
fn stake_b() -> Weight {
// Proof Size summary in bytes:
// Measured: `2144`
// Estimated: `28373`
// Minimum execution time: 45_093 nanoseconds.
Weight::from_parts(48_615_000, 28373)
Weight::from_parts(71_491_000, 5545)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: Economy StakingInfo (r:1 w:1)
// Proof Skipped: Economy StakingInfo (max_values: None, max_size: None, mode: Measured)
// Storage: Mining Round (r:1 w:0)
// Proof Skipped: Mining Round (max_values: Some(1), max_size: None, mode: Measured)
// Storage: Economy ExitQueue (r:1 w:1)
// Proof Skipped: Economy ExitQueue (max_values: None, max_size: None, mode: Measured)
// Storage: Economy TotalStake (r:1 w:1)
// Proof Skipped: Economy TotalStake (max_values: Some(1), max_size: None, mode: Measured)
fn stake_on_innovation() -> Weight {
Weight::from_parts(56_832_000, 4929)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
fn unstake_a() -> Weight {
// Proof Size summary in bytes:
// Measured: `1233`
// Estimated: `10872`
// Minimum execution time: 22_126 nanoseconds.
Weight::from_parts(23_896_000, 10872)
Weight::from_parts(32_069_000, 4698)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
// Storage: Estate Estates (r:1 w:0)
// Proof Skipped: Estate Estates (max_values: None, max_size: None, mode: Measured)
// Storage: Economy EstateStakingInfo (r:1 w:1)
// Proof Skipped: Economy EstateStakingInfo (max_values: None, max_size: None, mode: Measured)
// Storage: Mining Round (r:1 w:0)
// Proof Skipped: Mining Round (max_values: Some(1), max_size: None, mode: Measured)
// Storage: Economy EstateExitQueue (r:1 w:1)
// Proof Skipped: Economy EstateExitQueue (max_values: None, max_size: None, mode: Measured)
// Storage: Economy TotalEstateStake (r:1 w:1)
// Proof Skipped: Economy TotalEstateStake (max_values: Some(1), max_size: None, mode: Measured)
fn unstake_b() -> Weight {
// Proof Size summary in bytes:
// Measured: `1489`
// Estimated: `15860`
// Minimum execution time: 31_005 nanoseconds.
Weight::from_parts(32_916_000, 15860)
Weight::from_parts(47_341_000, 4921)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
// Storage: Estate Estates (r:1 w:0)
// Proof Skipped: Estate Estates (max_values: None, max_size: None, mode: Measured)
// Storage: Estate EstateOwner (r:1 w:0)
// Proof Skipped: Estate EstateOwner (max_values: None, max_size: None, mode: Measured)
// Storage: OrmlNFT Tokens (r:1 w:0)
// Proof Skipped: OrmlNFT Tokens (max_values: None, max_size: None, mode: Measured)
// Storage: Economy EstateStakingInfo (r:1 w:1)
// Proof Skipped: Economy EstateStakingInfo (max_values: None, max_size: None, mode: Measured)
// Storage: Mining Round (r:1 w:0)
// Proof Skipped: Mining Round (max_values: Some(1), max_size: None, mode: Measured)
// Storage: Economy TotalEstateStake (r:1 w:1)
// Proof Skipped: Economy TotalEstateStake (max_values: Some(1), max_size: None, mode: Measured)
// Storage: Economy EstateExitQueue (r:0 w:1)
// Proof Skipped: Economy EstateExitQueue (max_values: None, max_size: None, mode: Measured)
fn unstake_new_estate_owner() -> Weight {
// Proof Size summary in bytes:
// Measured: `1914`
// Estimated: `24288`
// Minimum execution time: 36_727 nanoseconds.
Weight::from_parts(38_216_000, 24288)
Weight::from_parts(53_229_000, 5314)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(3))
}
// Storage: Economy ExitQueue (r:1 w:1)
// Proof Skipped: Economy ExitQueue (max_values: None, max_size: None, mode: Measured)
fn unstake_on_innovation() -> Weight {
Weight::from_parts(46_719_000, 4811)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(5))
}
fn withdraw_unreserved() -> Weight {
// Proof Size summary in bytes:
// Measured: `1568`
// Estimated: `4043`
// Minimum execution time: 24_239 nanoseconds.
Weight::from_parts(25_134_000, 4043)
Weight::from_parts(58_043_000, 5001)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}

// For backwards compatibility and tests
impl WeightInfo for () { fn set_bit_power_exchange_rate() -> Weight {
Weight::from_parts(12_108_000, 919)
.saturating_add(RocksDbWeight::get().writes(1))
}
fn set_power_balance() -> Weight {
Weight::from_parts(12_785_000, 919)
.saturating_add(RocksDbWeight::get().writes(1))
}
fn stake_a() -> Weight {
Weight::from_parts(30_929_000, 11924)
impl WeightInfo for () { fn stake_a() -> Weight {
Weight::from_parts(52_209_000, 4929)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(2))
}
fn stake_b() -> Weight {
Weight::from_parts(48_615_000, 28373)
Weight::from_parts(71_491_000, 5545)
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().writes(2))
}
fn stake_on_innovation() -> Weight {
Weight::from_parts(56_832_000, 4929)
.saturating_add(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().writes(4))
}
fn unstake_a() -> Weight {
Weight::from_parts(23_896_000, 10872)
Weight::from_parts(32_069_000, 4698)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
}
fn unstake_b() -> Weight {
Weight::from_parts(32_916_000, 15860)
Weight::from_parts(47_341_000, 4921)
.saturating_add(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(3))
}
fn unstake_new_estate_owner() -> Weight {
Weight::from_parts(38_216_000, 24288)
Weight::from_parts(53_229_000, 5314)
.saturating_add(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().writes(3))
}
fn unstake_on_innovation() -> Weight {
Weight::from_parts(46_719_000, 4811)
.saturating_add(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().writes(5))
}
fn withdraw_unreserved() -> Weight {
Weight::from_parts(25_134_000, 4043)
Weight::from_parts(58_043_000, 5001)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
Expand Down
Loading
Loading