Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d293e47
Add benchmark for salp-lite
yrong Oct 26, 2021
dc65308
:bug: ($PALLET) Fix bancor bench error
AllenPocketGamer Oct 17, 2021
ab36334
:bug: ($PALLET) Fix vtoken-mint bench error
AllenPocketGamer Oct 17, 2021
0759f81
:wrench: ($PROJ) Add more phony
AllenPocketGamer Oct 18, 2021
c6a1b4b
:bug: ($PALLETS) Fix benchmark errors that occur by compile
AllenPocketGamer Oct 26, 2021
1fcf2af
:sparkles: ($RUNTIME) Supple the benchmark settings that missing on B…
AllenPocketGamer Oct 26, 2021
6c2066a
:fire: ($RUNTIME) Unlist pallet_* benchmarks
AllenPocketGamer Oct 26, 2021
1ace60c
:recycle: ($SCRIPT) Refactor script that generates weightInfos
AllenPocketGamer Oct 27, 2021
de1d263
:fire: ($RUNTIME) Remove useless code
AllenPocketGamer Oct 27, 2021
24846a8
:recycle: ($SCRIPT) Refactor ..
AllenPocketGamer Oct 27, 2021
f6d9e79
:construction_worker: ($CI) Try to generate all-runtime weight files
AllenPocketGamer Oct 27, 2021
a1e8ebd
:art: ($RUNTIME) Format ..
AllenPocketGamer Oct 27, 2021
d82720b
:construction: ($CI) Close check & test temporarily
AllenPocketGamer Oct 27, 2021
4f87cdd
:construction: ($CI) Working around..
AllenPocketGamer Oct 27, 2021
c5e9242
:bug: ($SCRIPT) Fix Syntax error 2
AllenPocketGamer Oct 27, 2021
d118482
:construction_worker: ($CI) Modify ci flow
AllenPocketGamer Oct 28, 2021
9fa3839
:bug: ($CI) Fix ci syntax error
AllenPocketGamer Oct 28, 2021
e615ce3
:bug: ($PALLET) Fix bench errors of lightening-redeem
AllenPocketGamer Oct 28, 2021
73d80ad
:bug: ($CI) Remove file_pattern option
AllenPocketGamer Oct 28, 2021
7e7dd2c
🤖 ($WEIGHT) Generate weightInfo files automatically
AllenPocketGamer Oct 28, 2021
8f85d52
fix support of token dot (#384)
herryho Nov 1, 2021
e64908c
add-call-switchgear pallet
herryho Oct 26, 2021
01d85b0
add diabling token transfer functionality
herryho Nov 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
jobs:
build:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: self-hosted
runs-on: [self-hosted, normal]
steps:
- name: Check to latest commit
uses: actions/checkout@v2
Expand All @@ -42,4 +42,27 @@ jobs:
status: ${{ job.status }}
fields: repo,author,eventName,workflow,ref,commit
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PULLREQUEST_WEBHOOK_URL }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PULLREQUEST_WEBHOOK_URL }}
bench:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: [self-hosted, bench]
steps:
- name: Check to latest commit
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-09-12
components: rustfmt
target: wasm32-unknown-unknown
default: true
- name: Generate WeightInfo Files
run: make generate-all-weights
- name: Commit Automatically
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 🤖 ($WEIGHT) Generate weightInfo files automatically
# file_pattern: runtime/**/*.rs
25 changes: 25 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ members = [
"pallets/vsbond-auction",
"pallets/vtoken-mint",
"pallets/vtoken-mint/rpc",
"pallets/call-switchgear",
"runtime/asgard",
"runtime/bifrost",
"xcm-support",
Expand Down
26 changes: 23 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,29 @@ format:
test-benchmarking:
cargo test --features runtime-benchmarks --features with-all-runtime --features --all benchmarking

.PHONY: run-benchmarking
run-benchmarking:
./scripts/run_all_benches.sh
.PHONY: generate-bifrost-weights
generate-bifrost-weights:
bash ./scripts/generate-weights.sh bifrost

.PHONY: generate-asgard-weights
generate-asgard-weights:
bash ./scripts/generate-weights.sh asgard

.PHONY: generate-all-weights
generate-all-weights:
bash ./scripts/generate-weights.sh asgard bifrost

.PHONY: build-asgard-release-with-bench
build-asgard-release-with-bench: copy-genesis-config-release
cargo build -p node-cli --locked --features "with-asgard-runtime,runtime-benchmarks" --release

.PHONY: build-bifrost-release-with-bench
build-bifrost-release-with-bench: copy-genesis-config-release
cargo build -p node-cli --locked --features "with-bifrost-runtime,runtime-benchmarks" --release

.PHONY: build-all-release-with-bench
build-all-release-with-bench: copy-genesis-config-release
cargo build -p node-cli --locked --features "with-all-runtime,runtime-benchmarks" --release

# Deploy
.PHONY: deploy-asgard-local
Expand Down
2 changes: 2 additions & 0 deletions node/service/src/chain_spec/asgard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
(x.clone(), CurrencyId::Token(TokenSymbol::KSM), ENDOWMENT * 4_000_000),
(x.clone(), CurrencyId::Native(TokenSymbol::ASG), ENDOWMENT * 4_000_000),
(x.clone(), CurrencyId::VSToken(TokenSymbol::KSM), ENDOWMENT * 4_000_000),
(x.clone(), CurrencyId::Token(TokenSymbol::DOT), ENDOWMENT * 4_000_000),
(x.clone(), CurrencyId::VSToken(TokenSymbol::DOT), ENDOWMENT * 4_000_000),
(
x.clone(),
CurrencyId::VSBond(TokenSymbol::BNC, 2001, 13, 20),
Expand Down
7 changes: 7 additions & 0 deletions node/service/src/chain_spec/bifrost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ fn development_config_genesis(id: ParaId) -> GenesisConfig {
(x.clone(), CurrencyId::Stable(TokenSymbol::KUSD), ENDOWMENT * 10_000),
(x.clone(), CurrencyId::Token(TokenSymbol::KAR), ENDOWMENT * 10_000),
(x.clone(), CurrencyId::Token(TokenSymbol::KSM), ENDOWMENT),
(x.clone(), CurrencyId::Token(TokenSymbol::DOT), ENDOWMENT),
(x.clone(), CurrencyId::VSToken(TokenSymbol::DOT), ENDOWMENT),
]
})
.collect();
Expand Down Expand Up @@ -197,6 +199,11 @@ fn local_config_genesis(id: ParaId) -> GenesisConfig {
CurrencyId::VSBond(TokenSymbol::KSM, 3000, 13, 20),
ENDOWMENT * 4_000_000,
),
(
x.clone(),
CurrencyId::VSBond(TokenSymbol::BNC, 2001, 13, 20),
ENDOWMENT * 4_000_000,
),
]
})
.collect();
Expand Down
8 changes: 4 additions & 4 deletions pallets/bancor/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ use crate::Pallet as Bancor;

benchmarks! {
add_token_to_pool {
let currency_id = CurrencyId::Token(TokenSymbol::DOT);
let currency_id = CurrencyId::Token(TokenSymbol::KSM);
let caller: T::AccountId = whitelisted_caller();
let token_amount = BalanceOf::<T>::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 currency_id = CurrencyId::Token(TokenSymbol::KSM);
let vstoken_amount = BalanceOf::<T>::unique_saturated_from(1u128);
let token_out_min = BalanceOf::<T>::unique_saturated_from(0u128);

Expand All @@ -53,7 +53,7 @@ benchmarks! {

exchange_for_vstoken {
let caller: T::AccountId = whitelisted_caller();
let currency_id = CurrencyId::Token(TokenSymbol::DOT);
let currency_id = CurrencyId::Token(TokenSymbol::KSM);
let token_amount = BalanceOf::<T>::unique_saturated_from(100u128);
let vstoken_out_min = BalanceOf::<T>::unique_saturated_from(0u128);

Expand All @@ -65,7 +65,7 @@ benchmarks! {
}: _(RawOrigin::Signed(caller), currency_id, token_amount, vstoken_out_min)

on_initialize {
let currency_id = CurrencyId::Token(TokenSymbol::DOT);
let currency_id = CurrencyId::Token(TokenSymbol::KSM);
let caller: T::AccountId = whitelisted_caller();
let token_amount = BalanceOf::<T>::unique_saturated_from(7200 as u128);

Expand Down
46 changes: 46 additions & 0 deletions pallets/call-switchgear/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[package]
name = "bifrost-call-switchgear"
version = "0.8.0"
authors = ["Herry Ho <herry.heyi@gmail.com>"]
edition = "2018"

[dependencies]
serde = { version = "1.0.124", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false, optional = true }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11", default-features = false }
node-primitives = { path = "../../node/primitives", default-features = false }
orml-traits = { version = "0.4.1-dev", default-features = false }
scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.11" }
orml-tokens = { version = "0.4.1-dev", default-features = false }
smallvec = "1.4.1"

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"sp-io/std",
"sp-std/std",
"node-primitives/std",
"orml-traits/std",
]
try-runtime = ["frame-support/try-runtime"]

runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]

59 changes: 59 additions & 0 deletions pallets/call-switchgear/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 <https://www.gnu.org/licenses/>.

#![cfg(feature = "runtime-benchmarks")]

use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
use frame_support::dispatch::UnfilteredDispatchable;
use node_primitives::{CurrencyId, TokenSymbol};

use super::*;
#[allow(unused_imports)]
use crate::Pallet as CallSwitchgear;

benchmarks! {
switchoff_transaction {
let origin = T::UpdateOrigin::successful_origin();
let switchoff_call = Call::<T>::switchoff_transaction{pallet_name: b"Balances".to_vec(), function_name: b"transfer".to_vec()};
}: {switchoff_call.dispatch_bypass_filter(origin)?}

switchon_transaction {
let origin = T::UpdateOrigin::successful_origin();
let switchoff_call = Call::<T>::switchoff_transaction{pallet_name: b"Balances".to_vec(), function_name: b"transfer".to_vec()};
switchoff_call.dispatch_bypass_filter(origin.clone())?;
let switchon_call = Call::<T>::switchon_transaction{pallet_name: b"Balances".to_vec(), function_name: b"transfer".to_vec()};
}: {switchon_call.dispatch_bypass_filter(origin)?}

disable_transfers {
let origin = T::UpdateOrigin::successful_origin();
let disable_call = Call::<T>::disable_transfers{currency_id: CurrencyId::Token(TokenSymbol::KSM)};
}: {disable_call.dispatch_bypass_filter(origin)?}

enable_transfers {
let origin = T::UpdateOrigin::successful_origin();
let disable_call = Call::<T>::disable_transfers{currency_id: CurrencyId::Token(TokenSymbol::KSM)};
disable_call.dispatch_bypass_filter(origin.clone())?;
let enable_call = Call::<T>::enable_transfers{currency_id: CurrencyId::Token(TokenSymbol::KSM)};
}: {enable_call.dispatch_bypass_filter(origin)?}
}

impl_benchmark_test_suite!(
CallSwitchgear,
crate::mock::ExtBuilder::default().build(),
crate::mock::Runtime
);
Loading