diff --git a/Cargo.lock b/Cargo.lock index 6068cb661d..d7d5977e73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -996,6 +996,7 @@ dependencies = [ name = "bifrost-token-issuer" version = "0.8.0" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "node-primitives", diff --git a/node/service/src/chain_spec/asgard.rs b/node/service/src/chain_spec/asgard.rs index 6b1f5f830f..7f1857dd70 100644 --- a/node/service/src/chain_spec/asgard.rs +++ b/node/service/src/chain_spec/asgard.rs @@ -148,9 +148,6 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig { .flat_map(|x| { vec![ (x.clone(), CurrencyId::Stable(TokenSymbol::KUSD), ENDOWMENT * 10_000), - (x.clone(), CurrencyId::Token(TokenSymbol::DOT), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::VSToken(TokenSymbol::DOT), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::Token(TokenSymbol::ETH), ENDOWMENT), (x.clone(), CurrencyId::Token(TokenSymbol::KSM), ENDOWMENT), ] }) @@ -218,17 +215,8 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig { .flat_map(|x| { vec![ (x.clone(), CurrencyId::Stable(TokenSymbol::KUSD), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::VSToken(TokenSymbol::DOT), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::VToken(TokenSymbol::DOT), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::Token(TokenSymbol::DOT), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::Token(TokenSymbol::ETH), ENDOWMENT * 4_000_000), (x.clone(), CurrencyId::Token(TokenSymbol::KSM), ENDOWMENT * 4_000_000), - (x.clone(), CurrencyId::Token(TokenSymbol::ASG), ENDOWMENT * 4_000_000), - ( - x.clone(), - CurrencyId::VSBond(TokenSymbol::KSM, 3000, 13, 20), - ENDOWMENT * 4_000_000, - ), + (x.clone(), CurrencyId::Native(TokenSymbol::ASG), ENDOWMENT * 4_000_000), ] }) .collect(); diff --git a/pallets/token-issuer/Cargo.toml b/pallets/token-issuer/Cargo.toml index f7fcc1e900..9ac7268c61 100644 --- a/pallets/token-issuer/Cargo.toml +++ b/pallets/token-issuer/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false, optional = true } node-primitives = { path = "../../node/primitives", default-features = false } orml-traits = { version = "0.4.1-dev", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10", default-features = false } @@ -34,4 +35,10 @@ std = [ "orml-tokens/std", "orml-currencies/std", "pallet-balances/std" +] + +runtime-benchmarks = [ + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] \ No newline at end of file diff --git a/pallets/token-issuer/src/benchmarking.rs b/pallets/token-issuer/src/benchmarking.rs new file mode 100644 index 0000000000..3d19baa155 --- /dev/null +++ b/pallets/token-issuer/src/benchmarking.rs @@ -0,0 +1,106 @@ +// 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, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; +use frame_support::{dispatch::UnfilteredDispatchable, sp_runtime::traits::UniqueSaturatedFrom}; +use frame_system::RawOrigin; +use node_primitives::{CurrencyId, TokenSymbol}; + +use super::*; +#[allow(unused_imports)] +use crate::Pallet as TokenIssuer; + +benchmarks! { + add_to_issue_whitelist { + let origin = T::ControlOrigin::successful_origin(); + let account: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let call = Call::::add_to_issue_whitelist(currency_id, account); + }: {call.dispatch_bypass_filter(origin)?} + + remove_from_issue_whitelist { + let origin = T::ControlOrigin::successful_origin(); + let account: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let add_call = Call::::add_to_issue_whitelist(currency_id, account.clone()); + add_call.dispatch_bypass_filter(origin.clone())?; + + let remove_call = Call::::remove_from_issue_whitelist(currency_id, account); + }: {remove_call.dispatch_bypass_filter(origin)?} + + add_to_transfer_whitelist { + let origin = T::ControlOrigin::successful_origin(); + let account: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let call = Call::::add_to_transfer_whitelist(currency_id, account); + }: {call.dispatch_bypass_filter(origin)?} + + remove_from_transfer_whitelist { + let origin = T::ControlOrigin::successful_origin(); + let account: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let add_call = Call::::add_to_transfer_whitelist(currency_id, account.clone()); + add_call.dispatch_bypass_filter(origin.clone())?; + + let remove_call = Call::::remove_from_transfer_whitelist(currency_id, account); + }: {remove_call.dispatch_bypass_filter(origin)?} + + issue { + let origin = T::ControlOrigin::successful_origin(); + let caller: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + let add_call = Call::::add_to_issue_whitelist(currency_id.clone(), caller.clone()); + add_call.dispatch_bypass_filter(origin.clone())?; + + let original_balance = T::MultiCurrency::free_balance(currency_id.clone(), &caller); + let token_amount = BalanceOf::::unique_saturated_from(1000u32 as u128); + }: _(RawOrigin::Signed(caller.clone()), caller.clone(), currency_id.clone(), token_amount) + verify { + assert_eq!(T::MultiCurrency::free_balance(currency_id.clone(), &caller), token_amount + original_balance); + } + + transfer { + let origin = T::ControlOrigin::successful_origin(); + let caller: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::KSM); + + // add caller to the transfer whitelist + let add_transfer_call = Call::::add_to_transfer_whitelist(currency_id.clone(), caller.clone()); + add_transfer_call.dispatch_bypass_filter(origin.clone())?; + + // transfer some ksm from caller account to receiver account + let receiver: T::AccountId = account("bechmarking_account_1", 0, 0); + let transfer_token_amount = BalanceOf::::unique_saturated_from(800u32 as u128); + let caller_original_balance = T::MultiCurrency::free_balance(currency_id.clone(), &caller); + let receiver_original_balance = T::MultiCurrency::free_balance(currency_id.clone(), &receiver); + }: _(RawOrigin::Signed(caller.clone()), receiver.clone(), currency_id.clone(), transfer_token_amount) + verify { + assert_eq!(T::MultiCurrency::free_balance(currency_id.clone(), &caller), caller_original_balance - transfer_token_amount); + assert_eq!(T::MultiCurrency::free_balance(currency_id.clone(), &receiver), transfer_token_amount+ receiver_original_balance); + } +} + +impl_benchmark_test_suite!( + TokenIssuer, + crate::mock::ExtBuilder::default() + // .one_hundred_precision_for_each_currency_type_for_whitelist_account() + .build(), + crate::mock::Test +); diff --git a/pallets/token-issuer/src/lib.rs b/pallets/token-issuer/src/lib.rs index d15bfa287c..f12408bbdd 100644 --- a/pallets/token-issuer/src/lib.rs +++ b/pallets/token-issuer/src/lib.rs @@ -26,20 +26,22 @@ extern crate alloc; use alloc::vec::Vec; use frame_support::{ensure, pallet_prelude::*, transactional}; -use frame_system::{pallet_prelude::*, WeightInfo}; +use frame_system::pallet_prelude::*; +use node_primitives::CurrencyId; use orml_traits::MultiCurrency; +pub use weights::WeightInfo; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; mod mock; mod tests; +mod weights; pub use pallet::*; type BalanceOf = <::MultiCurrency as MultiCurrency< ::AccountId, >>::Balance; -type CurrencyIdOf = <::MultiCurrency as MultiCurrency< - ::AccountId, ->>::CurrencyId; type AccountIdOf = ::AccountId; #[frame_support::pallet] @@ -50,7 +52,7 @@ pub mod pallet { pub trait Config: frame_system::Config { type Event: From> + IsType<::Event>; /// Currecny operation handler - type MultiCurrency: MultiCurrency>; + type MultiCurrency: MultiCurrency, CurrencyId = CurrencyId>; /// The only origin that can edit token issuer list type ControlOrigin: EnsureOrigin; @@ -70,34 +72,33 @@ pub mod pallet { } #[pallet::event] - #[pallet::metadata(BalanceOf = "Balance", CurrencyIdOf = "CurrencyId")] + #[pallet::metadata(BalanceOf = "Balance")] #[pallet::generate_deposit(pub(crate) fn deposit_event)] pub enum Event { /// Successful added a new account to the issue whitelist. \[account, currency_id]\ - AddedToIssueList(T::AccountId, CurrencyIdOf), + AddedToIssueList(T::AccountId, CurrencyId), /// Successful remove an account from the issue whitelist. \[account, currency_id]\ - RemovedFromIssueList(T::AccountId, CurrencyIdOf), + RemovedFromIssueList(T::AccountId, CurrencyId), /// Successful added a new account to the transfer whitelist. \[account, currency_id]\ - AddedToTransferList(T::AccountId, CurrencyIdOf), + AddedToTransferList(T::AccountId, CurrencyId), /// Successful remove an account from the transfer whitelist. \[account, currency_id]\ - RemovedFromTransferList(T::AccountId, CurrencyIdOf), + RemovedFromTransferList(T::AccountId, CurrencyId), /// Token issue success, \[currency_id, dest, amount\] - Issued(T::AccountId, CurrencyIdOf, BalanceOf), + Issued(T::AccountId, CurrencyId, BalanceOf), /// Token transferred success, \[origin, dest, currency_id, amount\] - Transferred(T::AccountId, T::AccountId, CurrencyIdOf, BalanceOf), + Transferred(T::AccountId, T::AccountId, CurrencyId, BalanceOf), } /// Accounts in the whitelist can issue the corresponding Currency. #[pallet::storage] #[pallet::getter(fn get_issue_whitelist)] - pub type IssueWhiteList = - StorageMap<_, Blake2_128Concat, CurrencyIdOf, Vec>>; + pub type IssueWhiteList = StorageMap<_, Blake2_128Concat, CurrencyId, Vec>>; /// Accounts in the whitelist can transfer the corresponding Currency. #[pallet::storage] #[pallet::getter(fn get_transfer_whitelist)] pub type TransferWhiteList = - StorageMap<_, Blake2_128Concat, CurrencyIdOf, Vec>>; + StorageMap<_, Blake2_128Concat, CurrencyId, Vec>>; #[pallet::pallet] pub struct Pallet(PhantomData); @@ -107,11 +108,11 @@ pub mod pallet { #[pallet::call] impl Pallet { - #[pallet::weight(1000)] + #[pallet::weight(T::WeightInfo::add_to_issue_whitelist())] #[transactional] pub fn add_to_issue_whitelist( origin: OriginFor, - currency_id: CurrencyIdOf, + currency_id: CurrencyId, account: AccountIdOf, ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; @@ -135,11 +136,11 @@ pub mod pallet { Ok(()) } - #[pallet::weight(1000)] + #[pallet::weight(T::WeightInfo::remove_from_issue_whitelist())] #[transactional] pub fn remove_from_issue_whitelist( origin: OriginFor, - currency_id: CurrencyIdOf, + currency_id: CurrencyId, account: AccountIdOf, ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; @@ -158,11 +159,11 @@ pub mod pallet { Ok(()) } - #[pallet::weight(1000)] + #[pallet::weight(T::WeightInfo::add_to_transfer_whitelist())] #[transactional] pub fn add_to_transfer_whitelist( origin: OriginFor, - currency_id: CurrencyIdOf, + currency_id: CurrencyId, account: AccountIdOf, ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; @@ -189,11 +190,11 @@ pub mod pallet { Ok(()) } - #[pallet::weight(1000)] + #[pallet::weight(T::WeightInfo::remove_from_transfer_whitelist())] #[transactional] pub fn remove_from_transfer_whitelist( origin: OriginFor, - currency_id: CurrencyIdOf, + currency_id: CurrencyId, account: AccountIdOf, ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; @@ -218,12 +219,12 @@ pub mod pallet { Ok(()) } - #[pallet::weight(1000)] + #[pallet::weight(T::WeightInfo::issue())] #[transactional] pub fn issue( origin: OriginFor, dest: AccountIdOf, - currency_id: CurrencyIdOf, + currency_id: CurrencyId, #[pallet::compact] amount: BalanceOf, ) -> DispatchResult { let issuer = ensure_signed(origin)?; @@ -242,12 +243,12 @@ pub mod pallet { /// /// The dispatch origin for this call must be `Root` by the /// transactor. - #[pallet::weight(1000)] + #[pallet::weight(T::WeightInfo::transfer())] #[transactional] pub fn transfer( origin: OriginFor, dest: AccountIdOf, - currency_id: CurrencyIdOf, + currency_id: CurrencyId, #[pallet::compact] amount: BalanceOf, ) -> DispatchResult { let transferrer = ensure_signed(origin)?; diff --git a/pallets/token-issuer/src/weights.rs b/pallets/token-issuer/src/weights.rs index b8fc6aa37d..52369611d3 100644 --- a/pallets/token-issuer/src/weights.rs +++ b/pallets/token-issuer/src/weights.rs @@ -23,40 +23,38 @@ use frame_support::{ traits::Get, weights::{constants::RocksDbWeight, Weight}, }; -use sp_std::marker::PhantomData; - pub trait WeightInfo { - fn add_to_issue_whitelist() -> Weight; - fn remove_from_issue_whitelist() -> Weight; - fn add_to_transfer_whitelist() -> Weight; - fn remove_from_transfer_whitelist() -> Weight; - fn issue() -> Weight; - fn transfer() -> Weight; + fn add_to_issue_whitelist() -> Weight; + fn remove_from_issue_whitelist() -> Weight; + fn add_to_transfer_whitelist() -> Weight; + fn remove_from_transfer_whitelist() -> Weight; + fn issue() -> Weight; + fn transfer() -> Weight; } impl WeightInfo for () { - fn add_to_issue_whitelist() -> Weight { - (50_000_000 as Weight) - } - - fn remove_from_issue_whitelist() -> Weight { - (50_000_000 as Weight) - } - - fn add_to_transfer_whitelist() -> Weight { - (50_000_000 as Weight) - } - - fn remove_from_transfer_whitelist() -> Weight { - (50_000_000 as Weight) - } - - fn issue() -> Weight { - (50_000_000 as Weight) - } - - fn transfer() -> Weight { - (50_000_000 as Weight) - } -} \ No newline at end of file + fn add_to_issue_whitelist() -> Weight { + (50_000_000 as Weight) + } + + fn remove_from_issue_whitelist() -> Weight { + (50_000_000 as Weight) + } + + fn add_to_transfer_whitelist() -> Weight { + (50_000_000 as Weight) + } + + fn remove_from_transfer_whitelist() -> Weight { + (50_000_000 as Weight) + } + + fn issue() -> Weight { + (50_000_000 as Weight) + } + + fn transfer() -> Weight { + (50_000_000 as Weight) + } +} diff --git a/runtime/asgard/Cargo.toml b/runtime/asgard/Cargo.toml index e3c874de15..7d94918360 100644 --- a/runtime/asgard/Cargo.toml +++ b/runtime/asgard/Cargo.toml @@ -210,6 +210,7 @@ runtime-benchmarks = [ "bifrost-vtoken-mint/runtime-benchmarks", "bifrost-minter-reward/runtime-benchmarks", "bifrost-vsbond-auction/runtime-benchmarks", + "bifrost-token-issuer/runtime-benchmarks", ] try-runtime = [ diff --git a/runtime/asgard/src/lib.rs b/runtime/asgard/src/lib.rs index d2d0063582..4bf8a24bd4 100644 --- a/runtime/asgard/src/lib.rs +++ b/runtime/asgard/src/lib.rs @@ -1262,7 +1262,7 @@ impl bifrost_token_issuer::Config for Runtime { type MultiCurrency = Currencies; type ControlOrigin = EnsureOneOf; - type WeightInfo = (); + type WeightInfo = weights::bifrost_token_issuer::WeightInfo; } // bifrost runtime end @@ -1725,6 +1725,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, bifrost_vtoken_mint, VtokenMint); list_benchmark!(list, extra, bifrost_minter_reward, MinterReward); list_benchmark!(list, extra, bifrost_vsbond_auction, VSBondAuction); + list_benchmark!(list, extra, bifrost_token_issuer, TokenIssuer); let storage_info = AllPalletsWithSystem::storage_info(); @@ -1761,7 +1762,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, bifrost_vtoken_mint, VtokenMint); add_benchmark!(params, batches, bifrost_minter_reward, MinterReward); add_benchmark!(params, batches, bifrost_vsbond_auction, VSBondAuction); - + add_benchmark!(params, batches, bifrost_token_issuer, TokenIssuer); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/runtime/asgard/src/weights/bifrost_token_issuer.rs b/runtime/asgard/src/weights/bifrost_token_issuer.rs new file mode 100644 index 0000000000..56156df4cc --- /dev/null +++ b/runtime/asgard/src/weights/bifrost_token_issuer.rs @@ -0,0 +1,89 @@ +// 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 `bifrost_token_issuer` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-10-08, STEPS: `50`, REPEAT: 1, 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=1 +// --pallet=bifrost_token_issuer +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/bifrost_token_issuer.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 bifrost_token_issuer. +pub struct WeightInfo(PhantomData); +impl bifrost_token_issuer::WeightInfo for WeightInfo { + // Storage: TokenIssuer IssueWhiteList (r:1 w:1) + fn add_to_issue_whitelist() -> Weight { + (72_266_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer IssueWhiteList (r:1 w:1) + fn remove_from_issue_whitelist() -> Weight { + (52_929_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer TransferWhiteList (r:1 w:1) + fn add_to_transfer_whitelist() -> Weight { + (35_216_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer TransferWhiteList (r:1 w:1) + fn remove_from_transfer_whitelist() -> Weight { + (27_602_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer IssueWhiteList (r:1 w:0) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: Tokens TotalIssuance (r:1 w:1) + fn issue() -> Weight { + (56_797_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: TokenIssuer TransferWhiteList (r:1 w:0) + // Storage: Tokens Accounts (r:2 w:2) + fn transfer() -> Weight { + (75_672_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} diff --git a/runtime/asgard/src/weights/mod.rs b/runtime/asgard/src/weights/mod.rs index f1981db56f..108f9833ec 100644 --- a/runtime/asgard/src/weights/mod.rs +++ b/runtime/asgard/src/weights/mod.rs @@ -24,6 +24,7 @@ pub mod bifrost_bancor; pub mod bifrost_flexible_fee; pub mod bifrost_minter_reward; pub mod bifrost_salp; +pub mod bifrost_token_issuer; pub mod bifrost_vsbond_auction; pub mod bifrost_vtoken_mint; pub mod pallet_vesting; diff --git a/runtime/bifrost/Cargo.toml b/runtime/bifrost/Cargo.toml index 1635cecf3b..c2780343f0 100644 --- a/runtime/bifrost/Cargo.toml +++ b/runtime/bifrost/Cargo.toml @@ -195,6 +195,7 @@ runtime-benchmarks = [ "bifrost-flexible-fee/runtime-benchmarks", "bifrost-salp/runtime-benchmarks", "bifrost-liquidity-mining/runtime-benchmarks", + "bifrost-token-issuer/runtime-benchmarks", ] try-runtime = [ diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index 539662b1ea..e8a6b79bd2 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -1140,7 +1140,7 @@ impl bifrost_token_issuer::Config for Runtime { type MultiCurrency = Currencies; type ControlOrigin = EnsureOneOf; - type WeightInfo = (); + type WeightInfo = weights::bifrost_token_issuer::WeightInfo; } // Bifrost modules end @@ -1559,6 +1559,7 @@ impl_runtime_apis! { list_benchmark!(list, extra, bifrost_flexible_fee, FlexibleFee); list_benchmark!(list, extra, bifrost_salp, Salp); list_benchmark!(list, extra, bifrost_liquidity_mining, LiquidityMining); + list_benchmark!(list, extra, bifrost_token_issuer, TokenIssuer); let storage_info = AllPalletsWithSystem::storage_info(); @@ -1592,6 +1593,7 @@ impl_runtime_apis! { add_benchmark!(params, batches, bifrost_flexible_fee, FlexibleFee); add_benchmark!(params, batches, bifrost_salp, Salp); add_benchmark!(params, batches, bifrost_liquidity_mining, LiquidityMining); + add_benchmark!(params, batches, bifrost_token_issuer, TokenIssuer); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/runtime/bifrost/src/weights/bifrost_token_issuer.rs b/runtime/bifrost/src/weights/bifrost_token_issuer.rs new file mode 100644 index 0000000000..56156df4cc --- /dev/null +++ b/runtime/bifrost/src/weights/bifrost_token_issuer.rs @@ -0,0 +1,89 @@ +// 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 `bifrost_token_issuer` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-10-08, STEPS: `50`, REPEAT: 1, 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=1 +// --pallet=bifrost_token_issuer +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/bifrost_token_issuer.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 bifrost_token_issuer. +pub struct WeightInfo(PhantomData); +impl bifrost_token_issuer::WeightInfo for WeightInfo { + // Storage: TokenIssuer IssueWhiteList (r:1 w:1) + fn add_to_issue_whitelist() -> Weight { + (72_266_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer IssueWhiteList (r:1 w:1) + fn remove_from_issue_whitelist() -> Weight { + (52_929_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer TransferWhiteList (r:1 w:1) + fn add_to_transfer_whitelist() -> Weight { + (35_216_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer TransferWhiteList (r:1 w:1) + fn remove_from_transfer_whitelist() -> Weight { + (27_602_000 as Weight) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) + .saturating_add(T::DbWeight::get().writes(1 as Weight)) + } + // Storage: TokenIssuer IssueWhiteList (r:1 w:0) + // Storage: Tokens Accounts (r:1 w:1) + // Storage: Tokens TotalIssuance (r:1 w:1) + fn issue() -> Weight { + (56_797_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } + // Storage: TokenIssuer TransferWhiteList (r:1 w:0) + // Storage: Tokens Accounts (r:2 w:2) + fn transfer() -> Weight { + (75_672_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) + } +} diff --git a/runtime/bifrost/src/weights/mod.rs b/runtime/bifrost/src/weights/mod.rs index a5c5464385..78e1625a54 100644 --- a/runtime/bifrost/src/weights/mod.rs +++ b/runtime/bifrost/src/weights/mod.rs @@ -23,6 +23,7 @@ pub mod bifrost_flexible_fee; pub mod bifrost_liquidity_mining; pub mod bifrost_salp; +pub mod bifrost_token_issuer; pub mod frame_system; pub mod orml_tokens; pub mod pallet_balances;