Skip to content

Commit

Permalink
Fix benchmarks && add weights (#986)
Browse files Browse the repository at this point in the history
* Add some weights

* fix slp

* add generate weights

* fix ci

---------

Co-authored-by: hqwangningbo <[email protected]>
  • Loading branch information
TomatoAres and hqwangningbo authored Jun 13, 2023
1 parent cfcd075 commit 5ae7f34
Show file tree
Hide file tree
Showing 28 changed files with 1,679 additions and 3,243 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

28 changes: 28 additions & 0 deletions pallets/asset-registry/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,34 @@ benchmarks! {
assert_eq!(CurrencyIdToWeights::<T>::get(CurrencyId::Token2(0)), Some(Weight::from_parts(2000_000_000, u64::MAX)));
}

force_set_multilocation {
let origin = T::RegisterOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
let metadata = AssetMetadata {
name: b"Bifrost Native Coin".to_vec(),
symbol: b"BNC".to_vec(),
decimals: 12,
minimal_balance: BalanceOf::<T>::unique_saturated_from(0u128),
};
// v3
let location = VersionedMultiLocation::V3(MultiLocation {
parents: 1,
interior: Junctions::X1(Parachain(2001)),
});

let multi_location: MultiLocation = location.clone().try_into().unwrap();

assert_ok!(AssetRegistry::<T>::register_token_metadata(
origin.clone(),
Box::new(metadata.clone())
));

let call = Call::<T>::force_set_multilocation {
currency_id: CurrencyId::Token2(0),
location:Box::new(location.clone()),
weight:Weight::from_parts(2000_000_000, u64::MAX),
};
}: {call.dispatch_bypass_filter(origin)?}

impl_benchmark_test_suite!(
AssetRegistry,
crate::mock::ExtBuilder::default().build(),
Expand Down
117 changes: 70 additions & 47 deletions pallets/asset-registry/src/weights.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
// This file is part of Bifrost.

// Copyright (C) 2019-2022 Liebi Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// 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.

//! Autogenerated weights for bifrost_asset_registry
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-05-18, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-06-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `VM-16-3-ubuntu`, CPU: `Intel(R) Xeon(R) Platinum 8374C CPU @ 2.70GHz`
//! HOSTNAME: `bifrost-jenkins`, CPU: `Intel(R) Xeon(R) CPU E5-26xx v4`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("bifrost-kusama-local"), DB CACHE: 1024

// Executed Command:
Expand All @@ -19,7 +42,7 @@
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./runtime/bifrost-kusama/src/weights/bifrost_asset_registry.rs
// --output=./pallets/asset-registry/src/weights.rs
// --template=./frame-weight-template.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
Expand All @@ -42,7 +65,7 @@ pub trait WeightInfo {
fn force_set_multilocation() -> Weight;
}

/// Weights for bifrost_asset_registry using the Substrate node and recommended hardware.
/// Weights for bifrost_asset_registry using the Bifrost node and recommended hardware.
pub struct BifrostWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
/// Storage: AssetRegistry LocationToCurrencyIds (r:1 w:1)
Expand All @@ -55,8 +78,8 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `80`
// Estimated: `7665`
// Minimum execution time: 26_080_000 picoseconds.
Weight::from_parts(26_753_000, 7665)
// Minimum execution time: 48_093_000 picoseconds.
Weight::from_parts(49_225_000, 7665)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -70,8 +93,8 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `212`
// Estimated: `8061`
// Minimum execution time: 30_124_000 picoseconds.
Weight::from_parts(30_890_000, 8061)
// Minimum execution time: 49_877_000 picoseconds.
Weight::from_parts(50_828_000, 8061)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
Expand All @@ -83,8 +106,8 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `569`
// Estimated: `4108`
// Minimum execution time: 22_881_000 picoseconds.
Weight::from_parts(23_551_000, 4108)
// Minimum execution time: 38_037_000 picoseconds.
Weight::from_parts(39_203_000, 4108)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
Expand All @@ -94,8 +117,8 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `772`
// Estimated: `5722`
// Minimum execution time: 26_008_000 picoseconds.
Weight::from_parts(27_051_000, 5722)
// Minimum execution time: 44_673_000 picoseconds.
Weight::from_parts(46_256_000, 5722)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -105,8 +128,8 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `698`
// Estimated: `5648`
// Minimum execution time: 25_272_000 picoseconds.
Weight::from_parts(26_140_000, 5648)
// Minimum execution time: 42_165_000 picoseconds.
Weight::from_parts(43_326_000, 5648)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -116,8 +139,8 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `756`
// Estimated: `5706`
// Minimum execution time: 27_239_000 picoseconds.
Weight::from_parts(28_326_000, 5706)
// Minimum execution time: 46_508_000 picoseconds.
Weight::from_parts(47_756_000, 5706)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
Expand All @@ -133,27 +156,27 @@ impl<T: frame_system::Config> WeightInfo for BifrostWeight<T> {
// Proof Size summary in bytes:
// Measured: `676`
// Estimated: `10129`
// Minimum execution time: 23_594_000 picoseconds.
Weight::from_parts(24_131_000, 10129)
// Minimum execution time: 38_426_000 picoseconds.
Weight::from_parts(39_937_000, 10129)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0)
/// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry LocationToCurrencyIds (r:1 w:1)
/// Storage: AssetRegistry LocationToCurrencyIds (r:0 w:1)
/// Proof Skipped: AssetRegistry LocationToCurrencyIds (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:1)
/// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry CurrencyIdToWeights (r:0 w:1)
/// Proof Skipped: AssetRegistry CurrencyIdToWeights (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry CurrencyIdToLocations (r:0 w:1)
/// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured)
fn force_set_multilocation() -> Weight {
// Proof Size summary in bytes:
// Measured: `676`
// Estimated: `10129`
// Minimum execution time: 23_594_000 picoseconds.
Weight::from_parts(24_131_000, 10129)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
// Estimated: `5179`
// Minimum execution time: 44_818_000 picoseconds.
Weight::from_parts(46_431_000, 5179)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
}

Expand All @@ -169,8 +192,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `80`
// Estimated: `7665`
// Minimum execution time: 26_080_000 picoseconds.
Weight::from_parts(26_753_000, 7665)
// Minimum execution time: 48_093_000 picoseconds.
Weight::from_parts(49_225_000, 7665)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand All @@ -184,8 +207,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `212`
// Estimated: `8061`
// Minimum execution time: 30_124_000 picoseconds.
Weight::from_parts(30_890_000, 8061)
// Minimum execution time: 49_877_000 picoseconds.
Weight::from_parts(50_828_000, 8061)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
Expand All @@ -197,8 +220,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `569`
// Estimated: `4108`
// Minimum execution time: 22_881_000 picoseconds.
Weight::from_parts(23_551_000, 4108)
// Minimum execution time: 38_037_000 picoseconds.
Weight::from_parts(39_203_000, 4108)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
Expand All @@ -208,8 +231,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `772`
// Estimated: `5722`
// Minimum execution time: 26_008_000 picoseconds.
Weight::from_parts(27_051_000, 5722)
// Minimum execution time: 44_673_000 picoseconds.
Weight::from_parts(46_256_000, 5722)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -219,8 +242,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `698`
// Estimated: `5648`
// Minimum execution time: 25_272_000 picoseconds.
Weight::from_parts(26_140_000, 5648)
// Minimum execution time: 42_165_000 picoseconds.
Weight::from_parts(43_326_000, 5648)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -230,8 +253,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `756`
// Estimated: `5706`
// Minimum execution time: 27_239_000 picoseconds.
Weight::from_parts(28_326_000, 5706)
// Minimum execution time: 46_508_000 picoseconds.
Weight::from_parts(47_756_000, 5706)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
Expand All @@ -247,26 +270,26 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `676`
// Estimated: `10129`
// Minimum execution time: 23_594_000 picoseconds.
Weight::from_parts(24_131_000, 10129)
// Minimum execution time: 38_426_000 picoseconds.
Weight::from_parts(39_937_000, 10129)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
/// Storage: AssetRegistry CurrencyMetadatas (r:1 w:0)
/// Proof Skipped: AssetRegistry CurrencyMetadatas (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry LocationToCurrencyIds (r:1 w:1)
/// Storage: AssetRegistry LocationToCurrencyIds (r:0 w:1)
/// Proof Skipped: AssetRegistry LocationToCurrencyIds (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry CurrencyIdToLocations (r:1 w:1)
/// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry CurrencyIdToWeights (r:0 w:1)
/// Proof Skipped: AssetRegistry CurrencyIdToWeights (max_values: None, max_size: None, mode: Measured)
/// Storage: AssetRegistry CurrencyIdToLocations (r:0 w:1)
/// Proof Skipped: AssetRegistry CurrencyIdToLocations (max_values: None, max_size: None, mode: Measured)
fn force_set_multilocation() -> Weight {
// Proof Size summary in bytes:
// Measured: `676`
// Estimated: `10129`
// Minimum execution time: 23_594_000 picoseconds.
Weight::from_parts(24_131_000, 10129)
.saturating_add(RocksDbWeight::get().reads(3_u64))
// Estimated: `5179`
// Minimum execution time: 44_818_000 picoseconds.
Weight::from_parts(46_431_000, 5179)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
}
Loading

0 comments on commit 5ae7f34

Please sign in to comment.