Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b79fd49
first version of multicurrency weight trader
apopiak May 3, 2022
4280ba4
add missing pallet-proxy in std feature
apopiak May 3, 2022
c1de129
add PriceOracle trait and fix compile issues
apopiak May 3, 2022
fc0f62f
add super simple test case
apopiak May 3, 2022
8d131f7
remove asset from paid_assets if remaining amount is zero
apopiak May 5, 2022
efc0ac4
add doc comments
apopiak May 5, 2022
590e01e
add negative test and adjust XCM integration tests
apopiak May 6, 2022
b458633
add more tests
apopiak May 10, 2022
dac2c7d
remove unused imports
apopiak May 10, 2022
abfe3af
Merge branch 'master' of github.com:galacticcouncil/Basilisk-node int…
apopiak May 12, 2022
d2ff079
point warehouse pallets to weight-trader branch
apopiak May 13, 2022
1f9c75f
use warehouse adapters instead of custom
apopiak May 19, 2022
c0e072a
use same version of orml-utilities pallet
apopiak May 19, 2022
83dbf35
update warehouse crates in Cargo.lock
apopiak May 19, 2022
077259b
add adapters crate to overrides
apopiak May 19, 2022
6461733
update warehouse crates in Cargo.lock
apopiak May 19, 2022
551dd66
fix compile errors
apopiak May 19, 2022
5c4d259
update MultiCurrencyTrader to include TakeRevenue type
apopiak May 25, 2022
58269a7
use PriceOracle impl from warehouse
apopiak May 26, 2022
36fec3e
Merge branch 'master' of github.com:galacticcouncil/Basilisk-node int…
apopiak May 27, 2022
ea91993
remove unused imports
apopiak May 28, 2022
f0a5b6f
transfer fees to FeeReceiver
apopiak May 28, 2022
0171c9f
update warehouse crates in Cargo.lock
apopiak May 28, 2022
381b0b3
remove fallback account in intregation tests
apopiak May 28, 2022
fbd8fd9
check that fees end up in treasury in integration tests
apopiak May 28, 2022
b8740ff
use TransferFees in testing runtime
apopiak May 28, 2022
1521299
set treasury as FeeReceiver in testing runtime
apopiak May 28, 2022
020e23c
add import for BoundedVec in marketplace tests
apopiak May 28, 2022
8d4e688
remove fallback account in more places
apopiak May 28, 2022
64de585
remove fallback accounts everywhere
apopiak May 28, 2022
e776618
Merge branch 'master' of github.com:galacticcouncil/Basilisk-node int…
apopiak Jun 13, 2022
2d3e4c7
update Cargo.lock
apopiak Jun 14, 2022
7effa0e
Merge branch 'master' of github.com:galacticcouncil/Basilisk-node int…
apopiak Jun 14, 2022
7147a57
update warehouse crates to merge commit and fix issues
apopiak Jun 14, 2022
4c7aa1a
Adjust Weight Trader Comment
apopiak Jun 14, 2022
8a14a74
bump spec_version
apopiak Jun 14, 2022
0f75a08
Merge branch 'master' into apopiak/weight-trader
enthusiastmartin Jun 16, 2022
ae64c25
use same trader in testing-basilisk
enthusiastmartin Jun 16, 2022
7eac58a
fix cross chain transfer test
apopiak Jun 16, 2022
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
25 changes: 22 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pallet-proxy = { git = "https://github.com/paritytech//substrate", rev = "22d40c
pallet-recovery = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-scheduler = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-session = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-session-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-session-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-society = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-staking = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
pallet-staking-reward-curve = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" }
Expand Down Expand Up @@ -185,15 +185,15 @@ cumulus-client-network = { git = "https://github.com/paritytech//cumulus", rev =
cumulus-client-service = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-primitives-core = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-primitives-timestamp = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-primitives-utility = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
parachain-info = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-relay-chain-interface = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }
cumulus-relay-chain-local = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" }

Expand Down
10 changes: 5 additions & 5 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "0.3.1"
version = "0.3.2"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand All @@ -10,8 +10,8 @@ repository = "https://github.com/galacticcouncil/Basilisk-node"

[dependencies]
# local dependencies
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "50c82ab02bb5baf99b263342dc5d4cc7e62c7e88", default-features = false}
pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "50c82ab02bb5baf99b263342dc5d4cc7e62c7e88", default-features = false}
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false}
pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false}

pallet-exchange = { path = "../pallets/exchange", default-features=false}
pallet-exchange-benchmarking = { path = "../pallets/exchange/benchmarking", optional = true, default-features = false}
Expand Down Expand Up @@ -65,8 +65,8 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "relea
polkadot-xcm = { package = "xcm", git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.17", default-features = false }

# HydraDX dependencies
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "50c82ab02bb5baf99b263342dc5d4cc7e62c7e88", default-features = false }
hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "50c82ab02bb5baf99b263342dc5d4cc7e62c7e88", default-features = false }
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }
hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }

# Substrate dependencies
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false, optional = true }
Expand Down
19 changes: 16 additions & 3 deletions integration-tests/src/cross_chain_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ fn transfer_from_relay_chain() {
Basilisk::execute_with(|| {
assert_eq!(
basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)),
1003 * BSX
10028 * BSX / 10 // 3 BSX - fees
);
assert_eq!(
basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()),
2 * BSX / 10 // fees should go to treasury
);
});
}
Expand Down Expand Up @@ -129,7 +133,11 @@ fn transfer_from_hydra() {
Basilisk::execute_with(|| {
assert_eq!(
basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)),
1003 * BSX
10028 * BSX / 10 // 3 * BSX - fees
);
assert_eq!(
basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()),
2 * BSX / 10 // fees should go to treasury
);
});
}
Expand Down Expand Up @@ -233,9 +241,14 @@ fn fee_currency_set_on_xcm_transfer() {
});

Basilisk::execute_with(|| {
let fee_amount = 2 * BSX / 10;
assert_eq!(
basilisk_runtime::Tokens::free_balance(1, &AccountId::from(HITCHHIKER)),
transfer_amount
transfer_amount - fee_amount
);
assert_eq!(
basilisk_runtime::Tokens::free_balance(1, &basilisk_runtime::Treasury::account_id()),
fee_amount // fees should go to treasury
);
// fee currency is set after XCM transfer
assert_eq!(
Expand Down
9 changes: 7 additions & 2 deletions integration-tests/src/kusama_test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ pub fn hydra_ext() -> sp_io::TestExternalities {
}

pub fn basilisk_ext() -> sp_io::TestExternalities {
use basilisk_runtime::{NativeExistentialDeposit, Runtime, System};
use basilisk_runtime::{MultiTransactionPayment, NativeExistentialDeposit, Runtime, System};
use frame_support::traits::OnInitialize;

let existential_deposit = NativeExistentialDeposit::get();

Expand Down Expand Up @@ -225,7 +226,11 @@ pub fn basilisk_ext() -> sp_io::TestExternalities {
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| System::set_block_number(1));
ext.execute_with(|| {
System::set_block_number(1);
// Make sure the prices are up-to-date.
MultiTransactionPayment::on_initialize(1);
});
ext
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/basilisk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "basilisk-runtime"
version = "53.0.0"
version = "54.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
homepage = "https://github.com/galacticcouncil/Basilisk-node"
Expand Down Expand Up @@ -49,6 +49,7 @@ pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", re
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false}
pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }
hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse",rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }

# collator support
pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.17", default-features = false }
Expand Down Expand Up @@ -202,6 +203,7 @@ std = [
"pallet-lbp/std",
"pallet-price-oracle/std",
"pallet-utility/std",
"hydradx-adapters/std",
"hydradx-traits/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down
2 changes: 1 addition & 1 deletion runtime/basilisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("basilisk"),
impl_name: create_runtime_str!("basilisk"),
authoring_version: 1,
spec_version: 53,
spec_version: 54,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
24 changes: 23 additions & 1 deletion runtime/basilisk/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ use frame_support::{
traits::{Everything, Nothing},
PalletId,
};
use hydradx_adapters::{MultiCurrencyTrader, ToFeeReceiver};
pub use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use polkadot_xcm::latest::prelude::*;
use polkadot_xcm::latest::Error;
use primitives::Price;
use sp_runtime::traits::Convert;

use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
EnsureXcmOrigin, FixedWeightBounds, LocationInverter, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
Expand Down Expand Up @@ -96,7 +99,26 @@ impl Config for XcmConfig {

type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Trader = TradePassthrough;
// We calculate weight fees the same way as for regular extrinsics and use the prices and choice
// of accepted currencies of the transaction payment pallet. Fees go to the same fee receiver as
// configured in `MultiTransactionPayment`.
type Trader = MultiCurrencyTrader<
AssetId,
Balance,
Price,
WeightToFee,
MultiTransactionPayment,
CurrencyIdConvert,
ToFeeReceiver<
AccountId,
AssetId,
Balance,
Price,
CurrencyIdConvert,
DepositAll<Runtime>,
MultiTransactionPayment,
>,
>;

type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
Expand Down
3 changes: 2 additions & 1 deletion runtime/testing-basilisk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "testing-basilisk-runtime"
version = "53.0.0"
version = "54.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
homepage = "https://github.com/galacticcouncil/Basilisk-node"
Expand Down Expand Up @@ -49,6 +49,7 @@ pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", re
pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }
pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false}
pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }
hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse",rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false }

# collator support
pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.17", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion runtime/testing-basilisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("testing-basilisk"),
impl_name: create_runtime_str!("testing-basilisk"),
authoring_version: 1,
spec_version: 53,
spec_version: 54,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
23 changes: 22 additions & 1 deletion runtime/testing-basilisk/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use frame_support::{
traits::{Everything, Nothing},
PalletId,
};
use hydradx_adapters::{MultiCurrencyTrader, ToFeeReceiver};
pub use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
Expand Down Expand Up @@ -96,7 +97,26 @@ impl Config for XcmConfig {

type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
type Trader = TradePassthrough;
// We calculate weight fees the same way as for regular extrinsics and use the prices and choice
// of accepted currencies of the transaction payment pallet. Fees go to the same fee receiver as
// configured in `MultiTransactionPayment`.
type Trader = MultiCurrencyTrader<
AssetId,
Balance,
Price,
WeightToFee,
MultiTransactionPayment,
CurrencyIdConvert,
ToFeeReceiver<
AccountId,
AssetId,
Balance,
Price,
CurrencyIdConvert,
DepositAll<Runtime>,
MultiTransactionPayment,
>,
>;

type ResponseHandler = PolkadotXcm;
type AssetTrap = PolkadotXcm;
Expand Down Expand Up @@ -167,6 +187,7 @@ impl pallet_xcm::Config for Runtime {

pub struct CurrencyIdConvert;
use primitives::constants::chain::CORE_ASSET_ID;
use primitives::Price;

impl Convert<AssetId, Option<MultiLocation>> for CurrencyIdConvert {
fn convert(id: AssetId) -> Option<MultiLocation> {
Expand Down