Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,8 @@ deploy-bifrost-live:
pm2 deploy scripts/bifrost-ecosystem.config.js production

# Run dev chain
.PHONY: run-dev
run-dev:
RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- --tmp --dev

.PHONY: run-dev-manual-seal
run-dev-manual-seal:
run-dev:
RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- --tmp --dev --sealing instant --rpc-cors all --unsafe-ws-external

# Build docker image
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ make try-bifrost-runtime-upgrade
## Run development chain

```bash
RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- --tmp --dev
make run-dev
```

## Run local testnet with polkadot-launch
Expand Down
6 changes: 6 additions & 0 deletions integration-tests/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ impl ExtBuilder {
)
.unwrap();

<pallet_xcm::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_xcm::GenesisConfig { safe_xcm_version: Some(2) },
&mut t,
)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext
Expand Down
56 changes: 56 additions & 0 deletions integration-tests/src/kusama_cross_chain_transact.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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/>.

use frame_support::assert_ok;
use xcm::latest::prelude::*;
use xcm_emulator::TestExt;

use crate::{integration_tests::*, kusama_test_net::*};

#[test]
fn relaychain_transact_works() {
let remark = kusama_runtime::Call::System(
frame_system::Call::<kusama_runtime::Runtime>::remark_with_event {
remark: "Hello from Bifrost!".as_bytes().to_vec(),
},
);

let asset: MultiAsset =
MultiAsset { id: Concrete(MultiLocation::here()), fun: Fungible(8000000000) };

let msg = Xcm(vec![
WithdrawAsset(asset.clone().into()),
BuyExecution { fees: asset, weight_limit: WeightLimit::Limited(6000000000) },
Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: 2000000000 as u64,
call: remark.encode().into(),
},
]);

Bifrost::execute_with(|| {
assert_ok!(pallet_xcm::Pallet::<Runtime>::send_xcm(Here, Parent, msg));
});

KusamaNet::execute_with(|| {
use kusama_runtime::{Event, System};
assert!(System::events()
.iter()
.any(|r| matches!(r.event, Event::System(frame_system::Event::Remarked(_, _)))));
});
}
2 changes: 2 additions & 0 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#[cfg(feature = "with-asgard-runtime")]
mod integration_tests;
#[cfg(feature = "with-asgard-runtime")]
mod kusama_cross_chain_transact;
#[cfg(feature = "with-asgard-runtime")]
mod kusama_cross_chain_transfer;
#[cfg(feature = "with-asgard-runtime")]
mod kusama_test_net;
22 changes: 14 additions & 8 deletions runtime/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = f
pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false }
xcm-support = { path = "../../xcm-support", default-features = false }
bifrost-liquidity-mining = { path = "../../pallets/liquidity-mining", default-features = false }
bifrost-token-issuer = { path = "../../pallets/token-issuer", default-features = false }
bifrost-lightening-redeem= { path = "../../pallets/lightening-redeem", default-features = false }
bifrost-call-switchgear= { path = "../../pallets/call-switchgear", default-features = false }
# orml
orml-currencies = { version = "0.4.1-dev", default-features = false }
orml-tokens = { version = "0.4.1-dev", default-features = false }
Expand Down Expand Up @@ -172,6 +175,14 @@ std = [
"xcm-builder/std",
"xcm-executor/std",
"polkadot-runtime-parachains/std",
"orml-currencies/std",
"orml-traits/std",
"orml-tokens/std",
"orml-xtokens/std",
"orml-xcm/std",
"orml-xcm-support/std",
"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
"bifrost-bancor/std",
"bifrost-bancor-runtime-api/std",
"bifrost-flexible-fee/std",
Expand All @@ -184,16 +195,11 @@ std = [
"bifrost-salp-lite-rpc-runtime-api/std",
"bifrost-vsbond-auction/std",
"bifrost-vtoken-mint/std",
"bifrost-token-issuer/std",
"bifrost-lightening-redeem/std",
"xcm-support/std",
"orml-currencies/std",
"orml-traits/std",
"orml-tokens/std",
"orml-xtokens/std",
"orml-xcm/std",
"orml-xcm-support/std",
"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
"bifrost-liquidity-mining/std",
"bifrost-call-switchgear/std",
]

runtime-benchmarks = [
Expand Down
45 changes: 38 additions & 7 deletions runtime/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ impl_opaque_keys! {
/// This runtime version.
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("asgard-dev"),
impl_name: create_runtime_str!("asgard-dev"),
spec_name: create_runtime_str!("bifrost-dev"),
impl_name: create_runtime_str!("bifrost-dev"),
authoring_version: 1,
spec_version: 1001,
impl_version: 0,
Expand Down Expand Up @@ -191,12 +191,19 @@ parameter_types! {
}

parameter_types! {
pub const NativeCurrencyId: CurrencyId = CurrencyId::Native(TokenSymbol::ASG);
pub const NativeCurrencyId: CurrencyId = CurrencyId::Native(TokenSymbol::BNC);
pub const RelayCurrencyId: CurrencyId = CurrencyId::Token(TokenSymbol::KSM);
pub const StableCurrencyId: CurrencyId = CurrencyId::Stable(TokenSymbol::KUSD);
pub const PolkadotCurrencyId: CurrencyId = CurrencyId::Token(TokenSymbol::DOT);
}

parameter_types! {
pub const TreasuryPalletId: PalletId = PalletId(*b"bf/trsry");
pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#");
pub const LiquidityMiningPalletId: PalletId = PalletId(*b"bf/lm###");
pub const LighteningRedeemPalletId: PalletId = PalletId(*b"bf/ltnrd");
}

impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
/// The identifier used to distinguish between accounts.
Expand Down Expand Up @@ -596,7 +603,6 @@ parameter_types! {
pub const ProposalBondMinimum: Balance = 50 * DOLLARS;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");

pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
Expand Down Expand Up @@ -1094,7 +1100,6 @@ pub fn create_x2_multilocation(index: u16) -> MultiLocation {

parameter_types! {
pub const MinContribution: Balance = 1 * DOLLARS;
pub const BifrostCrowdloanId: PalletId = PalletId(*b"bf/salp#");
pub const RemoveKeysLimit: u32 = 500;
pub const VSBondValidPeriod: BlockNumber = 30 * DAYS;
pub const ReleaseCycle: BlockNumber = 1 * DAYS;
Expand Down Expand Up @@ -1198,7 +1203,6 @@ parameter_types! {
pub const MinimumDuration: BlockNumber = DAYS;
pub const MaximumApproved: u32 = 8;
pub const MaximumOptionRewards: u32 = 7;
pub const LiquidityMiningPalletId: PalletId = PalletId(*b"mining##");
}

impl bifrost_liquidity_mining::Config for Runtime {
Expand All @@ -1217,6 +1221,30 @@ impl bifrost_liquidity_mining::Config for Runtime {
type WeightInfo = ();
}

impl bifrost_token_issuer::Config for Runtime {
type Event = Event;
type MultiCurrency = Currencies;
type ControlOrigin =
EnsureOneOf<AccountId, MoreThanHalfCouncil, EnsureRootOrAllTechnicalCommittee>;
type WeightInfo = weights::bifrost_token_issuer::WeightInfo<Runtime>;
}

impl bifrost_lightening_redeem::Config for Runtime {
type Event = Event;
type MultiCurrency = Tokens;
type ControlOrigin =
EnsureOneOf<AccountId, MoreThanHalfCouncil, EnsureRootOrAllTechnicalCommittee>;
type PalletId = LighteningRedeemPalletId;
type WeightInfo = weights::bifrost_lightening_redeem::WeightInfo<Runtime>;
}

impl bifrost_call_switchgear::Config for Runtime {
type Event = Event;
type UpdateOrigin =
EnsureOneOf<AccountId, MoreThanHalfCouncil, EnsureRootOrAllTechnicalCommittee>;
type WeightInfo = weights::bifrost_call_switchgear::WeightInfo<Runtime>;
}

// bifrost runtime end

// zenlink runtime start
Expand Down Expand Up @@ -1426,12 +1454,12 @@ construct_runtime! {
Vesting: pallet_vesting::{Pallet, Call, Storage, Event<T>, Config<T>} = 60,

// Third party modules
ZenlinkProtocol: zenlink_protocol::{Pallet, Call, Storage, Event<T>} = 61,
XTokens: orml_xtokens::{Pallet, Call, Event<T>} = 70,
Tokens: orml_tokens::{Pallet, Call, Storage, Event<T>, Config<T>} = 71,
Currencies: orml_currencies::{Pallet, Call, Event<T>} = 72,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 73,
OrmlXcm: orml_xcm::{Pallet, Call, Event<T>} = 74,
ZenlinkProtocol: zenlink_protocol::{Pallet, Call, Storage, Event<T>} = 80,

// Bifrost modules
VtokenMint: bifrost_vtoken_mint::{Pallet, Call, Storage, Event<T>, Config<T>} = 101,
Expand All @@ -1441,7 +1469,10 @@ construct_runtime! {
Bancor: bifrost_bancor::{Pallet, Call, Storage, Event<T>, Config<T>} = 106,
VSBondAuction: bifrost_vsbond_auction::{Pallet, Call, Storage, Event<T>} = 107,
LiquidityMining: bifrost_liquidity_mining::{Pallet, Call, Storage, Event<T>} = 108,
TokenIssuer: bifrost_token_issuer::{Pallet, Call, Storage, Event<T>} = 109,
LighteningRedeem: bifrost_lightening_redeem::{Pallet, Call, Storage, Event<T>} = 110,
SalpLite: bifrost_salp_lite::{Pallet, Call, Storage, Event<T>} = 111,
CallSwitchgear: bifrost_call_switchgear::{Pallet, Storage, Call, Event<T>} = 112,
}
}

Expand Down
74 changes: 74 additions & 0 deletions runtime/dev/src/weights/bifrost_call_switchgear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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/>.

//! Autogenerated weights for `bifrost_call_switchgear`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-11-01, 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_call_switchgear
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./HEADER-GPL3
// --output=./runtime/asgard/src/weights/bifrost_call_switchgear.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_call_switchgear`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> bifrost_call_switchgear::WeightInfo for WeightInfo<T> {
// Storage: CallSwitchgear SwitchedOffTransactions (r:1 w:1)
fn switchoff_transaction() -> Weight {
(26_520_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: CallSwitchgear SwitchedOffTransactions (r:1 w:1)
fn switchon_transaction() -> Weight {
(25_178_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: CallSwitchgear DisabledTransfers (r:1 w:1)
fn disable_transfers() -> Weight {
(25_318_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: CallSwitchgear DisabledTransfers (r:1 w:1)
fn enable_transfers() -> Weight {
(23_484_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
Loading