diff --git a/Cargo.lock b/Cargo.lock index 3a487abce..9da7cfe8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4621,7 +4621,7 @@ dependencies = [ [[package]] name = "hydradx-runtime" -version = "226.0.0" +version = "227.0.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -6986,7 +6986,7 @@ checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" [[package]] name = "pallet-asset-registry" -version = "3.2.0" +version = "3.2.1" dependencies = [ "frame-benchmarking", "frame-support", @@ -7404,7 +7404,7 @@ dependencies = [ [[package]] name = "pallet-dca" -version = "1.4.2" +version = "1.4.3" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -7606,7 +7606,7 @@ dependencies = [ [[package]] name = "pallet-ema-oracle" -version = "1.2.1" +version = "1.3.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -7625,6 +7625,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "test-utils", ] [[package]] @@ -8153,7 +8154,7 @@ dependencies = [ [[package]] name = "pallet-omnipool-liquidity-mining" -version = "2.1.3" +version = "2.1.4" dependencies = [ "frame-benchmarking", "frame-support", @@ -11391,7 +11392,7 @@ dependencies = [ [[package]] name = "runtime-integration-tests" -version = "1.20.0" +version = "1.20.1" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 30341369a..15d4791e9 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runtime-integration-tests" -version = "1.20.0" +version = "1.20.1" description = "Integration tests" authors = ["GalacticCouncil"] edition = "2021" diff --git a/integration-tests/src/oracle.rs b/integration-tests/src/oracle.rs index 860c4f0f3..08238a1c2 100644 --- a/integration-tests/src/oracle.rs +++ b/integration-tests/src/oracle.rs @@ -192,3 +192,57 @@ fn xyk_trades_with_insufficient_asset_are_not_tracked_by_oracle() { } }); } + +#[test] +fn xyk_trades_with_insufficient_asset_are_tracked_by_oracle_when_asset_is_whitelisted() { + TestNet::reset(); + + Hydra::execute_with(|| { + // arrange + hydradx_run_to_next_block(); + + assert_ok!(hydradx_runtime::Tokens::mint_into( + INSUFFICIENT_ASSET, + &ALICE.into(), + 200 * UNITS, + )); + + assert_ok!(hydradx_runtime::XYK::create_pool( + RuntimeOrigin::signed(ALICE.into()), + HDX, + 100 * UNITS, + INSUFFICIENT_ASSET, + 100 * UNITS, + )); + + assert_ok!(EmaOracle::add_oracle( + RuntimeOrigin::root(), + XYK_SOURCE, + (HDX, INSUFFICIENT_ASSET) + )); + + assert_ok!(hydradx_runtime::XYK::buy( + RuntimeOrigin::signed(ALICE.into()), + HDX, + INSUFFICIENT_ASSET, + 2 * UNITS, + 200 * UNITS, + false, + )); + + // act + // will store the data received in the sell as oracle values + hydradx_run_to_next_block(); + + // assert + for supported_period in SUPPORTED_PERIODS { + assert!(EmaOracle::get_price(HDX, INSUFFICIENT_ASSET, *supported_period, XYK_SOURCE).is_ok(),); + } + for unsupported_period in UNSUPPORTED_PERIODS { + assert_eq!( + EmaOracle::get_price(HDX, INSUFFICIENT_ASSET, *unsupported_period, XYK_SOURCE), + Err(OracleError::NotPresent) + ); + } + }); +} diff --git a/pallets/asset-registry/Cargo.toml b/pallets/asset-registry/Cargo.toml index fe331df95..27b006698 100644 --- a/pallets/asset-registry/Cargo.toml +++ b/pallets/asset-registry/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-asset-registry" -version = "3.2.0" +version = "3.2.1" description = "Pallet for asset registry management" authors = ["GalacticCouncil"] edition = "2021" diff --git a/pallets/asset-registry/src/lib.rs b/pallets/asset-registry/src/lib.rs index 3110d41db..aea283200 100644 --- a/pallets/asset-registry/src/lib.rs +++ b/pallets/asset-registry/src/lib.rs @@ -21,6 +21,7 @@ use frame_support::pallet_prelude::*; use frame_support::require_transactional; use frame_support::sp_runtime::traits::CheckedAdd; use frame_support::traits::tokens::fungibles::{Inspect as FungiblesInspect, Mutate as FungiblesMutate}; +use frame_support::traits::Contains; use frame_system::pallet_prelude::*; use scale_info::TypeInfo; use sp_arithmetic::traits::BaseArithmetic; @@ -756,3 +757,13 @@ impl Create for Pallet { } } } + +/// Oracle whitelist based on the asset sufficiency. +pub struct OracleWhitelist(PhantomData); +impl Contains<(hydradx_traits::Source, ::AssetId, ::AssetId)> + for OracleWhitelist +{ + fn contains(t: &(hydradx_traits::Source, ::AssetId, ::AssetId)) -> bool { + Pallet::::is_sufficient(t.1) && Pallet::::is_sufficient(t.2) + } +} diff --git a/pallets/dca/Cargo.toml b/pallets/dca/Cargo.toml index 4b50dba37..bf038aee2 100644 --- a/pallets/dca/Cargo.toml +++ b/pallets/dca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-dca' -version = "1.4.2" +version = "1.4.3" description = 'A pallet to manage DCA scheduling' authors = ['GalacticCouncil'] edition = '2021' diff --git a/pallets/dca/src/tests/mock.rs b/pallets/dca/src/tests/mock.rs index 454596d77..eca7e6fb5 100644 --- a/pallets/dca/src/tests/mock.rs +++ b/pallets/dca/src/tests/mock.rs @@ -146,13 +146,14 @@ parameter_types! { impl pallet_ema_oracle::Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); + type AuthorityOrigin = EnsureRoot; type BlockNumberProvider = MockBlockNumberProvider; type SupportedPeriods = SupportedPeriods; type OracleWhitelist = Everything; type MaxUniqueEntries = ConstU32<20>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); + type WeightInfo = (); } impl BlockNumberProvider for MockBlockNumberProvider { diff --git a/pallets/ema-oracle/Cargo.toml b/pallets/ema-oracle/Cargo.toml index 63dbcaf16..3dd10c436 100644 --- a/pallets/ema-oracle/Cargo.toml +++ b/pallets/ema-oracle/Cargo.toml @@ -1,6 +1,6 @@ [package] name = 'pallet-ema-oracle' -version = '1.2.1' +version = '1.3.0' description = 'Exponential moving average oracle for AMM pools' authors = ['GalacticCouncil'] edition = '2021' @@ -35,6 +35,7 @@ pretty_assertions = "1.3.0" proptest = "1.0.0" rug = { version = "1.17.0", features = ["num-traits"] } sp-io = { workspace = true } +test-utils = { workspace = true } [features] default = ['std'] diff --git a/pallets/ema-oracle/src/benchmarking.rs b/pallets/ema-oracle/src/benchmarking.rs index bbf47e954..d4336d1fa 100644 --- a/pallets/ema-oracle/src/benchmarking.rs +++ b/pallets/ema-oracle/src/benchmarking.rs @@ -23,7 +23,7 @@ pub const HDX: AssetId = 1_000; pub const DOT: AssetId = 2_000; use frame_benchmarking::benchmarks; -use frame_support::{assert_ok, traits::Hooks}; +use frame_support::{assert_ok, dispatch::RawOrigin, traits::Hooks}; #[cfg(test)] use pretty_assertions::assert_eq; @@ -33,7 +33,36 @@ use crate::Pallet as EmaOracle; /// Default oracle source. const SOURCE: Source = *b"dummysrc"; +fn fill_whitelist_storage(n: u32) { + for i in 0..n { + assert_ok!(EmaOracle::::add_oracle(RawOrigin::Root.into(), SOURCE, (HDX, i))); + } +} benchmarks! { + add_oracle { + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries - 1); + + assert_eq!(WhitelistedAssets::::get().len(), (max_entries - 1) as usize); + + }: _(RawOrigin::Root, SOURCE, (HDX, DOT)) + verify { + assert!(WhitelistedAssets::::get().contains(&(SOURCE, (HDX, DOT)))); + } + + remove_oracle { + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries - 1); + + assert_ok!(EmaOracle::::add_oracle(RawOrigin::Root.into(), SOURCE, (HDX, DOT))); + + assert_eq!(WhitelistedAssets::::get().len(), max_entries as usize); + + }: _(RawOrigin::Root, SOURCE, (HDX, DOT)) + verify { + assert!(!WhitelistedAssets::::get().contains(&(SOURCE, (HDX, DOT)))); + } + on_finalize_no_entry { let block_num: u32 = 5; }: { EmaOracle::::on_finalize(block_num.into()); } @@ -42,6 +71,9 @@ benchmarks! { #[extra] on_finalize_insert_one_token { + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries); + let block_num: BlockNumberFor = 5u32.into(); let prev_block = block_num.saturating_sub(One::one()); @@ -78,6 +110,9 @@ benchmarks! { #[extra] on_finalize_update_one_token { + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries); + let initial_data_block: BlockNumberFor = 5u32.into(); // higher update time difference might make exponentiation more expensive let block_num = initial_data_block.saturating_add(1_000_000u32.into()); @@ -119,6 +154,9 @@ benchmarks! { on_finalize_multiple_tokens { let b in 1 .. (T::MaxUniqueEntries::get() - 1); + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries); + let initial_data_block: BlockNumberFor = 5u32.into(); let block_num = initial_data_block.saturating_add(1_000_000u32.into()); @@ -167,6 +205,9 @@ benchmarks! { on_trade_multiple_tokens { let b in 1 .. (T::MaxUniqueEntries::get() - 1); + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries); + let initial_data_block: BlockNumberFor = 5u32.into(); let block_num = initial_data_block.saturating_add(1_000_000u32.into()); @@ -229,6 +270,9 @@ benchmarks! { on_liquidity_changed_multiple_tokens { let b in 1 .. (T::MaxUniqueEntries::get() - 1); + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries); + let initial_data_block: BlockNumberFor = 5u32.into(); let block_num = initial_data_block.saturating_add(1_000_000u32.into()); @@ -295,6 +339,9 @@ benchmarks! { } get_entry { + let max_entries = <::MaxUniqueEntries as Get>::get(); + fill_whitelist_storage::(max_entries); + let initial_data_block: BlockNumberFor = 5u32.into(); let oracle_age: BlockNumberFor = 999_999u32.into(); let block_num = initial_data_block.saturating_add(oracle_age.saturating_add(One::one())); diff --git a/pallets/ema-oracle/src/lib.rs b/pallets/ema-oracle/src/lib.rs index aba2fb22d..b62ac2e63 100644 --- a/pallets/ema-oracle/src/lib.rs +++ b/pallets/ema-oracle/src/lib.rs @@ -115,8 +115,8 @@ impl BenchmarkHelper for () { #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::BoundedBTreeMap; - use frame_system::pallet_prelude::BlockNumberFor; + use frame_support::{BoundedBTreeMap, BoundedBTreeSet}; + use frame_system::pallet_prelude::{BlockNumberFor, OriginFor}; #[pallet::pallet] pub struct Pallet(_); @@ -128,6 +128,9 @@ pub mod pallet { /// Weight information for the extrinsics. type WeightInfo: WeightInfo; + /// Origin that can enable oracle for assets that would be rejected by `OracleWhitelist` otherwise. + type AuthorityOrigin: EnsureOrigin; + /// Provider for the current block number. type BlockNumberProvider: BlockNumberProvider>; @@ -149,10 +152,17 @@ pub mod pallet { pub enum Error { TooManyUniqueEntries, OnTradeValueZero, + OracleNotFound, } #[pallet::event] - pub enum Event {} + #[pallet::generate_deposit(pub(crate) fn deposit_event)] + pub enum Event { + /// Oracle was added to the whitelist. + AddedToWhitelist { source: Source, assets: (AssetId, AssetId) }, + /// Oracle was removed from the whitelist. + RemovedFromWhitelist { source: Source, assets: (AssetId, AssetId) }, + } /// Accumulator for oracle data in current block that will be recorded at the end of the block. #[pallet::storage] @@ -163,7 +173,7 @@ pub mod pallet { ValueQuery, >; - /// Orace storage keyed by data source, involved asset ids and the period length of the oracle. + /// Oracle storage keyed by data source, involved asset ids and the period length of the oracle. /// /// Stores the data entry as well as the block number when the oracle was first initialized. #[pallet::storage] @@ -179,6 +189,11 @@ pub mod pallet { OptionQuery, >; + /// Assets that are whitelisted and tracked by the pallet. + #[pallet::storage] + pub type WhitelistedAssets = + StorageValue<_, BoundedBTreeSet<(Source, (AssetId, AssetId)), T::MaxUniqueEntries>, ValueQuery>; + #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] pub struct GenesisConfig { @@ -232,7 +247,51 @@ pub mod pallet { } #[pallet::call] - impl Pallet {} + impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight(::WeightInfo::add_oracle())] + pub fn add_oracle(origin: OriginFor, source: Source, assets: (AssetId, AssetId)) -> DispatchResult { + T::AuthorityOrigin::ensure_origin(origin)?; + + let assets = ordered_pair(assets.0, assets.1); + + WhitelistedAssets::::mutate(|list| { + list.try_insert((source, (assets))) + .map_err(|_| Error::::TooManyUniqueEntries) + })?; + + Self::deposit_event(Event::AddedToWhitelist { source, assets }); + + Ok(()) + } + + #[pallet::call_index(1)] + #[pallet::weight(::WeightInfo::remove_oracle())] + pub fn remove_oracle(origin: OriginFor, source: Source, assets: (AssetId, AssetId)) -> DispatchResult { + T::AuthorityOrigin::ensure_origin(origin)?; + + let assets = ordered_pair(assets.0, assets.1); + + WhitelistedAssets::::mutate(|list| { + ensure!(list.remove(&(source, (assets))), Error::::OracleNotFound); + + Ok::<(), DispatchError>(()) + })?; + + // remove oracle from the storage + for period in T::SupportedPeriods::get().into_iter() { + let _ = Accumulator::::mutate(|accumulator| { + accumulator.remove(&(source, assets)); + Ok::<(), ()>(()) + }); + Oracles::::remove((source, assets, period)); + } + + Self::deposit_event(Event::RemovedFromWhitelist { source, assets }); + + Ok(()) + } + } } impl Pallet { @@ -244,6 +303,7 @@ impl Pallet { oracle_entry: OracleEntry>, ) -> Result<(), ()> { if !T::OracleWhitelist::contains(&(src, assets.0, assets.1)) { + // if we don't track oracle for given asset pair, don't throw error return Ok(()); } @@ -592,3 +652,11 @@ impl AggregatedPriceOracle, Price> for Pal Self::get_entry_weight() } } + +/// Oracle whitelist based on the pallet's storage. +pub struct OracleWhitelist(PhantomData); +impl Contains<(Source, AssetId, AssetId)> for OracleWhitelist { + fn contains(t: &(Source, AssetId, AssetId)) -> bool { + WhitelistedAssets::::get().contains(&(t.0, (t.1, t.2))) + } +} diff --git a/pallets/ema-oracle/src/tests/add_and_remove_oracle.rs b/pallets/ema-oracle/src/tests/add_and_remove_oracle.rs new file mode 100644 index 000000000..17773c034 --- /dev/null +++ b/pallets/ema-oracle/src/tests/add_and_remove_oracle.rs @@ -0,0 +1,182 @@ +// This file is part of pallet-ema-oracle. + +// Copyright (C) 2022-2023 Intergalactic, Limited (GIB). +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use super::*; +pub use mock::{expect_events, EmaOracle, RuntimeOrigin, Test, DOT, HDX, ORACLE_ENTRY_1}; + +use frame_support::{assert_noop, assert_ok}; +use pretty_assertions::assert_eq; + +pub fn new_test_ext() -> sp_io::TestExternalities { + ExtBuilder::default().build() +} + +#[test] +fn add_oracle_should_add_entry_to_storage() { + new_test_ext().execute_with(|| { + assert_ok!(EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT))); + + expect_events(vec![Event::AddedToWhitelist { + source: SOURCE, + assets: (HDX, DOT), + } + .into()]); + }); +} + +#[test] +fn add_oracle_should_store_assets_in_correct_order() { + new_test_ext().execute_with(|| { + assert_ok!(EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (DOT, HDX))); + + expect_events(vec![Event::AddedToWhitelist { + source: SOURCE, + assets: (HDX, DOT), + } + .into()]); + + assert!(WhitelistedAssets::::get().contains(&(SOURCE, (HDX, DOT)))); + }); +} + +#[test] +fn add_oracle_should_not_fail_when_storage_entry_already_added() { + new_test_ext().execute_with(|| { + assert_ok!(EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT))); + assert_ok!(EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT))); + }); +} + +#[test] +fn add_oracle_should_fail_when_storage_is_full() { + new_test_ext().execute_with(|| { + let max_entries = <::MaxUniqueEntries as Get>::get(); + + for i in 0..max_entries { + assert_ok!(EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (HDX, i))); + } + + assert_eq!(WhitelistedAssets::::get().len(), max_entries as usize); + + assert_noop!( + EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT)), + Error::::TooManyUniqueEntries + ); + }); +} + +#[test] +fn remove_oracle_should_remove_entry_from_storage() { + new_test_ext().execute_with(|| { + assert_ok!(EmaOracle::add_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT))); + assert!(WhitelistedAssets::::get().contains(&(SOURCE, (HDX, DOT)))); + + System::set_block_number(5); + EmaOracle::on_initialize(5); + + assert_ok!(EmaOracle::on_trade(SOURCE, ordered_pair(HDX, DOT), ORACLE_ENTRY_1)); + + EmaOracle::on_finalize(5); + System::set_block_number(6); + EmaOracle::on_initialize(6); + + for period in ::SupportedPeriods::get() { + assert_eq!(get_oracle_entry(HDX, DOT, period), Some(ORACLE_ENTRY_1),); + } + + assert_ok!(EmaOracle::remove_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT))); + assert!(!WhitelistedAssets::::get().contains(&(SOURCE, (HDX, DOT)))); + + for period in ::SupportedPeriods::get() { + assert!(get_oracle_entry(HDX, DOT, period).is_none()); + } + + EmaOracle::on_finalize(6); + System::set_block_number(7); + EmaOracle::on_initialize(7); + + expect_events(vec![Event::RemovedFromWhitelist { + source: SOURCE, + assets: (HDX, DOT), + } + .into()]); + }); +} + +#[test] +fn remove_oracle_should_fail_when_oracle_not_tracked() { + new_test_ext().execute_with(|| { + assert_noop!( + EmaOracle::remove_oracle(RuntimeOrigin::root(), SOURCE, (HDX, DOT)), + Error::::OracleNotFound + ); + }); +} + +#[test] +fn on_trade_should_include_whitelisted_oracle_for_correct_source() { + new_test_ext().execute_with(|| { + assert_ok!(EmaOracle::add_oracle( + RuntimeOrigin::root(), + SOURCE, + (HDX, INSUFFICIENT_ASSET) + )); + + assert!(get_accumulator_entry(SOURCE, (HDX, INSUFFICIENT_ASSET)).is_none()); + + assert_ok!(OnActivityHandler::::on_trade( + SOURCE, + HDX, + INSUFFICIENT_ASSET, + 1_000, + 500, + 2_000, + 1_000, + Price::new(2_000, 1_000) + )); + + assert!(get_accumulator_entry(SOURCE, (HDX, INSUFFICIENT_ASSET)).is_some()); + assert!(get_accumulator_entry([0; 8], (HDX, INSUFFICIENT_ASSET)).is_none()); + }); +} + +#[test] +fn on_liquidity_changed_should_include_whitelisted_oracle_for_correct_source() { + new_test_ext().execute_with(|| { + assert_ok!(EmaOracle::add_oracle( + RuntimeOrigin::root(), + SOURCE, + (HDX, INSUFFICIENT_ASSET) + )); + + assert!(get_accumulator_entry(SOURCE, (HDX, INSUFFICIENT_ASSET)).is_none()); + + assert_ok!(OnActivityHandler::::on_liquidity_changed( + SOURCE, + HDX, + INSUFFICIENT_ASSET, + 1_000, + 500, + 2_000, + 1_000, + Price::new(2_000, 1_000), + )); + + assert!(get_accumulator_entry(SOURCE, (HDX, INSUFFICIENT_ASSET)).is_some()); + assert!(get_accumulator_entry([0; 8], (HDX, INSUFFICIENT_ASSET)).is_none()); + }); +} diff --git a/pallets/ema-oracle/src/tests/mock.rs b/pallets/ema-oracle/src/tests/mock.rs index e076b485c..cb492235b 100644 --- a/pallets/ema-oracle/src/tests/mock.rs +++ b/pallets/ema-oracle/src/tests/mock.rs @@ -27,6 +27,7 @@ use frame_support::sp_runtime::{ }; use frame_support::traits::{Contains, Everything}; use frame_support::BoundedVec; +use frame_system::EnsureRoot; use hydradx_traits::OraclePeriod::{self, *}; use hydradx_traits::Source; use hydradx_traits::{AssetPairAccountIdFor, Liquidity, Volume}; @@ -34,6 +35,7 @@ use sp_core::H256; use crate::types::{AssetId, Balance, Price}; pub type BlockNumber = u64; +pub type AccountId = u64; type Block = frame_system::mocking::MockBlock; @@ -124,22 +126,23 @@ parameter_types! { pub SupportedPeriods: BoundedVec> = bounded_vec![LastBlock, TenMinutes, Day, Week]; } -pub struct SufficientAssetsFilter; -impl Contains<(Source, AssetId, AssetId)> for SufficientAssetsFilter { +pub struct OracleWhitelist; +impl Contains<(Source, AssetId, AssetId)> for OracleWhitelist { fn contains(t: &(Source, AssetId, AssetId)) -> bool { - t.1 != INSUFFICIENT_ASSET && t.2 != INSUFFICIENT_ASSET + (t.1 != INSUFFICIENT_ASSET && t.2 != INSUFFICIENT_ASSET) || ema_oracle::OracleWhitelist::::contains(t) } } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); + type AuthorityOrigin = EnsureRoot; type BlockNumberProvider = System; type SupportedPeriods = SupportedPeriods; - type OracleWhitelist = SufficientAssetsFilter; + type OracleWhitelist = OracleWhitelist; type MaxUniqueEntries = ConstU32<45>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); + type WeightInfo = (); } pub type InitialDataEntry = (Source, (AssetId, AssetId), Price, Liquidity); @@ -166,8 +169,12 @@ impl ExtBuilder { let mut ext: sp_io::TestExternalities = t.into(); ext.execute_with(|| { - System::set_block_number(0); + System::set_block_number(1); }); ext } } + +pub fn expect_events(e: Vec) { + test_utils::expect_events::(e); +} diff --git a/pallets/ema-oracle/src/tests/mod.rs b/pallets/ema-oracle/src/tests/mod.rs index 1d061b0b3..062cfc283 100644 --- a/pallets/ema-oracle/src/tests/mod.rs +++ b/pallets/ema-oracle/src/tests/mod.rs @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +mod add_and_remove_oracle; mod invariants; mod mock; @@ -474,13 +475,13 @@ fn oracle_volume_should_factor_in_asset_order() { price: Price::new(2_000, 1), volume: Volume::from_a_in_b_out(2_000_000, 1_000), liquidity: (2_000, 1).into(), - updated_at: 0, + updated_at: 1, }; let second_entry = OracleEntry { price: Price::new(2_000, 1), volume: Volume::from_a_out_b_in(2_000_000, 1_000), liquidity: (2_000, 1).into(), - updated_at: 0, + updated_at: 1, }; let result = second_entry.with_added_volume_from(&first_entry); diff --git a/pallets/ema-oracle/src/weights.rs b/pallets/ema-oracle/src/weights.rs index 56c3c5b5c..9f5677c51 100644 --- a/pallets/ema-oracle/src/weights.rs +++ b/pallets/ema-oracle/src/weights.rs @@ -18,26 +18,24 @@ //! Autogenerated weights for `pallet_ema_oracle` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-12-12, STEPS: `5`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-03-05, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 // Executed Command: // target/release/hydradx // benchmark // pallet -// --pallet=pallet-ema-oracle +// --chain=dev +// --steps=10 +// --repeat=30 // --wasm-execution=compiled // --heap-pages=4096 -// --chain=dev +// --template=.maintain/pallet-weight-template-no-back.hbs +// --pallet=pallet-ema-oracle +// --output=weights-1.1.0/oracle.rs // --extrinsic=* -// --steps=5 -// --repeat=20 -// --output -// ./weights-1.1.0/ema_oracle.rs -// --template -// .maintain/pallet-weight-template-no-back.hbs #![allow(unused_parens)] #![allow(unused_imports)] @@ -51,6 +49,8 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_ema_oracle. pub trait WeightInfo { + fn add_oracle() -> Weight; + fn remove_oracle() -> Weight; fn on_finalize_no_entry() -> Weight; fn on_finalize_multiple_tokens(b: u32) -> Weight; fn on_trade_multiple_tokens(b: u32) -> Weight; @@ -61,14 +61,36 @@ pub trait WeightInfo { pub struct BasiliskWeight(PhantomData); impl WeightInfo for BasiliskWeight { + /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:1) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + fn add_oracle() -> Weight { + // Proof Size summary in bytes: + // Measured: `860` + // Estimated: `2126` + // Minimum execution time: 21_341_000 picoseconds. + Weight::from_parts(21_667_000, 2126) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:1) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + fn remove_oracle() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `2126` + // Minimum execution time: 21_553_000 picoseconds. + Weight::from_parts(21_866_000, 2126) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `EmaOracle::Accumulator` (r:1 w:0) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn on_finalize_no_entry() -> Weight { // Proof Size summary in bytes: // Measured: `208` // Estimated: `7406` - // Minimum execution time: 3_261_000 picoseconds. - Weight::from_parts(3_342_000, 7406).saturating_add(T::DbWeight::get().reads(1)) + // Minimum execution time: 3_165_000 picoseconds. + Weight::from_parts(3_271_000, 7406).saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) @@ -77,12 +99,12 @@ impl WeightInfo for BasiliskWeight { /// The range of component `b` is `[1, 39]`. fn on_finalize_multiple_tokens(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + b * (626 ±0)` + // Measured: `304 + b * (626 ±0)` // Estimated: `7406 + b * (7956 ±0)` - // Minimum execution time: 49_005_000 picoseconds. - Weight::from_parts(11_980_224, 7406) - // Standard Error: 17_790 - .saturating_add(Weight::from_parts(36_916_571, 0).saturating_mul(b.into())) + // Minimum execution time: 48_505_000 picoseconds. + Weight::from_parts(12_673_348, 7406) + // Standard Error: 31_644 + .saturating_add(Weight::from_parts(36_427_193, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -96,12 +118,12 @@ impl WeightInfo for BasiliskWeight { /// The range of component `b` is `[1, 39]`. fn on_trade_multiple_tokens(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `718 + b * (163 ±0)` + // Measured: `751 + b * (163 ±0)` // Estimated: `7406` - // Minimum execution time: 18_948_000 picoseconds. - Weight::from_parts(19_508_272, 7406) - // Standard Error: 3_859 - .saturating_add(Weight::from_parts(435_799, 0).saturating_mul(b.into())) + // Minimum execution time: 18_943_000 picoseconds. + Weight::from_parts(19_294_596, 7406) + // Standard Error: 3_556 + .saturating_add(Weight::from_parts(423_769, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -112,12 +134,12 @@ impl WeightInfo for BasiliskWeight { /// The range of component `b` is `[1, 39]`. fn on_liquidity_changed_multiple_tokens(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `718 + b * (163 ±0)` + // Measured: `751 + b * (163 ±0)` // Estimated: `7406` - // Minimum execution time: 18_875_000 picoseconds. - Weight::from_parts(19_397_429, 7406) - // Standard Error: 4_124 - .saturating_add(Weight::from_parts(438_627, 0).saturating_mul(b.into())) + // Minimum execution time: 19_079_000 picoseconds. + Weight::from_parts(19_403_394, 7406) + // Standard Error: 3_730 + .saturating_add(Weight::from_parts(422_560, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -125,23 +147,45 @@ impl WeightInfo for BasiliskWeight { /// Proof: `EmaOracle::Oracles` (`max_values`: None, `max_size`: Some(177), added: 2652, mode: `MaxEncodedLen`) fn get_entry() -> Weight { // Proof Size summary in bytes: - // Measured: `604` + // Measured: `638` // Estimated: `6294` - // Minimum execution time: 18_746_000 picoseconds. - Weight::from_parts(19_158_000, 6294).saturating_add(T::DbWeight::get().reads(2)) + // Minimum execution time: 18_991_000 picoseconds. + Weight::from_parts(19_258_000, 6294).saturating_add(T::DbWeight::get().reads(2)) } } // For backwards compatibility and tests impl WeightInfo for () { + /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:1) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + fn add_oracle() -> Weight { + // Proof Size summary in bytes: + // Measured: `860` + // Estimated: `2126` + // Minimum execution time: 21_341_000 picoseconds. + Weight::from_parts(21_667_000, 2126) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:1) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + fn remove_oracle() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `2126` + // Minimum execution time: 21_553_000 picoseconds. + Weight::from_parts(21_866_000, 2126) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } /// Storage: `EmaOracle::Accumulator` (r:1 w:0) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn on_finalize_no_entry() -> Weight { // Proof Size summary in bytes: // Measured: `208` // Estimated: `7406` - // Minimum execution time: 3_261_000 picoseconds. - Weight::from_parts(3_342_000, 7406).saturating_add(RocksDbWeight::get().reads(1)) + // Minimum execution time: 3_165_000 picoseconds. + Weight::from_parts(3_271_000, 7406).saturating_add(RocksDbWeight::get().reads(1)) } /// Storage: `EmaOracle::Accumulator` (r:1 w:1) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) @@ -150,12 +194,12 @@ impl WeightInfo for () { /// The range of component `b` is `[1, 39]`. fn on_finalize_multiple_tokens(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + b * (626 ±0)` + // Measured: `304 + b * (626 ±0)` // Estimated: `7406 + b * (7956 ±0)` - // Minimum execution time: 49_005_000 picoseconds. - Weight::from_parts(11_980_224, 7406) - // Standard Error: 17_790 - .saturating_add(Weight::from_parts(36_916_571, 0).saturating_mul(b.into())) + // Minimum execution time: 48_505_000 picoseconds. + Weight::from_parts(12_673_348, 7406) + // Standard Error: 31_644 + .saturating_add(Weight::from_parts(36_427_193, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(b.into()))) .saturating_add(RocksDbWeight::get().writes(1)) @@ -169,12 +213,12 @@ impl WeightInfo for () { /// The range of component `b` is `[1, 39]`. fn on_trade_multiple_tokens(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `718 + b * (163 ±0)` + // Measured: `751 + b * (163 ±0)` // Estimated: `7406` - // Minimum execution time: 18_948_000 picoseconds. - Weight::from_parts(19_508_272, 7406) - // Standard Error: 3_859 - .saturating_add(Weight::from_parts(435_799, 0).saturating_mul(b.into())) + // Minimum execution time: 18_943_000 picoseconds. + Weight::from_parts(19_294_596, 7406) + // Standard Error: 3_556 + .saturating_add(Weight::from_parts(423_769, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -185,12 +229,12 @@ impl WeightInfo for () { /// The range of component `b` is `[1, 39]`. fn on_liquidity_changed_multiple_tokens(b: u32) -> Weight { // Proof Size summary in bytes: - // Measured: `718 + b * (163 ±0)` + // Measured: `751 + b * (163 ±0)` // Estimated: `7406` - // Minimum execution time: 18_875_000 picoseconds. - Weight::from_parts(19_397_429, 7406) - // Standard Error: 4_124 - .saturating_add(Weight::from_parts(438_627, 0).saturating_mul(b.into())) + // Minimum execution time: 19_079_000 picoseconds. + Weight::from_parts(19_403_394, 7406) + // Standard Error: 3_730 + .saturating_add(Weight::from_parts(422_560, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -198,9 +242,9 @@ impl WeightInfo for () { /// Proof: `EmaOracle::Oracles` (`max_values`: None, `max_size`: Some(177), added: 2652, mode: `MaxEncodedLen`) fn get_entry() -> Weight { // Proof Size summary in bytes: - // Measured: `604` + // Measured: `638` // Estimated: `6294` - // Minimum execution time: 18_746_000 picoseconds. - Weight::from_parts(19_158_000, 6294).saturating_add(RocksDbWeight::get().reads(2)) + // Minimum execution time: 18_991_000 picoseconds. + Weight::from_parts(19_258_000, 6294).saturating_add(RocksDbWeight::get().reads(2)) } } diff --git a/pallets/omnipool-liquidity-mining/Cargo.toml b/pallets/omnipool-liquidity-mining/Cargo.toml index c1315670b..f4998e812 100644 --- a/pallets/omnipool-liquidity-mining/Cargo.toml +++ b/pallets/omnipool-liquidity-mining/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-omnipool-liquidity-mining" -version = "2.1.3" +version = "2.1.4" authors = ['GalacticCouncil'] edition = "2021" license = "Apache-2.0" diff --git a/pallets/omnipool-liquidity-mining/src/tests/mock.rs b/pallets/omnipool-liquidity-mining/src/tests/mock.rs index 357b10548..bb5987972 100644 --- a/pallets/omnipool-liquidity-mining/src/tests/mock.rs +++ b/pallets/omnipool-liquidity-mining/src/tests/mock.rs @@ -247,13 +247,14 @@ parameter_types! { impl pallet_ema_oracle::Config for Test { type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); + type AuthorityOrigin = EnsureRoot; type BlockNumberProvider = MockBlockNumberProvider; type SupportedPeriods = SupportedPeriods; type OracleWhitelist = Everything; type MaxUniqueEntries = ConstU32<20>; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = (); + type WeightInfo = (); } parameter_types! { diff --git a/runtime/hydradx/Cargo.toml b/runtime/hydradx/Cargo.toml index 1202cae2b..ff05f3b82 100644 --- a/runtime/hydradx/Cargo.toml +++ b/runtime/hydradx/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hydradx-runtime" -version = "226.0.0" +version = "227.0.0" authors = ["GalacticCouncil"] edition = "2021" license = "Apache 2.0" diff --git a/runtime/hydradx/src/assets.rs b/runtime/hydradx/src/assets.rs index 79c8293c6..97183c74b 100644 --- a/runtime/hydradx/src/assets.rs +++ b/runtime/hydradx/src/assets.rs @@ -497,25 +497,31 @@ parameter_types! { OraclePeriod::LastBlock, OraclePeriod::Short, OraclePeriod::TenMinutes]); } -pub struct SufficientAssetsFilter; -impl Contains<(Source, AssetId, AssetId)> for SufficientAssetsFilter { +pub struct OracleWhitelist(PhantomData); +impl Contains<(Source, AssetId, AssetId)> for OracleWhitelist +where + Runtime: pallet_ema_oracle::Config + pallet_asset_registry::Config, + AssetId: From<::AssetId>, +{ fn contains(t: &(Source, AssetId, AssetId)) -> bool { - AssetRegistry::is_sufficient(t.1) && AssetRegistry::is_sufficient(t.2) + pallet_asset_registry::OracleWhitelist::::contains(t) + || pallet_ema_oracle::OracleWhitelist::::contains(t) } } impl pallet_ema_oracle::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::ema_oracle::HydraWeight; + type AuthorityOrigin = SuperMajorityTechCommittee; /// The definition of the oracle time periods currently assumes a 6 second block time. /// We use the parachain blocks anyway, because we want certain guarantees over how many blocks correspond /// to which smoothing factor. type BlockNumberProvider = System; type SupportedPeriods = SupportedPeriods; - type OracleWhitelist = SufficientAssetsFilter; + type OracleWhitelist = OracleWhitelist; /// With every asset trading against LRNA we will only have as many pairs as there will be assets, so /// 40 seems a decent upper bound for the foreseeable future. type MaxUniqueEntries = ConstU32<40>; + type WeightInfo = weights::ema_oracle::HydraWeight; #[cfg(feature = "runtime-benchmarks")] /// Should take care of the overhead introduced by `OracleWhitelist`. type BenchmarkHelper = RegisterAsset; diff --git a/runtime/hydradx/src/lib.rs b/runtime/hydradx/src/lib.rs index a4af2b3ad..36a3c5bb2 100644 --- a/runtime/hydradx/src/lib.rs +++ b/runtime/hydradx/src/lib.rs @@ -109,7 +109,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("hydradx"), impl_name: create_runtime_str!("hydradx"), authoring_version: 1, - spec_version: 226, + spec_version: 227, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/hydradx/src/weights/ema_oracle.rs b/runtime/hydradx/src/weights/ema_oracle.rs index e0e7ee958..521b361eb 100644 --- a/runtime/hydradx/src/weights/ema_oracle.rs +++ b/runtime/hydradx/src/weights/ema_oracle.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for `pallet_ema_oracle` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-29, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-03-05, STEPS: `10`, REPEAT: `30`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `bench-bot`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 @@ -50,14 +50,36 @@ use pallet_ema_oracle::weights::WeightInfo; /// Weight functions for `pallet_ema_oracle`. pub struct HydraWeight(PhantomData); impl WeightInfo for HydraWeight { + /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:1) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + fn add_oracle() -> Weight { + // Proof Size summary in bytes: + // Measured: `860` + // Estimated: `2126` + // Minimum execution time: 21_341_000 picoseconds. + Weight::from_parts(21_667_000, 2126) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `EmaOracle::WhitelistedAssets` (r:1 w:1) + /// Proof: `EmaOracle::WhitelistedAssets` (`max_values`: Some(1), `max_size`: Some(641), added: 1136, mode: `MaxEncodedLen`) + fn remove_oracle() -> Weight { + // Proof Size summary in bytes: + // Measured: `876` + // Estimated: `2126` + // Minimum execution time: 21_553_000 picoseconds. + Weight::from_parts(21_866_000, 2126) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `EmaOracle::Accumulator` (r:1 w:0) /// Proof: `EmaOracle::Accumulator` (`max_values`: Some(1), `max_size`: Some(5921), added: 6416, mode: `MaxEncodedLen`) fn on_finalize_no_entry() -> Weight { // Proof Size summary in bytes: // Measured: `208` // Estimated: `7406` - // Minimum execution time: 3_261_000 picoseconds. - Weight::from_parts(3_342_000, 7406) + // Minimum execution time: 3_165_000 picoseconds. + Weight::from_parts(3_271_000, 7406) .saturating_add(T::DbWeight::get().reads(1)) } /// Storage: `EmaOracle::Accumulator` (r:1 w:1) @@ -67,12 +89,12 @@ impl WeightInfo for HydraWeight { /// The range of component `b` is `[1, 39]`. fn on_finalize_multiple_tokens(b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `270 + b * (626 ±0)` + // Measured: `304 + b * (626 ±0)` // Estimated: `7406 + b * (7956 ±0)` - // Minimum execution time: 49_005_000 picoseconds. - Weight::from_parts(11_980_224, 7406) - // Standard Error: 17_790 - .saturating_add(Weight::from_parts(36_916_571, 0).saturating_mul(b.into())) + // Minimum execution time: 48_505_000 picoseconds. + Weight::from_parts(12_673_348, 7406) + // Standard Error: 31_644 + .saturating_add(Weight::from_parts(36_427_193, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(b.into()))) .saturating_add(T::DbWeight::get().writes(1)) @@ -86,12 +108,12 @@ impl WeightInfo for HydraWeight { /// The range of component `b` is `[1, 39]`. fn on_trade_multiple_tokens(b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `718 + b * (163 ±0)` + // Measured: `751 + b * (163 ±0)` // Estimated: `7406` - // Minimum execution time: 18_948_000 picoseconds. - Weight::from_parts(19_508_272, 7406) - // Standard Error: 3_859 - .saturating_add(Weight::from_parts(435_799, 0).saturating_mul(b.into())) + // Minimum execution time: 18_943_000 picoseconds. + Weight::from_parts(19_294_596, 7406) + // Standard Error: 3_556 + .saturating_add(Weight::from_parts(423_769, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -102,12 +124,12 @@ impl WeightInfo for HydraWeight { /// The range of component `b` is `[1, 39]`. fn on_liquidity_changed_multiple_tokens(b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `718 + b * (163 ±0)` + // Measured: `751 + b * (163 ±0)` // Estimated: `7406` - // Minimum execution time: 18_875_000 picoseconds. - Weight::from_parts(19_397_429, 7406) - // Standard Error: 4_124 - .saturating_add(Weight::from_parts(438_627, 0).saturating_mul(b.into())) + // Minimum execution time: 19_079_000 picoseconds. + Weight::from_parts(19_403_394, 7406) + // Standard Error: 3_730 + .saturating_add(Weight::from_parts(422_560, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -115,10 +137,10 @@ impl WeightInfo for HydraWeight { /// Proof: `EmaOracle::Oracles` (`max_values`: None, `max_size`: Some(177), added: 2652, mode: `MaxEncodedLen`) fn get_entry() -> Weight { // Proof Size summary in bytes: - // Measured: `604` + // Measured: `638` // Estimated: `6294` - // Minimum execution time: 18_746_000 picoseconds. - Weight::from_parts(19_158_000, 6294) + // Minimum execution time: 18_991_000 picoseconds. + Weight::from_parts(19_258_000, 6294) .saturating_add(T::DbWeight::get().reads(2)) } }