Skip to content

Commit

Permalink
feat: 🎸 add vtoken-minting benchmark (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
yooml authored Feb 1, 2024
1 parent 6f7d0a9 commit 30f7b8e
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 22 deletions.
16 changes: 16 additions & 0 deletions pallets/vtoken-minting/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ benchmarks! {
let origin = T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
}: _<T::RuntimeOrigin>(origin, 10u32)

set_unlocking_total {
let origin = T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let token = CurrencyId::Token(TokenSymbol::KSM);
let token_amount = BalanceOf::<T>::unique_saturated_from(1000u32 as u128);
}: _<T::RuntimeOrigin>(origin, token, token_amount)

set_min_time_unit {
let origin = T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let token = CurrencyId::Token(TokenSymbol::KSM);
}: _<T::RuntimeOrigin>(origin, token, TimeUnit::Era(1))

recreate_currency_ongoing_time_unit {
let origin = T::ControlOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let token = CurrencyId::Token(TokenSymbol::KSM);
}: _<T::RuntimeOrigin>(origin, token, TimeUnit::Era(1))

mint {
let caller: T::AccountId = whitelisted_caller();
const KSM: CurrencyId = CurrencyId::Token(TokenSymbol::KSM);
Expand Down
6 changes: 3 additions & 3 deletions pallets/vtoken-minting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ pub mod pallet {
}

#[pallet::call_index(11)]
#[pallet::weight({0})]
#[pallet::weight(T::WeightInfo::set_unlocking_total())]
pub fn set_unlocking_total(
origin: OriginFor<T>,
token_id: CurrencyIdOf<T>,
Expand All @@ -793,7 +793,7 @@ pub mod pallet {
}

#[pallet::call_index(12)]
#[pallet::weight({0})]
#[pallet::weight(T::WeightInfo::set_min_time_unit())]
pub fn set_min_time_unit(
origin: OriginFor<T>,
token_id: CurrencyIdOf<T>,
Expand All @@ -808,7 +808,7 @@ pub mod pallet {
}

#[pallet::call_index(13)]
#[pallet::weight({0})]
#[pallet::weight(T::WeightInfo::recreate_currency_ongoing_time_unit())]
pub fn recreate_currency_ongoing_time_unit(
origin: OriginFor<T>,
token_id: CurrencyIdOf<T>,
Expand Down
46 changes: 39 additions & 7 deletions pallets/vtoken-minting/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ pub trait WeightInfo {
fn set_minimum_mint() -> Weight;
fn set_minimum_redeem() -> Weight;
fn set_unlock_duration() -> Weight;
fn set_unlocking_total() -> Weight;
fn set_min_time_unit() -> Weight;
fn recreate_currency_ongoing_time_unit() -> Weight;
fn add_support_rebond_token() -> Weight;
fn remove_support_rebond_token() -> Weight;
fn set_fees() -> Weight;
Expand All @@ -65,7 +68,6 @@ pub trait WeightInfo {
fn rebond() -> Weight;
fn rebond_by_unlock_id() -> Weight;
fn on_initialize() -> Weight;
fn recreate_currency_ongoing_time_unit() -> Weight;
}

// For backwards compatibility and tests
Expand Down Expand Up @@ -105,6 +107,42 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: `VtokenMinting::UnlockingTotal` (r:1 w:1)
/// Proof: `VtokenMinting::UnlockingTotal` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`)
fn set_unlocking_total() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3503`
// Minimum execution time: 14_808_000 picoseconds.
Weight::from_parts(15_209_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::MinTimeUnit` (r:1 w:1)
/// Proof: `VtokenMinting::MinTimeUnit` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`)
fn set_min_time_unit() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3492`
// Minimum execution time: 15_269_000 picoseconds.
Weight::from_parts(15_499_000, 0)
.saturating_add(Weight::from_parts(0, 3492))
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::OngoingTimeUnit` (r:1 w:1)
/// Proof: `VtokenMinting::OngoingTimeUnit` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`)
fn recreate_currency_ongoing_time_unit() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3492`
// Minimum execution time: 15_209_000 picoseconds.
Weight::from_parts(15_509_000, 0)
.saturating_add(Weight::from_parts(0, 3492))
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
/// Storage: VtokenMinting TokenToRebond (r:1 w:1)
/// Proof: VtokenMinting TokenToRebond (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen)
fn add_support_rebond_token() -> Weight {
Expand Down Expand Up @@ -279,10 +317,4 @@ impl WeightInfo for () {
Weight::from_parts(15_243_000, 3492)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}

fn recreate_currency_ongoing_time_unit() -> Weight {
Weight::from_parts(70_238_000, 4197)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
42 changes: 36 additions & 6 deletions runtime/bifrost-kusama/src/weights/bifrost_vtoken_minting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,42 @@ impl<T: frame_system::Config> bifrost_vtoken_minting::WeightInfo for BifrostWeig
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::UnlockingTotal` (r:1 w:1)
/// Proof: `VtokenMinting::UnlockingTotal` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`)
fn set_unlocking_total() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3503`
// Minimum execution time: 14_808_000 picoseconds.
Weight::from_parts(15_209_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::MinTimeUnit` (r:1 w:1)
/// Proof: `VtokenMinting::MinTimeUnit` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`)
fn set_min_time_unit() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3492`
// Minimum execution time: 15_269_000 picoseconds.
Weight::from_parts(15_499_000, 0)
.saturating_add(Weight::from_parts(0, 3492))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::OngoingTimeUnit` (r:1 w:1)
/// Proof: `VtokenMinting::OngoingTimeUnit` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`)
fn recreate_currency_ongoing_time_unit() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3492`
// Minimum execution time: 15_209_000 picoseconds.
Weight::from_parts(15_509_000, 0)
.saturating_add(Weight::from_parts(0, 3492))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: VtokenMinting TokenToRebond (r:1 w:1)
// Proof: VtokenMinting TokenToRebond (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen)
fn add_support_rebond_token() -> Weight {
Expand Down Expand Up @@ -263,10 +299,4 @@ impl<T: frame_system::Config> bifrost_vtoken_minting::WeightInfo for BifrostWeig
Weight::from_parts(16_763_000, 3492)
.saturating_add(T::DbWeight::get().reads(1))
}

fn recreate_currency_ongoing_time_unit() -> Weight {
Weight::from_parts(70_238_000, 4197)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}
42 changes: 36 additions & 6 deletions runtime/bifrost-polkadot/src/weights/bifrost_vtoken_minting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,42 @@ impl<T: frame_system::Config> bifrost_vtoken_minting::WeightInfo for BifrostWeig
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::UnlockingTotal` (r:1 w:1)
/// Proof: `VtokenMinting::UnlockingTotal` (`max_values`: None, `max_size`: Some(38), added: 2513, mode: `MaxEncodedLen`)
fn set_unlocking_total() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3503`
// Minimum execution time: 14_808_000 picoseconds.
Weight::from_parts(15_209_000, 0)
.saturating_add(Weight::from_parts(0, 3503))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::MinTimeUnit` (r:1 w:1)
/// Proof: `VtokenMinting::MinTimeUnit` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`)
fn set_min_time_unit() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3492`
// Minimum execution time: 15_269_000 picoseconds.
Weight::from_parts(15_499_000, 0)
.saturating_add(Weight::from_parts(0, 3492))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `VtokenMinting::OngoingTimeUnit` (r:1 w:1)
/// Proof: `VtokenMinting::OngoingTimeUnit` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`)
fn recreate_currency_ongoing_time_unit() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3492`
// Minimum execution time: 15_209_000 picoseconds.
Weight::from_parts(15_509_000, 0)
.saturating_add(Weight::from_parts(0, 3492))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: VtokenMinting TokenToRebond (r:1 w:1)
// Proof: VtokenMinting TokenToRebond (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen)
fn add_support_rebond_token() -> Weight {
Expand Down Expand Up @@ -263,10 +299,4 @@ impl<T: frame_system::Config> bifrost_vtoken_minting::WeightInfo for BifrostWeig
Weight::from_parts(16_763_000, 3492)
.saturating_add(T::DbWeight::get().reads(1))
}

fn recreate_currency_ongoing_time_unit() -> Weight {
Weight::from_parts(70_238_000, 4197)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}

0 comments on commit 30f7b8e

Please sign in to comment.