From 6749c7556cf960823c243106ce646f4935ea6d90 Mon Sep 17 00:00:00 2001 From: Herry Ho Date: Mon, 8 Nov 2021 17:46:07 +0800 Subject: [PATCH] orml-currencies benchmarks added --- Cargo.lock | 21 +++ Cargo.toml | 15 +- runtime/asgard/Cargo.toml | 3 + runtime/asgard/src/benchmarking/currencies.rs | 128 ++++++++++++++++++ runtime/asgard/src/benchmarking/mod.rs | 19 +++ runtime/asgard/src/benchmarking/tokens.rs | 103 ++++++++++++++ runtime/asgard/src/lib.rs | 10 +- runtime/asgard/src/weights/mod.rs | 1 + runtime/asgard/src/weights/orml_currencies.rs | 82 +++++++++++ runtime/bifrost/src/lib.rs | 2 +- runtime/bifrost/src/weights/mod.rs | 1 + .../bifrost/src/weights/orml_currencies.rs | 82 +++++++++++ runtime/dev/src/lib.rs | 2 +- runtime/dev/src/weights/mod.rs | 1 + runtime/dev/src/weights/orml_currencies.rs | 82 +++++++++++ 15 files changed, 542 insertions(+), 10 deletions(-) create mode 100644 runtime/asgard/src/benchmarking/currencies.rs create mode 100644 runtime/asgard/src/benchmarking/mod.rs create mode 100644 runtime/asgard/src/benchmarking/tokens.rs create mode 100644 runtime/asgard/src/weights/orml_currencies.rs create mode 100644 runtime/bifrost/src/weights/orml_currencies.rs create mode 100644 runtime/dev/src/weights/orml_currencies.rs diff --git a/Cargo.lock b/Cargo.lock index 672511127..83318fff4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,6 +196,7 @@ dependencies = [ "hex-literal 0.3.3", "log", "node-primitives", + "orml-benchmarking", "orml-currencies", "orml-tokens 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=5ba42f532b72d71a28aaa18421855de003b9ca71)", "orml-traits 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=5ba42f532b72d71a28aaa18421855de003b9ca71)", @@ -5426,6 +5427,26 @@ dependencies = [ "num-traits", ] +[[package]] +name = "orml-benchmarking" +version = "0.4.1-dev" +source = "git+https://github.com/open-web3-stack/open-runtime-module-library?rev=7969776ff70f1d361daae72f3e3cecfdc3e9342d#7969776ff70f1d361daae72f3e3cecfdc3e9342d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "log", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-api", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "sp-storage", +] + [[package]] name = "orml-currencies" version = "0.4.1-dev" diff --git a/Cargo.toml b/Cargo.toml index 6a2667a79..7544f6fd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -197,10 +197,11 @@ zenlink-protocol = { git = "https://github.com/zenlinkpro/Zenlink-DEX-Module", r zenlink-protocol-rpc = { git = "https://github.com/zenlinkpro/Zenlink-DEX-Module", rev = "0a96d66fba0b8173381ff5d03a33bb7943b4f457" } zenlink-protocol-runtime-api = { git = "https://github.com/zenlinkpro/Zenlink-DEX-Module", rev = "0a96d66fba0b8173381ff5d03a33bb7943b4f457" } -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } -orml-currencies = {git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } -orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } -orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } -orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } -orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "5ba42f532b72d71a28aaa18421855de003b9ca71" } +orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-currencies = {git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-xcm = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } +orml-benchmarking = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "7969776ff70f1d361daae72f3e3cecfdc3e9342d" } diff --git a/runtime/asgard/Cargo.toml b/runtime/asgard/Cargo.toml index 5f16576fe..6bef22fb7 100644 --- a/runtime/asgard/Cargo.toml +++ b/runtime/asgard/Cargo.toml @@ -112,6 +112,7 @@ orml-xtokens = { version = "0.4.1-dev", default-features = false } orml-unknown-tokens = { version = "0.4.1-dev", default-features = false } orml-xcm = { version = "0.4.1-dev", default-features = false } orml-xcm-support = { version = "0.4.1-dev", default-features = false } +orml-benchmarking = { version = "0.4.1-dev", default-features = false, optional = true } zenlink-protocol = { version = "*", default-features = false } zenlink-protocol-runtime-api = { version = "*", default-features = false } @@ -206,6 +207,7 @@ std = [ "orml-unknown-tokens/std", "orml-xcm/std", "orml-xcm-support/std", + "orml-benchmarking/std", "zenlink-protocol/std", "zenlink-protocol-runtime-api/std", ] @@ -229,6 +231,7 @@ runtime-benchmarks = [ "bifrost-token-issuer/runtime-benchmarks", "bifrost-lightening-redeem/runtime-benchmarks", "bifrost-call-switchgear/runtime-benchmarks", + "orml-benchmarking" ] try-runtime = [ diff --git a/runtime/asgard/src/benchmarking/currencies.rs b/runtime/asgard/src/benchmarking/currencies.rs new file mode 100644 index 000000000..e9f2f9091 --- /dev/null +++ b/runtime/asgard/src/benchmarking/currencies.rs @@ -0,0 +1,128 @@ +// This file is part of Bifrost. + +// Copyright (C) 2019-2021 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 . + +#![cfg(feature = "runtime-benchmarks")] + +use frame_benchmarking::{account, whitelisted_caller}; +use frame_support::assert_ok; +use frame_system::RawOrigin; +use orml_benchmarking::runtime_benchmarks; +use orml_traits::MultiCurrencyExtended; +use sp_runtime::{ + traits::{StaticLookup, UniqueSaturatedInto}, + SaturatedConversion, +}; +use sp_std::prelude::*; + +use crate::{ + AccountId, Amount, Balance, Currencies, CurrencyId, ExistentialDeposit, NativeCurrencyId, + Runtime, TokenSymbol, +}; + +const SEED: u32 = 0; +const NATIVE: CurrencyId = NativeCurrencyId::get(); + +pub fn set_balance(currency_id: CurrencyId, who: &AccountId, balance: Balance) { + assert_ok!(>::update_balance( + currency_id, + who, + balance.saturated_into() + )); +} + +runtime_benchmarks! { + { Runtime, orml_currencies } + + // `transfer` non-native currency + transfer_non_native_currency { + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let amount: Balance = 100u32.into(); + let from: AccountId = whitelisted_caller(); + set_balance(currency_id, &from, amount); + + let receiver: AccountId = account("bechmarking_account_1", 0, 0); + let recipient = ::Lookup::unlookup(receiver.clone()); + }: transfer(RawOrigin::Signed(from), recipient, currency_id, amount) + + + // `transfer` native currency and in worst case + #[extra] + transfer_native_currency_worst_case { + let existential_deposit = ExistentialDeposit::get(); + let amount: Balance = existential_deposit.saturating_mul(1000); + let from: AccountId = whitelisted_caller(); + set_balance(NATIVE, &from, amount); + + let to: AccountId = account("to", 0, SEED); + let to_lookup = ::Lookup::unlookup(to.clone()); + + }: transfer(RawOrigin::Signed(from), to_lookup, NATIVE, amount) + + // `transfer_native_currency` in worst case + // * will create the `to` account. + // * will kill the `from` account. + transfer_native_currency { + let existential_deposit = ExistentialDeposit::get(); + let amount: Balance = existential_deposit.saturating_mul(1000); + let from: AccountId = whitelisted_caller(); + set_balance(NATIVE, &from, amount); + + let to: AccountId = account("to", 0, SEED); + let to_lookup = ::Lookup::unlookup(to.clone()); + }: _(RawOrigin::Signed(from), to_lookup, amount) + + // `update_balance` for non-native currency + update_balance_non_native_currency { + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let balance: Balance = 1_000_000_000_000u128.into(); + let amount: Amount = balance.unique_saturated_into(); + let who: AccountId = account("who", 0, SEED); + let who_lookup = ::Lookup::unlookup(who.clone()); + }: update_balance(RawOrigin::Root, who_lookup, currency_id, amount) + + // `update_balance` for native currency + // * will create the `who` account. + update_balance_native_currency_creating { + let existential_deposit = ExistentialDeposit::get(); + let balance: Balance = existential_deposit.saturating_mul(1000); + let amount: Amount = balance.unique_saturated_into(); + let who: AccountId = account("who", 0, SEED); + let who_lookup = ::Lookup::unlookup(who.clone()); + }: update_balance(RawOrigin::Root, who_lookup, NATIVE, amount) + + // `update_balance` for native currency + // * will kill the `who` account. + update_balance_native_currency_killing { + let existential_deposit = ExistentialDeposit::get(); + let balance: Balance = existential_deposit.saturating_mul(1000); + let amount: Amount = balance.unique_saturated_into(); + let who: AccountId = account("who", 0, SEED); + let who_lookup = ::Lookup::unlookup(who.clone()); + set_balance(NATIVE, &who, balance); + }: update_balance(RawOrigin::Root, who_lookup, NATIVE, -amount) +} + +#[cfg(test)] +mod tests { + use orml_benchmarking::impl_benchmark_test_suite; + + use super::*; + use crate::benchmarking::utils::tests::new_test_ext; + + impl_benchmark_test_suite!(new_test_ext(),); +} diff --git a/runtime/asgard/src/benchmarking/mod.rs b/runtime/asgard/src/benchmarking/mod.rs new file mode 100644 index 000000000..890ecc701 --- /dev/null +++ b/runtime/asgard/src/benchmarking/mod.rs @@ -0,0 +1,19 @@ +// This file is part of Bifrost. + +// Copyright (C) 2019-2021 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 . + +pub mod currencies; diff --git a/runtime/asgard/src/benchmarking/tokens.rs b/runtime/asgard/src/benchmarking/tokens.rs new file mode 100644 index 000000000..54c7fab45 --- /dev/null +++ b/runtime/asgard/src/benchmarking/tokens.rs @@ -0,0 +1,103 @@ +// This file is part of Acala. + +// Copyright (C) 2020-2021 Acala Foundation. +// 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 . + +use super::utils::{lookup_of_account, set_balance as update_balance}; +use crate::{dollar, AccountId, Balance, CurrencyId, GetStableCurrencyId, Runtime, Tokens}; + +use sp_std::prelude::*; + +use frame_benchmarking::{account, whitelisted_caller}; +use frame_system::RawOrigin; + +use orml_benchmarking::runtime_benchmarks; +use orml_traits::MultiCurrency; + +const SEED: u32 = 0; + +const STABLECOIN: CurrencyId = GetStableCurrencyId::get(); + +runtime_benchmarks! { + { Runtime, orml_tokens } + + transfer { + let amount: Balance = dollar(STABLECOIN); + + let from: AccountId = whitelisted_caller(); + update_balance(STABLECOIN, &from, amount); + + let to: AccountId = account("to", 0, SEED); + let to_lookup = lookup_of_account(to.clone()); + }: _(RawOrigin::Signed(from), to_lookup, STABLECOIN, amount) + verify { + assert_eq!(>::total_balance(STABLECOIN, &to), amount); + } + + transfer_all { + let amount: Balance = dollar(STABLECOIN); + + let from: AccountId = whitelisted_caller(); + update_balance(STABLECOIN, &from, amount); + + let to: AccountId = account("to", 0, SEED); + let to_lookup = lookup_of_account(to); + }: _(RawOrigin::Signed(from.clone()), to_lookup, STABLECOIN, false) + verify { + assert_eq!(>::total_balance(STABLECOIN, &from), 0); + } + + transfer_keep_alive { + let from: AccountId = whitelisted_caller(); + update_balance(STABLECOIN, &from, 2 * dollar(STABLECOIN)); + + let to: AccountId = account("to", 0, SEED); + let to_lookup = lookup_of_account(to.clone()); + }: _(RawOrigin::Signed(from), to_lookup, STABLECOIN, dollar(STABLECOIN)) + verify { + assert_eq!(>::total_balance(STABLECOIN, &to), dollar(STABLECOIN)); + } + + force_transfer { + let from: AccountId = account("from", 0, SEED); + let from_lookup = lookup_of_account(from.clone()); + update_balance(STABLECOIN, &from, 2 * dollar(STABLECOIN)); + + let to: AccountId = account("to", 0, SEED); + let to_lookup = lookup_of_account(to.clone()); + }: _(RawOrigin::Root, from_lookup, to_lookup, STABLECOIN, dollar(STABLECOIN)) + verify { + assert_eq!(>::total_balance(STABLECOIN, &to), dollar(STABLECOIN)); + } + + set_balance { + let who: AccountId = account("who", 0, SEED); + let who_lookup = lookup_of_account(who.clone()); + + }: _(RawOrigin::Root, who_lookup, STABLECOIN, dollar(STABLECOIN), dollar(STABLECOIN)) + verify { + assert_eq!(>::total_balance(STABLECOIN, &who), 2 * dollar(STABLECOIN)); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::benchmarking::utils::tests::new_test_ext; + use orml_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!(new_test_ext(),); +} diff --git a/runtime/asgard/src/lib.rs b/runtime/asgard/src/lib.rs index cf1ad4172..e2d5cb23b 100644 --- a/runtime/asgard/src/lib.rs +++ b/runtime/asgard/src/lib.rs @@ -122,6 +122,7 @@ use zenlink_protocol::{ MultiAssetsHandler, PairInfo, ZenlinkMultiAssets, }; +mod benchmarking; mod weights; pub type SessionHandlers = (); @@ -1106,7 +1107,7 @@ impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = NativeCurrencyId; type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; - type WeightInfo = (); + type WeightInfo = weights::orml_currencies::WeightInfo; } orml_traits::parameter_type_with_key! { @@ -1919,6 +1920,8 @@ impl_runtime_apis! { ) { use frame_support::traits::StorageInfoTrait; use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList}; + use orml_benchmarking::list_benchmark as orml_list_benchmark; + let mut list = Vec::::new(); list_benchmark!(list, extra, bifrost_salp, Salp); @@ -1932,6 +1935,8 @@ impl_runtime_apis! { list_benchmark!(list, extra, bifrost_lightening_redeem, LighteningRedeem); list_benchmark!(list, extra, bifrost_call_switchgear, CallSwitchgear); + orml_list_benchmark!(list, extra, orml_currencies, benchmarking::currencies); + let storage_info = AllPalletsWithSystem::storage_info(); return (list, storage_info) @@ -1941,6 +1946,7 @@ impl_runtime_apis! { config: frame_benchmarking::BenchmarkConfig ) -> Result, RuntimeString> { use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use orml_benchmarking::{add_benchmark as orml_add_benchmark}; let whitelist: Vec = vec![ // Block Number @@ -1972,6 +1978,8 @@ impl_runtime_apis! { add_benchmark!(params, batches, bifrost_lightening_redeem, LighteningRedeem); add_benchmark!(params, batches, bifrost_call_switchgear, CallSwitchgear); + orml_add_benchmark!(params, batches, orml_currencies, benchmarking::currencies); + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } diff --git a/runtime/asgard/src/weights/mod.rs b/runtime/asgard/src/weights/mod.rs index e9e8219bd..d881f6cc5 100644 --- a/runtime/asgard/src/weights/mod.rs +++ b/runtime/asgard/src/weights/mod.rs @@ -30,4 +30,5 @@ pub mod bifrost_salp_lite; pub mod bifrost_token_issuer; pub mod bifrost_vsbond_auction; pub mod bifrost_vtoken_mint; +pub mod orml_currencies; pub mod pallet_vesting; diff --git a/runtime/asgard/src/weights/orml_currencies.rs b/runtime/asgard/src/weights/orml_currencies.rs new file mode 100644 index 000000000..8824e6480 --- /dev/null +++ b/runtime/asgard/src/weights/orml_currencies.rs @@ -0,0 +1,82 @@ +// This file is part of Bifrost. + +// Copyright (C) 2019-2021 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 . + +//! Autogenerated weights for `orml_currencies` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-local"), DB CACHE: 128 + +// Executed Command: +// target/release/bifrost +// benchmark +// --chain=asgard-local +// --steps=50 +// --repeat=20 +// --pallet=orml-currencies +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/orml_currencies.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `orml_currencies`. +pub struct WeightInfo(PhantomData); +impl orml_currencies::WeightInfo for WeightInfo { + // Storage: Tokens Accounts (r:2 w:2) + fn transfer_non_native_currency() -> Weight { + (78_778_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_native_currency() -> Weight { + (126_238_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Tokens Accounts (r:1 w:1) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn update_balance_non_native_currency() -> Weight { + (90_800_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn update_balance_native_currency_creating() -> Weight { + (86_863_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn update_balance_native_currency_killing() -> Weight { + (67_787_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index fa7f1bd8c..da9a516d0 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -1089,7 +1089,7 @@ impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = NativeCurrencyId; type MultiCurrency = Tokens; type NativeCurrency = BasicCurrencyAdapter; - type WeightInfo = (); + type WeightInfo = weights::orml_currencies::WeightInfo; } orml_traits::parameter_type_with_key! { diff --git a/runtime/bifrost/src/weights/mod.rs b/runtime/bifrost/src/weights/mod.rs index 77fc82fd1..436026482 100644 --- a/runtime/bifrost/src/weights/mod.rs +++ b/runtime/bifrost/src/weights/mod.rs @@ -28,6 +28,7 @@ pub mod bifrost_salp; pub mod bifrost_salp_lite; pub mod bifrost_token_issuer; pub mod frame_system; +pub mod orml_currencies; pub mod orml_tokens; pub mod pallet_balances; pub mod pallet_bounties; diff --git a/runtime/bifrost/src/weights/orml_currencies.rs b/runtime/bifrost/src/weights/orml_currencies.rs new file mode 100644 index 000000000..8824e6480 --- /dev/null +++ b/runtime/bifrost/src/weights/orml_currencies.rs @@ -0,0 +1,82 @@ +// This file is part of Bifrost. + +// Copyright (C) 2019-2021 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 . + +//! Autogenerated weights for `orml_currencies` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-local"), DB CACHE: 128 + +// Executed Command: +// target/release/bifrost +// benchmark +// --chain=asgard-local +// --steps=50 +// --repeat=20 +// --pallet=orml-currencies +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/orml_currencies.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `orml_currencies`. +pub struct WeightInfo(PhantomData); +impl orml_currencies::WeightInfo for WeightInfo { + // Storage: Tokens Accounts (r:2 w:2) + fn transfer_non_native_currency() -> Weight { + (78_778_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_native_currency() -> Weight { + (126_238_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Tokens Accounts (r:1 w:1) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn update_balance_non_native_currency() -> Weight { + (90_800_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn update_balance_native_currency_creating() -> Weight { + (86_863_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn update_balance_native_currency_killing() -> Weight { + (67_787_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +} diff --git a/runtime/dev/src/lib.rs b/runtime/dev/src/lib.rs index 33721925e..ff445fecc 100644 --- a/runtime/dev/src/lib.rs +++ b/runtime/dev/src/lib.rs @@ -1456,7 +1456,7 @@ impl orml_currencies::Config for Runtime { type GetNativeCurrencyId = NativeCurrencyId; type MultiCurrency = Tokens; type NativeCurrency = BifrostToken; - type WeightInfo = (); + type WeightInfo = weights::orml_currencies::WeightInfo; } parameter_types! { diff --git a/runtime/dev/src/weights/mod.rs b/runtime/dev/src/weights/mod.rs index e9e8219bd..d881f6cc5 100644 --- a/runtime/dev/src/weights/mod.rs +++ b/runtime/dev/src/weights/mod.rs @@ -30,4 +30,5 @@ pub mod bifrost_salp_lite; pub mod bifrost_token_issuer; pub mod bifrost_vsbond_auction; pub mod bifrost_vtoken_mint; +pub mod orml_currencies; pub mod pallet_vesting; diff --git a/runtime/dev/src/weights/orml_currencies.rs b/runtime/dev/src/weights/orml_currencies.rs new file mode 100644 index 000000000..8824e6480 --- /dev/null +++ b/runtime/dev/src/weights/orml_currencies.rs @@ -0,0 +1,82 @@ +// This file is part of Bifrost. + +// Copyright (C) 2019-2021 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 . + +//! Autogenerated weights for `orml_currencies` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-11-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-local"), DB CACHE: 128 + +// Executed Command: +// target/release/bifrost +// benchmark +// --chain=asgard-local +// --steps=50 +// --repeat=20 +// --pallet=orml-currencies +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/orml_currencies.rs + + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `orml_currencies`. +pub struct WeightInfo(PhantomData); +impl orml_currencies::WeightInfo for WeightInfo { + // Storage: Tokens Accounts (r:2 w:2) + fn transfer_non_native_currency() -> Weight { + (78_778_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn transfer_native_currency() -> Weight { + (126_238_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: Tokens Accounts (r:1 w:1) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn update_balance_non_native_currency() -> Weight { + (90_800_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn update_balance_native_currency_creating() -> Weight { + (86_863_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: System Account (r:1 w:1) + fn update_balance_native_currency_killing() -> Weight { + (67_787_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } +}