diff --git a/Cargo.lock b/Cargo.lock index ba80354435..258aea75cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -612,6 +612,7 @@ dependencies = [ name = "bifrost-bancor" 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 de21534eba..c00a5de310 100644 --- a/node/service/src/chain_spec/asgard.rs +++ b/node/service/src/chain_spec/asgard.rs @@ -24,6 +24,7 @@ use asgard_runtime::{ TokensConfig, VestingConfig, VtokenMintConfig, WASM_BINARY, }; use cumulus_primitives_core::ParaId; +use frame_benchmarking::whitelisted_caller; use hex_literal::hex; use node_primitives::{CurrencyId, TokenSymbol}; use sc_service::ChainType; @@ -126,7 +127,10 @@ pub fn asgard_genesis( } fn development_config_genesis(id: ParaId) -> GenesisConfig { - let endowed_accounts = vec![get_account_id_from_seed::("Alice")]; + let endowed_accounts = vec![ + get_account_id_from_seed::("Alice"), + whitelisted_caller(), // Benchmarking whitelist_account + ]; let balances = endowed_accounts .iter() .chain(faucet_accounts().iter()) @@ -144,7 +148,8 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig { .flat_map(|x| { vec![ (x.clone(), CurrencyId::Stable(TokenSymbol::AUSD), ENDOWMENT * 10_000), - (x.clone(), CurrencyId::Token(TokenSymbol::DOT), ENDOWMENT), + (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), ] diff --git a/pallets/bancor/Cargo.toml b/pallets/bancor/Cargo.toml index f86fa3683d..c3b23f14f4 100644 --- a/pallets/bancor/Cargo.toml +++ b/pallets/bancor/Cargo.toml @@ -18,6 +18,8 @@ orml-tokens = { version = "0.4.1-dev", default-features = false } node-primitives = { path = "../../node/primitives", default-features = false } num-bigint = { version = "0.4", default-features = false } sp-std = { version = "3.0.0", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false, optional = true } + [dev-dependencies] sp-core = "3.0.0" @@ -38,4 +40,10 @@ std = [ "node-primitives/std", "num-bigint/std", "sp-std/std", +] + +runtime-benchmarks = [ + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] \ No newline at end of file diff --git a/pallets/bancor/src/benchmarking.rs b/pallets/bancor/src/benchmarking.rs new file mode 100644 index 0000000000..0b826d0af5 --- /dev/null +++ b/pallets/bancor/src/benchmarking.rs @@ -0,0 +1,88 @@ +// 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::{benchmarks, impl_benchmark_test_suite, whitelisted_caller}; +use frame_system::RawOrigin; +use node_primitives::{CurrencyId, TokenSymbol}; +use sp_runtime::traits::UniqueSaturatedFrom; + +use super::*; +use crate::BancorPools; +#[allow(unused_imports)] +use crate::Pallet as Bancor; + +benchmarks! { + add_token_to_pool { + let currency_id = CurrencyId::Token(TokenSymbol::DOT); + let caller: T::AccountId = whitelisted_caller(); + let token_amount = BalanceOf::::unique_saturated_from(10u32 as u128); + }: _(RawOrigin::Signed(caller), currency_id, token_amount) + + exchange_for_token { + let caller: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::DOT); + let vstoken_amount = BalanceOf::::unique_saturated_from(1u128); + let token_out_min = BalanceOf::::unique_saturated_from(0u128); + + // add token to the pool + BancorPools::::mutate(currency_id, |pool_info_option|{ + let pool_info = pool_info_option.as_mut().unwrap(); + + pool_info.token_ceiling = + pool_info.token_ceiling.saturating_add(BalanceOf::::unique_saturated_from(10u128)); + }); + + }: _(RawOrigin::Signed(caller), currency_id, vstoken_amount, token_out_min) + + exchange_for_vstoken { + let caller: T::AccountId = whitelisted_caller(); + let currency_id = CurrencyId::Token(TokenSymbol::DOT); + let token_amount = BalanceOf::::unique_saturated_from(100u128); + let vstoken_out_min = BalanceOf::::unique_saturated_from(0u128); + + BancorPools::::mutate(currency_id, |pool| { + let pool_info = pool.as_mut().unwrap(); + pool_info.token_pool = pool_info.token_pool.saturating_add(token_amount); + pool_info.vstoken_pool = pool_info.vstoken_pool.saturating_add(token_amount); + }); + }: _(RawOrigin::Signed(caller), currency_id, token_amount, vstoken_out_min) + + on_initialize { + let currency_id = CurrencyId::Token(TokenSymbol::DOT); + let caller: T::AccountId = whitelisted_caller(); + let token_amount = BalanceOf::::unique_saturated_from(7200 as u128); + + BancorPools::::mutate(currency_id, |pool| { + let pool_info = pool.as_mut().unwrap(); + pool_info.token_pool = pool_info.token_pool.saturating_add(token_amount); + }); + + let block_num = T::BlockNumber::from(100u32); + }:{Bancor::::on_initialize(block_num);} + +} + +impl_benchmark_test_suite!( + Bancor, + crate::mock::ExtBuilder::default() + .one_hundred_precision_for_each_currency_type_for_whitelist_account() + .build(), + crate::mock::Test +); diff --git a/pallets/bancor/src/lib.rs b/pallets/bancor/src/lib.rs index d7b4f070fe..7fe451a6ec 100644 --- a/pallets/bancor/src/lib.rs +++ b/pallets/bancor/src/lib.rs @@ -28,12 +28,15 @@ use sp_runtime::{ traits::{CheckedAdd, CheckedDiv, CheckedMul, CheckedSub, Saturating, Zero}, SaturatedConversion, }; -use weights::WeightInfo; +pub use weights::WeightInfo; mod mock; mod tests; pub mod weights; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + pub use pallet::*; type AccountIdOf = ::AccountId; @@ -223,8 +226,7 @@ pub mod pallet { } } - // TODO: Estimate weight for this function - 1_000 + T::WeightInfo::on_initialize() } } diff --git a/pallets/bancor/src/mock.rs b/pallets/bancor/src/mock.rs index 79bf26159e..6f1c175456 100644 --- a/pallets/bancor/src/mock.rs +++ b/pallets/bancor/src/mock.rs @@ -18,6 +18,8 @@ #![cfg(test)] +#[cfg(feature = "runtime-benchmarks")] +use frame_benchmarking::whitelisted_caller; use frame_support::{ construct_runtime, parameter_types, traits::{GenesisBuild, OnFinalize, OnInitialize}, @@ -165,6 +167,18 @@ impl ExtBuilder { ]) } + #[cfg(feature = "runtime-benchmarks")] + pub fn one_hundred_precision_for_each_currency_type_for_whitelist_account(self) -> Self { + let whitelist_caller: AccountId = whitelisted_caller(); + + self.balances(vec![ + (whitelist_caller.clone(), KSM, 100_000_000_000_000), + (whitelist_caller.clone(), DOT, 100_000_000_000_000), + (whitelist_caller.clone(), VSKSM, 100_000_000_000_000), + (whitelist_caller.clone(), VSDOT, 100_000_000_000_000), + ]) + } + pub fn build(self) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); diff --git a/pallets/bancor/src/weights.rs b/pallets/bancor/src/weights.rs index 1ecc861260..85d1ebe635 100644 --- a/pallets/bancor/src/weights.rs +++ b/pallets/bancor/src/weights.rs @@ -30,11 +30,11 @@ pub trait WeightInfo { fn add_token_to_pool() -> Weight; fn exchange_for_token() -> Weight; fn exchange_for_vstoken() -> Weight; + fn on_initialize() -> Weight; } -/// Weights for the pallet using the Bifrost node and recommended hardware. -pub struct BifrostWeight(PhantomData); -impl WeightInfo for BifrostWeight { +// For backwards compatibility and tests +impl WeightInfo for () { fn add_token_to_pool() -> Weight { (50_000_000 as Weight) } @@ -46,19 +46,8 @@ impl WeightInfo for BifrostWeight { fn exchange_for_vstoken() -> Weight { (50_000_000 as Weight) } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - fn add_token_to_pool() -> Weight { - (50_000_000 as Weight) - } - fn exchange_for_token() -> Weight { - (50_000_000 as Weight) - } - - fn exchange_for_vstoken() -> Weight { + fn on_initialize() -> Weight { (50_000_000 as Weight) } } diff --git a/runtime/asgard/Cargo.toml b/runtime/asgard/Cargo.toml index 1da5182bf2..f54196ca21 100644 --- a/runtime/asgard/Cargo.toml +++ b/runtime/asgard/Cargo.toml @@ -185,4 +185,5 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "bifrost-salp/runtime-benchmarks", + "bifrost-bancor/runtime-benchmarks", ] diff --git a/runtime/asgard/src/lib.rs b/runtime/asgard/src/lib.rs index 3a0a48f0d8..98a59ae76b 100644 --- a/runtime/asgard/src/lib.rs +++ b/runtime/asgard/src/lib.rs @@ -973,7 +973,7 @@ impl bifrost_salp::Config for Runtime { type SubmissionDeposit = SubmissionDeposit; type VSBondValidPeriod = VSBondValidPeriod; type XcmTransferOrigin = XcmTransferOrigin; - type WeightInfo = weights::pallet_salp::WeightInfo; // bifrost_salp::TestWeightInfo; + type WeightInfo = weights::bifrost_salp::WeightInfo; // bifrost_salp::TestWeightInfo; } parameter_types! { @@ -986,7 +986,7 @@ impl bifrost_bancor::Config for Runtime { type InterventionPercentage = InterventionPercentage; type DailyReleasePercentage = DailyReleasePercentage; type MultiCurrency = Currencies; - type WeightInfo = bifrost_bancor::weights::BifrostWeight; + type WeightInfo = weights::bifrost_bancor::WeightInfo; } parameter_types! { @@ -1496,6 +1496,7 @@ impl_runtime_apis! { let mut batches = Vec::::new(); let params = (&config, &whitelist); add_benchmark!(params, batches, bifrost_salp, Salp); + add_benchmark!(params, batches, bifrost_bancor, Bancor); if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) diff --git a/runtime/asgard/src/weights/bifrost_bancor.rs b/runtime/asgard/src/weights/bifrost_bancor.rs new file mode 100644 index 0000000000..cbfc8d80b9 --- /dev/null +++ b/runtime/asgard/src/weights/bifrost_bancor.rs @@ -0,0 +1,66 @@ +// 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_bancor +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2021-08-03, STEPS: `[50, ]`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-dev"), DB CACHE: 128 + +// Executed Command: +// target/release/bifrost +// benchmark +// --chain=asgard-dev +// --steps=50 +// --repeat=1 +// --pallet=bifrost-bancor +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/bifrost_bancor.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for bifrost_bancor. +pub struct WeightInfo(PhantomData); +impl bifrost_bancor::WeightInfo for WeightInfo { + fn add_token_to_pool() -> Weight { + (64_732_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn exchange_for_token() -> Weight { + (94_428_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn exchange_for_vstoken() -> Weight { + (82_786_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn on_initialize() -> Weight { + (22_914_000 as Weight).saturating_add(T::DbWeight::get().reads(3 as Weight)) + } +} diff --git a/runtime/asgard/src/weights/pallet_salp.rs b/runtime/asgard/src/weights/bifrost_salp.rs similarity index 78% rename from runtime/asgard/src/weights/pallet_salp.rs rename to runtime/asgard/src/weights/bifrost_salp.rs index 5b82ba2d59..4f95249a7f 100644 --- a/runtime/asgard/src/weights/pallet_salp.rs +++ b/runtime/asgard/src/weights/bifrost_salp.rs @@ -19,24 +19,22 @@ //! Autogenerated weights for bifrost_salp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-07-11, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-30, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-dev"), DB CACHE: 128 // Executed Command: -// target/debug/bifrost +// target/release/bifrost // benchmark -// --chain -// asgard-dev +// --chain=asgard-dev // --steps=50 // --repeat=20 -// --pallet=bifrost-salp -// --extrinsic -// * +// --pallet=bifrost_salp +// --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 // --header=./HEADER-GPL3 -// --output=./runtime/asgard/src/weights/salp.rs +// --output=./runtime/asgard/src/weights/bifrost_salp.rs #![allow(unused_parens)] #![allow(unused_imports)] @@ -48,22 +46,20 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl bifrost_salp::WeightInfo for WeightInfo { fn create() -> Weight { - (2_345_291_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + (60_294_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - fn contribute() -> Weight { - (1_251_633_000 as Weight) + (63_079_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - fn on_finalize(n: u32) -> Weight { - (290_825_000 as Weight) - // Standard Error: 5_000 - .saturating_add((399_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + (8_753_000 as Weight) + // Standard Error: 0 + .saturating_add((214_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } } diff --git a/runtime/asgard/src/weights/mod.rs b/runtime/asgard/src/weights/mod.rs index 3cdec6fda5..2206502d2c 100644 --- a/runtime/asgard/src/weights/mod.rs +++ b/runtime/asgard/src/weights/mod.rs @@ -20,5 +20,6 @@ //! A list of the different weight modules for our runtime. -pub mod pallet_salp; +pub mod bifrost_bancor; +pub mod bifrost_salp; pub mod pallet_vesting; diff --git a/runtime/asgard/src/weights/pallet_assets.rs b/runtime/asgard/src/weights/pallet_assets.rs deleted file mode 100644 index 559d2ee809..0000000000 --- a/runtime/asgard/src/weights/pallet_assets.rs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 . - -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 - -use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; -pub struct WeightInfo(PhantomData); -impl bifrost_assets::WeightInfo for WeightInfo { - fn create() -> Weight { - (65949000 as Weight) - //.saturating_add(T::DbWeight::get().reads(0 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn create_pair() -> Weight { - (65949000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn issue() -> Weight { - (46665000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer() -> Weight { - (27086000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn destroy() -> Weight { - (39_603_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn redeem() -> Weight { - (110_679_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } -} \ No newline at end of file diff --git a/runtime/dev/src/lib.rs b/runtime/dev/src/lib.rs index c274ece108..a248b4c24d 100644 --- a/runtime/dev/src/lib.rs +++ b/runtime/dev/src/lib.rs @@ -945,7 +945,7 @@ impl bifrost_salp::Config for Runtime { type SubmissionDeposit = SubmissionDeposit; type VSBondValidPeriod = VSBondValidPeriod; type XcmTransferOrigin = XcmTransferOrigin; - type WeightInfo = weights::pallet_salp::WeightInfo; // bifrost_salp::TestWeightInfo; + type WeightInfo = weights::bifrost_salp::WeightInfo; // bifrost_salp::TestWeightInfo; } parameter_types! { @@ -958,7 +958,7 @@ impl bifrost_bancor::Config for Runtime { type InterventionPercentage = InterventionPercentage; type DailyReleasePercentage = DailyReleasePercentage; type MultiCurrency = Currencies; - type WeightInfo = bifrost_bancor::weights::BifrostWeight; + type WeightInfo = weights::bifrost_bancor::WeightInfo; } parameter_types! { diff --git a/runtime/dev/src/weights/bifrost_bancor.rs b/runtime/dev/src/weights/bifrost_bancor.rs new file mode 100644 index 0000000000..cbfc8d80b9 --- /dev/null +++ b/runtime/dev/src/weights/bifrost_bancor.rs @@ -0,0 +1,66 @@ +// 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_bancor +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 +//! DATE: 2021-08-03, STEPS: `[50, ]`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-dev"), DB CACHE: 128 + +// Executed Command: +// target/release/bifrost +// benchmark +// --chain=asgard-dev +// --steps=50 +// --repeat=1 +// --pallet=bifrost-bancor +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --header=./HEADER-GPL3 +// --output=./runtime/asgard/src/weights/bifrost_bancor.rs + +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for bifrost_bancor. +pub struct WeightInfo(PhantomData); +impl bifrost_bancor::WeightInfo for WeightInfo { + fn add_token_to_pool() -> Weight { + (64_732_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn exchange_for_token() -> Weight { + (94_428_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn exchange_for_vstoken() -> Weight { + (82_786_000 as Weight) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + fn on_initialize() -> Weight { + (22_914_000 as Weight).saturating_add(T::DbWeight::get().reads(3 as Weight)) + } +} diff --git a/runtime/dev/src/weights/pallet_salp.rs b/runtime/dev/src/weights/bifrost_salp.rs similarity index 78% rename from runtime/dev/src/weights/pallet_salp.rs rename to runtime/dev/src/weights/bifrost_salp.rs index 5b82ba2d59..4f95249a7f 100644 --- a/runtime/dev/src/weights/pallet_salp.rs +++ b/runtime/dev/src/weights/bifrost_salp.rs @@ -19,24 +19,22 @@ //! Autogenerated weights for bifrost_salp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-07-11, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-07-30, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asgard-dev"), DB CACHE: 128 // Executed Command: -// target/debug/bifrost +// target/release/bifrost // benchmark -// --chain -// asgard-dev +// --chain=asgard-dev // --steps=50 // --repeat=20 -// --pallet=bifrost-salp -// --extrinsic -// * +// --pallet=bifrost_salp +// --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 // --header=./HEADER-GPL3 -// --output=./runtime/asgard/src/weights/salp.rs +// --output=./runtime/asgard/src/weights/bifrost_salp.rs #![allow(unused_parens)] #![allow(unused_imports)] @@ -48,22 +46,20 @@ use sp_std::marker::PhantomData; pub struct WeightInfo(PhantomData); impl bifrost_salp::WeightInfo for WeightInfo { fn create() -> Weight { - (2_345_291_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + (60_294_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - fn contribute() -> Weight { - (1_251_633_000 as Weight) + (63_079_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - fn on_finalize(n: u32) -> Weight { - (290_825_000 as Weight) - // Standard Error: 5_000 - .saturating_add((399_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + (8_753_000 as Weight) + // Standard Error: 0 + .saturating_add((214_000 as Weight).saturating_mul(n 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/weights/mod.rs b/runtime/dev/src/weights/mod.rs index 3cdec6fda5..2206502d2c 100644 --- a/runtime/dev/src/weights/mod.rs +++ b/runtime/dev/src/weights/mod.rs @@ -20,5 +20,6 @@ //! A list of the different weight modules for our runtime. -pub mod pallet_salp; +pub mod bifrost_bancor; +pub mod bifrost_salp; pub mod pallet_vesting; diff --git a/runtime/dev/src/weights/pallet_assets.rs b/runtime/dev/src/weights/pallet_assets.rs deleted file mode 100644 index 82ec7cfe61..0000000000 --- a/runtime/dev/src/weights/pallet_assets.rs +++ /dev/null @@ -1,53 +0,0 @@ -// 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 . - -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 - -use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; -pub struct WeightInfo(PhantomData); -impl bifrost_assets::WeightInfo for WeightInfo { - fn create() -> Weight { - (65949000 as Weight) - //.saturating_add(T::DbWeight::get().reads(0 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn create_pair() -> Weight { - (65949000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn issue() -> Weight { - (46665000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn transfer() -> Weight { - (27086000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn destroy() -> Weight { - (39_603_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn redeem() -> Weight { - (110_679_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } -}