Skip to content

Commit

Permalink
528 make issue pallet benchmarks run successfully on pendulum runtimes (
Browse files Browse the repository at this point in the history
#535)

* Update benchmarks logic for issue pallet and re-generate weights

* Test commit for min issue amount

* Use minimum transfer amount in issue benchmark

* Use `omrl_currencies` to deposit tokens
so that the native currency is treated separately

---------

Co-authored-by: Marcel Ebert <[email protected]>
  • Loading branch information
bogdanS98 and ebma authored Jun 4, 2024
1 parent 524b15e commit 53f81a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
10 changes: 7 additions & 3 deletions pallets/issue/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ fn deposit_tokens<T: crate::Config>(
account_id: &T::AccountId,
amount: BalanceOf<T>,
) {
assert_ok!(<orml_tokens::Pallet<T>>::deposit(currency_id, account_id, amount));
assert_ok!(<orml_currencies::Pallet<T>>::deposit(currency_id, account_id, amount));
}

fn mint_collateral<T: crate::Config>(account_id: &T::AccountId, amount: BalanceOf<T>) {
deposit_tokens::<T>(get_collateral_currency_id::<T>(), account_id, amount);
deposit_tokens::<T>(get_native_currency_id::<T>(), account_id, amount);
deposit_tokens::<T>(
<T as vault_registry::Config>::GetGriefingCollateralCurrencyId::get(),
account_id,
amount,
);
}

fn get_currency_pair<T: crate::Config>() -> DefaultVaultCurrencyPair<T> {
Expand Down Expand Up @@ -61,8 +66,7 @@ benchmarks! {
request_issue {
let origin: T::AccountId = account("Origin", 0, 0);
let vault_id = get_vault_id::<T>();
let amount = 10_000_000u32.into();
let asset = vault_id.wrapped_currency();
let amount = Issue::<T>::issue_minimum_transfer_amount(vault_id.wrapped_currency()).amount();
let relayer_id: T::AccountId = account("Relayer", 0, 0);

Oracle::<T>::_set_exchange_rate(origin.clone(), get_collateral_currency_id::<T>(), <T as currency::Config>::UnsignedFixedPoint::one()).unwrap();
Expand Down
38 changes: 19 additions & 19 deletions pallets/issue/src/default_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Autogenerated weights for issue
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-04-02, STEPS: `100`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2024-05-23, STEPS: `100`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `Bogdans-M2-MacBook-Pro.local`, CPU: `<UNKNOWN>`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
Expand Down Expand Up @@ -77,8 +77,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `2192`
// Estimated: `5657`
// Minimum execution time: 57_000_000 picoseconds.
Weight::from_parts(60_000_000, 5657)
// Minimum execution time: 55_000_000 picoseconds.
Weight::from_parts(58_000_000, 5657)
.saturating_add(T::DbWeight::get().reads(15_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
Expand All @@ -104,8 +104,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `2190`
// Estimated: `71867`
// Minimum execution time: 3_807_000_000 picoseconds.
Weight::from_parts(3_911_000_000, 71867)
// Minimum execution time: 3_926_000_000 picoseconds.
Weight::from_parts(3_982_000_000, 71867)
.saturating_add(T::DbWeight::get().reads(10_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -121,8 +121,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `1199`
// Estimated: `4664`
// Minimum execution time: 24_000_000 picoseconds.
Weight::from_parts(25_000_000, 4664)
// Minimum execution time: 23_000_000 picoseconds.
Weight::from_parts(24_000_000, 4664)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -146,8 +146,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_000_000 picoseconds.
Weight::from_parts(6_000_000, 0)
// Minimum execution time: 4_000_000 picoseconds.
Weight::from_parts(5_000_000, 0)
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: Issue IssueMinimumTransferAmount (r:0 w:1)
Expand All @@ -156,7 +156,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 4_000_000 picoseconds.
// Minimum execution time: 3_000_000 picoseconds.
Weight::from_parts(4_000_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand Down Expand Up @@ -200,8 +200,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `2192`
// Estimated: `5657`
// Minimum execution time: 57_000_000 picoseconds.
Weight::from_parts(60_000_000, 5657)
// Minimum execution time: 55_000_000 picoseconds.
Weight::from_parts(58_000_000, 5657)
.saturating_add(RocksDbWeight::get().reads(15_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
Expand All @@ -227,8 +227,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `2190`
// Estimated: `71867`
// Minimum execution time: 3_807_000_000 picoseconds.
Weight::from_parts(3_911_000_000, 71867)
// Minimum execution time: 3_926_000_000 picoseconds.
Weight::from_parts(3_982_000_000, 71867)
.saturating_add(RocksDbWeight::get().reads(10_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -244,8 +244,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `1199`
// Estimated: `4664`
// Minimum execution time: 24_000_000 picoseconds.
Weight::from_parts(25_000_000, 4664)
// Minimum execution time: 23_000_000 picoseconds.
Weight::from_parts(24_000_000, 4664)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -269,8 +269,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_000_000 picoseconds.
Weight::from_parts(6_000_000, 0)
// Minimum execution time: 4_000_000 picoseconds.
Weight::from_parts(5_000_000, 0)
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
/// Storage: Issue IssueMinimumTransferAmount (r:0 w:1)
Expand All @@ -279,7 +279,7 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 4_000_000 picoseconds.
// Minimum execution time: 3_000_000 picoseconds.
Weight::from_parts(4_000_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand Down

0 comments on commit 53f81a2

Please sign in to comment.