Skip to content

Commit

Permalink
Merge branch 'master' into remove_common_runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Roznovjak committed Jun 30, 2023
2 parents ba88bfe + 35c131b commit c038123
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion pallets/circuit-breaker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-circuit-breaker"
version = "1.1.12"
version = "1.1.13"
authors = ["GalacticCouncil <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
17 changes: 15 additions & 2 deletions pallets/circuit-breaker/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,34 @@ benchmarks! {
}: { Pallet::<T>::on_finalize(block_num); }
verify {}

on_finalize_single {
on_finalize_single_liquidity_limit_entry {
let block_num: T::BlockNumber = 5u32.into();
frame_system::Pallet::<T>::set_block_number(block_num);

Pallet::<T>::on_initialize(block_num);

let amount = T::Balance::from(1_000_000u32);
let asset_id = T::AssetId::from(1);
Pallet::<T>::initialize_trade_limit(asset_id, amount)?;
Pallet::<T>::calculate_and_store_liquidity_limits(asset_id, amount)?;

whitelist_storage_maps::<T>();
}: { Pallet::<T>::on_finalize(block_num); }
verify {}

on_finalize_single_trade_limit_entry {
let block_num: T::BlockNumber = 5u32.into();
frame_system::Pallet::<T>::set_block_number(block_num);

Pallet::<T>::on_initialize(block_num);

let amount = T::Balance::from(1_000_000u32);
let asset_id = T::AssetId::from(1);
Pallet::<T>::initialize_trade_limit(asset_id, amount)?;

whitelist_storage_maps::<T>();
}: { Pallet::<T>::on_finalize(block_num); }
verify {}

on_finalize_empty {
let block_num: T::BlockNumber = 5u32.into();
frame_system::Pallet::<T>::set_block_number(block_num);
Expand Down
8 changes: 6 additions & 2 deletions pallets/circuit-breaker/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_omnipool.
pub trait WeightInfo {
fn on_finalize(m: u32, n: u32) -> Weight;
fn on_finalize_single() -> Weight;
fn on_finalize_single_liquidity_limit_entry() -> Weight;
fn on_finalize_single_trade_limit_entry() -> Weight;
fn on_finalize_empty() -> Weight;
fn set_trade_volume_limit() -> Weight;
fn set_add_liquidity_limit() -> Weight;
Expand All @@ -65,7 +66,10 @@ impl WeightInfo for () {
fn on_finalize(_m: u32, _n: u32) -> Weight {
Weight::zero()
}
fn on_finalize_single() -> Weight {
fn on_finalize_single_liquidity_limit_entry() -> Weight {
Weight::zero()
}
fn on_finalize_single_trade_limit_entry() -> Weight {
Weight::zero()
}
fn on_finalize_empty() -> Weight {
Expand Down
4 changes: 2 additions & 2 deletions runtime/hydradx/src/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ where
let w1 = OnActivityHandler::<Runtime>::on_liquidity_changed_weight();
let w2 = <Runtime as pallet_circuit_breaker::Config>::WeightInfo::ensure_add_liquidity_limit()
.max(<Runtime as pallet_circuit_breaker::Config>::WeightInfo::ensure_remove_liquidity_limit());
let w3 = <Runtime as pallet_circuit_breaker::Config>::WeightInfo::on_finalize_single(); // TODO: implement and use on_finalize_single_liquidity_limit_entry benchmark
let w3 = <Runtime as pallet_circuit_breaker::Config>::WeightInfo::on_finalize_single_liquidity_limit_entry();
w1.saturating_add(w2).saturating_add(w3)
}

fn on_trade_weight() -> Weight {
let w1 = OnActivityHandler::<Runtime>::on_trade_weight().saturating_mul(2);
let w2 = <Runtime as pallet_circuit_breaker::Config>::WeightInfo::ensure_pool_state_change_limit();
let w3 = <Runtime as pallet_circuit_breaker::Config>::WeightInfo::on_finalize_single(); // TODO: implement and use on_finalize_single_trade_limit_entry benchmark
let w3 = <Runtime as pallet_circuit_breaker::Config>::WeightInfo::on_finalize_single_trade_limit_entry();
w1.saturating_add(w2).saturating_add(w3)
}
}
Expand Down
50 changes: 27 additions & 23 deletions runtime/hydradx/src/weights/circuit_breaker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Autogenerated weights for pallet_circuit_breaker
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-16, STEPS: 5, REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! DATE: 2023-06-22, STEPS: 5, REPEAT: 20, LOW RANGE: [], HIGH RANGE: []
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -57,37 +57,41 @@ impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
/// The range of component `n` is `[0, 400]`.
/// The range of component `m` is `[0, 400]`.
fn on_finalize(n: u32, m: u32) -> Weight {
// Minimum execution time: 310_153 nanoseconds.
Weight::from_ref_time(561_590 as u64) // Standard Error: 4_842
.saturating_add(Weight::from_ref_time(781_422 as u64).saturating_mul(n as u64))
// Standard Error: 4_842
.saturating_add(Weight::from_ref_time(1_547_362 as u64).saturating_mul(m as u64))
// Minimum execution time: 310_147 nanoseconds.
Weight::from_ref_time(314_819_000 as u64) // Standard Error: 32_862
.saturating_add(Weight::from_ref_time(290_334 as u64).saturating_mul(n as u64))
// Standard Error: 32_862
.saturating_add(Weight::from_ref_time(1_084_558 as u64).saturating_mul(m as u64))
}
fn on_finalize_single() -> Weight {
// Minimum execution time: 8_312 nanoseconds.
Weight::from_ref_time(8_598_000 as u64)
fn on_finalize_single_liquidity_limit_entry() -> Weight {
// Minimum execution time: 8_356 nanoseconds.
Weight::from_ref_time(8_620_000 as u64)
}
fn on_finalize_single_trade_limit_entry() -> Weight {
// Minimum execution time: 8_409 nanoseconds.
Weight::from_ref_time(8_627_000 as u64)
}
fn on_finalize_empty() -> Weight {
// Minimum execution time: 8_327 nanoseconds.
Weight::from_ref_time(8_689_000 as u64)
// Minimum execution time: 8_492 nanoseconds.
Weight::from_ref_time(8_759_000 as u64)
}
// Storage: CircuitBreaker TradeVolumeLimitPerAsset (r:0 w:1)
// Proof: CircuitBreaker TradeVolumeLimitPerAsset (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
fn set_trade_volume_limit() -> Weight {
// Minimum execution time: 12_138 nanoseconds.
Weight::from_ref_time(12_365_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
// Minimum execution time: 12_557 nanoseconds.
Weight::from_ref_time(12_852_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: CircuitBreaker LiquidityAddLimitPerAsset (r:0 w:1)
// Proof: CircuitBreaker LiquidityAddLimitPerAsset (max_values: None, max_size: Some(29), added: 2504, mode: MaxEncodedLen)
fn set_add_liquidity_limit() -> Weight {
// Minimum execution time: 12_781 nanoseconds.
Weight::from_ref_time(13_036_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
// Minimum execution time: 12_968 nanoseconds.
Weight::from_ref_time(13_333_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: CircuitBreaker LiquidityRemoveLimitPerAsset (r:0 w:1)
// Proof: CircuitBreaker LiquidityRemoveLimitPerAsset (max_values: None, max_size: Some(29), added: 2504, mode: MaxEncodedLen)
fn set_remove_liquidity_limit() -> Weight {
// Minimum execution time: 12_582 nanoseconds.
Weight::from_ref_time(12_858_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
// Minimum execution time: 12_822 nanoseconds.
Weight::from_ref_time(13_140_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: CircuitBreaker LiquidityAddLimitPerAsset (r:1 w:0)
// Proof: CircuitBreaker LiquidityAddLimitPerAsset (max_values: None, max_size: Some(29), added: 2504, mode: MaxEncodedLen)
Expand All @@ -98,8 +102,8 @@ impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
// Storage: CircuitBreaker AllowedRemoveLiquidityAmountPerAsset (r:1 w:1)
// Proof: CircuitBreaker AllowedRemoveLiquidityAmountPerAsset (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
fn ensure_add_liquidity_limit() -> Weight {
// Minimum execution time: 19_432 nanoseconds.
Weight::from_ref_time(19_760_000 as u64)
// Minimum execution time: 19_815 nanoseconds.
Weight::from_ref_time(20_251_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
Expand All @@ -112,8 +116,8 @@ impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
// Storage: CircuitBreaker AllowedRemoveLiquidityAmountPerAsset (r:1 w:1)
// Proof: CircuitBreaker AllowedRemoveLiquidityAmountPerAsset (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
fn ensure_remove_liquidity_limit() -> Weight {
// Minimum execution time: 17_471 nanoseconds.
Weight::from_ref_time(17_880_000 as u64)
// Minimum execution time: 18_011 nanoseconds.
Weight::from_ref_time(18_202_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
Expand All @@ -122,8 +126,8 @@ impl<T: frame_system::Config> WeightInfo for HydraWeight<T> {
// Storage: CircuitBreaker TradeVolumeLimitPerAsset (r:2 w:0)
// Proof: CircuitBreaker TradeVolumeLimitPerAsset (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen)
fn ensure_pool_state_change_limit() -> Weight {
// Minimum execution time: 17_852 nanoseconds.
Weight::from_ref_time(18_129_000 as u64)
// Minimum execution time: 18_080 nanoseconds.
Weight::from_ref_time(18_365_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
Expand Down

0 comments on commit c038123

Please sign in to comment.