From b79fd49f4b8741ebe42786aa93eccd50b6f18fe3 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 3 May 2022 12:55:58 +0200 Subject: [PATCH 01/34] first version of multicurrency weight trader --- runtime/basilisk/src/xcm.rs | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 8b93d798fe3..1df692bed2c 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -81,6 +81,105 @@ impl WeightTrader for TradePassthrough { } } +/// Weight trader which uses the `TransactionPayment` pallet to set the right price for weight and then +/// places any weight bought into the right account. +pub struct MultiCurrencyTrader< + WeightToFee: WeightToFeePolynomial, + AssetId: Get, + AccountId, + Currency: CurrencyT, + OnUnbalanced: OnUnbalancedT, + AcceptedCurrencyPrices: pallet_transaction_multi_payment::Config, + ConvertCurrency: Convert>, +> { + weight: Weight, + paid_assets: BTreeMap<(AssetId, Price), u128>, + _phantom: PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced, AcceptedCurrencyPrices, ConvertCurrency)>, +} + +impl< + WeightToFee: WeightToFeePolynomial, + AssetId: Get, + AccountId, + Currency: CurrencyT, + OnUnbalanced: OnUnbalancedT, + AcceptedCurrencyPrices: pallet_transaction_multi_payment::Config, + ConvertCurrency: Convert>, + > + MultiCurrencyTrader +{ + fn get_asset_and_price(&mut self, weight: Weight, &payment: Assets) -> Option<(Multilocation, Price)> { + if let Some(asset) = payment.fungible_assets_iter().next() { + // TODO: consider optimizing out the clone + CurrencyConvert::convert(asset.id.clone()) + .and_then(|currency| { + AcceptedCurrencyPrices::currency_price(currency) + }).and_then(|price| (asset.id.clone(), price)) + } else { + None + } + } +} + +impl< + WeightToFee: WeightToFeePolynomial, + AssetId: Get, + AccountId, + Currency: CurrencyT, + OnUnbalanced: OnUnbalancedT, + AcceptedCurrencyPrices: pallet_transaction_multi_payment::Config, + ConvertCurrency: Convert>, + > WeightTrader for MultiCurrencyTrader +{ + fn new() -> Self { + Self { weight: 0, paid_assets: Default::default(), _phantom: PhantomData } + } + + fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { + log::trace!(target: "xcm::weight", "MultiCurrencyTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment); + let (asset_id, price) = self.get_asset_and_price(weight, &payment).ok_or(XcmError::TooExpensive)?; + let fee = WeightToFee::calc(weight); + let converted_fee = price.checked_mul_int(fee).ok_or(XcmError::Overflow)?; + let amount: u128 = converted_fee.try_into().map_err(|_| XcmError::Overflow)?; + let required = (Concrete(asset_id), amount).into(); + let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; + self.weight = self.weight.saturating_add(weight); + match self.assets.get_mut(&(asset_id, price)) { + Some(v) => v.saturating_accrue(amount), + None => self.assets.insert((asset_id, price), amount), + } + Ok(unused) + } + + /// Will refund up to `weight` from the first asset tracked by the trader. + fn refund_weight(&mut self, weight: Weight) -> Option { + log::trace!(target: "xcm::weight", "MultiCurrencyTrader::refund_weight weight: {:?}", weight); + let weight = weight.min(self.weight); + self.weight -= weight; // Will not underflow because of `min()` above. + let fee = WeightToFee::calc(&weight); + if let Some(((asset_id, price), amount) = self.assets.iter_mut().next() { + let converted_fee: u128 = price.saturating_mul_int(fee).saturated_into(); + let refund = converted_fee.min(*amount); + amount -= refund; // Will not underflow because of `min()` above. + Some((Concrete(asset_id), refund).into()) + } else { + None + } + } +} +impl< + WeightToFee: WeightToFeePolynomial, + AssetId: Get, + AccountId, + Currency: CurrencyT, + OnUnbalanced: OnUnbalancedT, + > Drop for MultiCurrencyTrader +{ + fn drop(&mut self) { + OnUnbalanced::on_unbalanced(Currency::issue(self.1)); + } +} + pub struct XcmConfig; impl Config for XcmConfig { type Call = Call; @@ -279,3 +378,4 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< CurrencyIdConvert, (), >; + From 4280ba4bdf23d2d0b19f1a3926d8064dcf953b6b Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 3 May 2022 13:44:36 +0200 Subject: [PATCH 02/34] add missing pallet-proxy in std feature --- runtime/basilisk/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index a04b8dff501..9eb7380eaf2 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -221,6 +221,7 @@ std = [ "pallet-treasury/std", "pallet-collective/std", "pallet-democracy/std", + "pallet-proxy/std", "pallet-scheduler/std", "pallet-tips/std", "pallet-collator-selection/std", From c1de129dfafa19d591de233a5fb71bd08af3184d Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 3 May 2022 14:42:41 +0200 Subject: [PATCH 03/34] add PriceOracle trait and fix compile issues --- Cargo.lock | 9 ++-- runtime/basilisk/Cargo.toml | 1 + runtime/basilisk/src/xcm.rs | 91 +++++++++++++++++-------------------- 3 files changed, 48 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b8d3480673..be8579c2d83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -519,6 +519,7 @@ dependencies = [ "hash-db", "hex-literal", "hydradx-traits", + "log", "memory-db 0.27.0", "orml-benchmarking", "orml-currencies", @@ -4547,9 +4548,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", "value-bag", @@ -11935,9 +11936,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.0.0-alpha.8" +version = "1.0.0-alpha.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79923f7731dc61ebfba3633098bf3ac533bbd35ccd8c57e7088d9a5eebe0263f" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" dependencies = [ "ctor", "version_check", diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index 9eb7380eaf2..6e94027804d 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -25,6 +25,7 @@ hash-db = { version = "0.15.2", default-features = false } memory-db = { version = "0.27.0", default-features = false } trie-db = { version = "0.22.6", default-features = false } smallvec = "1.6.1" +log = { version = "0.4.17", default-features = false } # local dependencies primitives = { default-features = false, path = "../../primitives" } diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 1df692bed2c..ca852d1594d 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -8,7 +8,9 @@ use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; use polkadot_xcm::latest::prelude::*; use polkadot_xcm::latest::Error; -use sp_runtime::traits::Convert; +use primitives::Price; +use sp_runtime::{traits::{Convert, Saturating}, FixedPointNumber, SaturatedConversion}; +use sp_std::collections::btree_map::BTreeMap; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, ParentIsPreset, RelayChainAsNative, @@ -81,40 +83,45 @@ impl WeightTrader for TradePassthrough { } } +pub trait PriceOracle { + fn price(currency: AssetId) -> Option; +} + +impl PriceOracle for MultiTransactionPayment { + fn price(currency: AssetId) -> Option { + MultiTransactionPayment::currency_price(currency) + } +} + /// Weight trader which uses the `TransactionPayment` pallet to set the right price for weight and then /// places any weight bought into the right account. pub struct MultiCurrencyTrader< - WeightToFee: WeightToFeePolynomial, - AssetId: Get, - AccountId, - Currency: CurrencyT, - OnUnbalanced: OnUnbalancedT, - AcceptedCurrencyPrices: pallet_transaction_multi_payment::Config, + WeightToFee: WeightToFeePolynomial, + AcceptedCurrencyPrices: PriceOracle, ConvertCurrency: Convert>, > { weight: Weight, - paid_assets: BTreeMap<(AssetId, Price), u128>, - _phantom: PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced, AcceptedCurrencyPrices, ConvertCurrency)>, + paid_assets: BTreeMap<(MultiLocation, Price), u128>, + _phantom: PhantomData<(WeightToFee, AcceptedCurrencyPrices, ConvertCurrency)>, } impl< - WeightToFee: WeightToFeePolynomial, - AssetId: Get, - AccountId, - Currency: CurrencyT, - OnUnbalanced: OnUnbalancedT, - AcceptedCurrencyPrices: pallet_transaction_multi_payment::Config, + WeightToFee: WeightToFeePolynomial, + AcceptedCurrencyPrices: PriceOracle, ConvertCurrency: Convert>, > - MultiCurrencyTrader + MultiCurrencyTrader { - fn get_asset_and_price(&mut self, weight: Weight, &payment: Assets) -> Option<(Multilocation, Price)> { + fn get_asset_and_price(&mut self, payment: &Assets) -> Option<(MultiLocation, Price)> { if let Some(asset) = payment.fungible_assets_iter().next() { // TODO: consider optimizing out the clone - CurrencyConvert::convert(asset.id.clone()) + ConvertCurrency::convert(asset.clone()) .and_then(|currency| { - AcceptedCurrencyPrices::currency_price(currency) - }).and_then(|price| (asset.id.clone(), price)) + AcceptedCurrencyPrices::price(currency) + }).and_then(|price| match asset.id.clone() { + Concrete(location) => Some((location, price)), + _ => None, + }) } else { None } @@ -122,14 +129,10 @@ impl< } impl< - WeightToFee: WeightToFeePolynomial, - AssetId: Get, - AccountId, - Currency: CurrencyT, - OnUnbalanced: OnUnbalancedT, - AcceptedCurrencyPrices: pallet_transaction_multi_payment::Config, + WeightToFee: WeightToFeePolynomial, + AcceptedCurrencyPrices: PriceOracle, ConvertCurrency: Convert>, - > WeightTrader for MultiCurrencyTrader + > WeightTrader for MultiCurrencyTrader { fn new() -> Self { Self { weight: 0, paid_assets: Default::default(), _phantom: PhantomData } @@ -137,48 +140,38 @@ impl< fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { log::trace!(target: "xcm::weight", "MultiCurrencyTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment); - let (asset_id, price) = self.get_asset_and_price(weight, &payment).ok_or(XcmError::TooExpensive)?; - let fee = WeightToFee::calc(weight); + let (asset_loc, price) = self.get_asset_and_price(&payment).ok_or(XcmError::TooExpensive)?; + let fee = WeightToFee::calc(&weight); let converted_fee = price.checked_mul_int(fee).ok_or(XcmError::Overflow)?; let amount: u128 = converted_fee.try_into().map_err(|_| XcmError::Overflow)?; - let required = (Concrete(asset_id), amount).into(); + let required = (Concrete(asset_loc.clone()), amount).into(); let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; self.weight = self.weight.saturating_add(weight); - match self.assets.get_mut(&(asset_id, price)) { + let key = (asset_loc, price); + match self.paid_assets.get_mut(&key) { Some(v) => v.saturating_accrue(amount), - None => self.assets.insert((asset_id, price), amount), + None => { self.paid_assets.insert(key, amount); }, } Ok(unused) } /// Will refund up to `weight` from the first asset tracked by the trader. fn refund_weight(&mut self, weight: Weight) -> Option { - log::trace!(target: "xcm::weight", "MultiCurrencyTrader::refund_weight weight: {:?}", weight); + log::trace!(target: "xcm::weight", "MultiCurrencyTrader::refund_weight weight: {:?}, paid_assets: {:?}", weight, self.paid_assets); let weight = weight.min(self.weight); self.weight -= weight; // Will not underflow because of `min()` above. let fee = WeightToFee::calc(&weight); - if let Some(((asset_id, price), amount) = self.assets.iter_mut().next() { + if let Some(((asset_loc, price), amount)) = self.paid_assets.iter_mut().next() { let converted_fee: u128 = price.saturating_mul_int(fee).saturated_into(); let refund = converted_fee.min(*amount); - amount -= refund; // Will not underflow because of `min()` above. - Some((Concrete(asset_id), refund).into()) + // TODO: remove entry when new amount is 0 + *amount -= refund; // Will not underflow because of `min()` above. + Some((Concrete(asset_loc.clone()), refund).into()) } else { None } } } -impl< - WeightToFee: WeightToFeePolynomial, - AssetId: Get, - AccountId, - Currency: CurrencyT, - OnUnbalanced: OnUnbalancedT, - > Drop for MultiCurrencyTrader -{ - fn drop(&mut self) { - OnUnbalanced::on_unbalanced(Currency::issue(self.1)); - } -} pub struct XcmConfig; impl Config for XcmConfig { @@ -194,7 +187,7 @@ impl Config for XcmConfig { type Barrier = Barrier; type Weigher = FixedWeightBounds; - type Trader = TradePassthrough; + type Trader = MultiCurrencyTrader; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; From fc0f62f1f574fdb75153a9bef746ab6545e39c46 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 3 May 2022 15:49:51 +0200 Subject: [PATCH 04/34] add super simple test case --- runtime/basilisk/src/xcm.rs | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index ca852d1594d..a0575fbe06a 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -372,3 +372,82 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< (), >; +#[cfg(test)] +mod tests { + use super::*; + use frame_support::weights::IdentityFee; + use sp_runtime::traits::One; + + const TEST_ASSET_ID: AssetId = 123; + + struct MockOracle; + impl PriceOracle for MockOracle { + fn price(currency: AssetId) -> Option { + match currency { + CORE_ASSET_ID => Some(Price::one()), + TEST_ASSET_ID => Some(Price::from_float(0.5)), + _ => None, + } + } + } + + struct MockConvert; + impl Convert> for MockConvert { + fn convert(id: AssetId) -> Option { + match id { + CORE_ASSET_ID | TEST_ASSET_ID => Some(MultiLocation::new( + 0, + X1(GeneralKey(id.encode())), + )), + _ => None + } + } + } + + impl Convert> for MockConvert { + fn convert(location: MultiLocation) -> Option { + match location { + MultiLocation { + parents: 0, + interior: X1(GeneralKey(key)), + } => { + if let Ok(currency_id) = AssetId::decode(&mut &key[..]) { + // we currently have only one native asset + match currency_id { + CORE_ASSET_ID | TEST_ASSET_ID => Some(currency_id), + _ => None, + } + } else { + None + } + } + _ => None, + } + } + } + + impl Convert> for MockConvert { + fn convert(asset: MultiAsset) -> Option { + if let MultiAsset { + id: Concrete(location), .. + } = asset + { + Self::convert(location) + } else { + None + } + } + } + + #[test] + fn multi_currency_trader() { + type Trader = MultiCurrencyTrader, MockOracle, MockConvert>; + + let mut trader = Trader::new(); + let payment: MultiAsset = (Concrete(MockConvert::convert(CORE_ASSET_ID).unwrap()), 1_000_000).into(); + + let res = dbg!(trader.buy_weight(1_000_000, payment.into())); + assert!(.is_ok()); + assert!(res.unwrap().is_empty()); + } +} From 8d131f7885b87e0eae4ce0b436050a1a4600e435 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 5 May 2022 15:11:55 +0200 Subject: [PATCH 05/34] remove asset from paid_assets if remaining amount is zero --- runtime/basilisk/src/xcm.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index a0575fbe06a..8d02a57b71b 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -9,7 +9,7 @@ use polkadot_parachain::primitives::Sibling; use polkadot_xcm::latest::prelude::*; use polkadot_xcm::latest::Error; use primitives::Price; -use sp_runtime::{traits::{Convert, Saturating}, FixedPointNumber, SaturatedConversion}; +use sp_runtime::{traits::{Convert, Saturating, Zero}, FixedPointNumber, SaturatedConversion}; use sp_std::collections::btree_map::BTreeMap; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, @@ -164,9 +164,14 @@ impl< if let Some(((asset_loc, price), amount)) = self.paid_assets.iter_mut().next() { let converted_fee: u128 = price.saturating_mul_int(fee).saturated_into(); let refund = converted_fee.min(*amount); - // TODO: remove entry when new amount is 0 *amount -= refund; // Will not underflow because of `min()` above. - Some((Concrete(asset_loc.clone()), refund).into()) + + let refund_asset = asset_loc.clone(); + if amount.is_zero() { + let key = (asset_loc.clone(), price.clone()); + self.paid_assets.remove(&key); + } + Some((Concrete(refund_asset), refund).into()) } else { None } @@ -447,7 +452,6 @@ mod tests { let payment: MultiAsset = (Concrete(MockConvert::convert(CORE_ASSET_ID).unwrap()), 1_000_000).into(); let res = dbg!(trader.buy_weight(1_000_000, payment.into())); - assert!(.is_ok()); assert!(res.unwrap().is_empty()); } } From efc0ac454deb8f26a28da3e7ae1a3eb09bfbc43f Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 5 May 2022 15:12:28 +0200 Subject: [PATCH 06/34] add doc comments --- runtime/basilisk/src/xcm.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 8d02a57b71b..1e8cdac9833 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -83,6 +83,8 @@ impl WeightTrader for TradePassthrough { } } +/// Very simple price oracle trait. +/// TODO: Move to correct location and properly define the price oracle interface. pub trait PriceOracle { fn price(currency: AssetId) -> Option; } @@ -93,8 +95,9 @@ impl PriceOracle for MultiTransactionPayment { } } -/// Weight trader which uses the `TransactionPayment` pallet to set the right price for weight and then -/// places any weight bought into the right account. +/// Weight trader which uses `WeightToFee` in combination with a `PriceOracle` to set the right +/// price for weight. Keeps track of the assets used used to pay for weight and can refund them one +/// by one (interface only allows returning one asset per refund). pub struct MultiCurrencyTrader< WeightToFee: WeightToFeePolynomial, AcceptedCurrencyPrices: PriceOracle, @@ -112,6 +115,8 @@ impl< > MultiCurrencyTrader { + /// Get the asset id of the first asset in `payment` and try to determine its price via the + /// price oracle. fn get_asset_and_price(&mut self, payment: &Assets) -> Option<(MultiLocation, Price)> { if let Some(asset) = payment.fungible_assets_iter().next() { // TODO: consider optimizing out the clone @@ -138,6 +143,8 @@ impl< Self { weight: 0, paid_assets: Default::default(), _phantom: PhantomData } } + /// Will try to buy weight with the first asset in `payment`. + /// The fee is determined by `WeightToFee` in combination with the determined price. fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { log::trace!(target: "xcm::weight", "MultiCurrencyTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment); let (asset_loc, price) = self.get_asset_and_price(&payment).ok_or(XcmError::TooExpensive)?; From 590e01ecdf8cb0d2fe25e6d4c47db26885e8c849 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Fri, 6 May 2022 17:54:04 +0200 Subject: [PATCH 07/34] add negative test and adjust XCM integration tests --- integration-tests/src/cross_chain_transfer.rs | 4 +- integration-tests/src/kusama_test_net.rs | 9 +++- runtime/basilisk/src/xcm.rs | 41 +++++++++++++++---- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/integration-tests/src/cross_chain_transfer.rs b/integration-tests/src/cross_chain_transfer.rs index 22342743fa5..9444c4e93a7 100644 --- a/integration-tests/src/cross_chain_transfer.rs +++ b/integration-tests/src/cross_chain_transfer.rs @@ -44,7 +44,7 @@ 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 ); }); } @@ -129,7 +129,7 @@ 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 ); }); } diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index c65282ed851..8b3d46ccba5 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -165,7 +165,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(); @@ -227,7 +228,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 } diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 1e8cdac9833..192c87faa13 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -199,6 +199,8 @@ impl Config for XcmConfig { type Barrier = Barrier; type Weigher = FixedWeightBounds; + // 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. type Trader = MultiCurrencyTrader; type ResponseHandler = PolkadotXcm; @@ -391,6 +393,7 @@ mod tests { use sp_runtime::traits::One; const TEST_ASSET_ID: AssetId = 123; + const CHEAP_ASSET_ID: AssetId = 420; struct MockOracle; impl PriceOracle for MockOracle { @@ -398,6 +401,7 @@ mod tests { match currency { CORE_ASSET_ID => Some(Price::one()), TEST_ASSET_ID => Some(Price::from_float(0.5)), + CHEAP_ASSET_ID => Some(Price::saturating_from_integer(4)), _ => None, } } @@ -407,7 +411,7 @@ mod tests { impl Convert> for MockConvert { fn convert(id: AssetId) -> Option { match id { - CORE_ASSET_ID | TEST_ASSET_ID => Some(MultiLocation::new( + CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID => Some(MultiLocation::new( 0, X1(GeneralKey(id.encode())), )), @@ -426,7 +430,7 @@ mod tests { if let Ok(currency_id) = AssetId::decode(&mut &key[..]) { // we currently have only one native asset match currency_id { - CORE_ASSET_ID | TEST_ASSET_ID => Some(currency_id), + CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID => Some(currency_id), _ => None, } } else { @@ -451,14 +455,37 @@ mod tests { } } + type Trader = MultiCurrencyTrader, MockOracle, MockConvert>; + + #[test] + fn can_buy_weight() { + let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); + let test_id = MockConvert::convert(TEST_ASSET_ID).unwrap(); + let cheap_id = MockConvert::convert(CHEAP_ASSET_ID).unwrap(); + + let mut trader = Trader::new(); + + let core_payment: MultiAsset = (Concrete(core_id), 1_000_000).into(); + let res = dbg!(trader.buy_weight(1_000_000, core_payment.into())); + assert!(res.expect("buy_weight should succeed because payment == weight").is_empty()); + + let test_payment: MultiAsset = (Concrete(test_id), 500_000).into(); + let res = dbg!(trader.buy_weight(1_000_000, test_payment.into())); + assert!(res.expect("buy_weight should succeed because payment == 0.5 * weight").is_empty()); + + let cheap_payment: MultiAsset = (Concrete(cheap_id), 4_000_000).into(); + let res = dbg!(trader.buy_weight(1_000_000, cheap_payment.into())); + assert!(res.expect("buy_weight should succeed because payment == 4 * weight").is_empty()); + } + #[test] - fn multi_currency_trader() { - type Trader = MultiCurrencyTrader, MockOracle, MockConvert>; + fn cannot_buy_with_too_few_tokens() { + let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); let mut trader = Trader::new(); - let payment: MultiAsset = (Concrete(MockConvert::convert(CORE_ASSET_ID).unwrap()), 1_000_000).into(); - let res = dbg!(trader.buy_weight(1_000_000, payment.into())); - assert!(res.unwrap().is_empty()); + let core_payment: MultiAsset = (Concrete(core_id), 69).into(); + let res = dbg!(trader.buy_weight(1_000_000, core_payment.into())); + assert_eq!(res, Err(XcmError::TooExpensive)); } } From b45863321235df983cb0b0f0154b766a300d24d6 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 10 May 2022 19:17:00 +0200 Subject: [PATCH 08/34] add more tests --- runtime/basilisk/src/xcm.rs | 88 ++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 192c87faa13..953899fbacc 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -147,7 +147,7 @@ impl< /// The fee is determined by `WeightToFee` in combination with the determined price. fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { log::trace!(target: "xcm::weight", "MultiCurrencyTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment); - let (asset_loc, price) = self.get_asset_and_price(&payment).ok_or(XcmError::TooExpensive)?; + let (asset_loc, price) = self.get_asset_and_price(&payment).ok_or(XcmError::AssetNotFound)?; let fee = WeightToFee::calc(&weight); let converted_fee = price.checked_mul_int(fee).ok_or(XcmError::Overflow)?; let amount: u128 = converted_fee.try_into().map_err(|_| XcmError::Overflow)?; @@ -390,10 +390,11 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< mod tests { use super::*; use frame_support::weights::IdentityFee; - use sp_runtime::traits::One; + use sp_runtime::traits::{Bounded, One}; const TEST_ASSET_ID: AssetId = 123; const CHEAP_ASSET_ID: AssetId = 420; + const OVERFLOW_ASSET_ID: AssetId = 1_000; struct MockOracle; impl PriceOracle for MockOracle { @@ -402,6 +403,7 @@ mod tests { CORE_ASSET_ID => Some(Price::one()), TEST_ASSET_ID => Some(Price::from_float(0.5)), CHEAP_ASSET_ID => Some(Price::saturating_from_integer(4)), + OVERFLOW_ASSET_ID => Some(Price::saturating_from_integer(2_147_483_647)), _ => None, } } @@ -411,7 +413,7 @@ mod tests { impl Convert> for MockConvert { fn convert(id: AssetId) -> Option { match id { - CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID => Some(MultiLocation::new( + CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID | OVERFLOW_ASSET_ID => Some(MultiLocation::new( 0, X1(GeneralKey(id.encode())), )), @@ -430,7 +432,7 @@ mod tests { if let Ok(currency_id) = AssetId::decode(&mut &key[..]) { // we currently have only one native asset match currency_id { - CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID => Some(currency_id), + CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID | OVERFLOW_ASSET_ID => Some(currency_id), _ => None, } } else { @@ -484,8 +486,82 @@ mod tests { let mut trader = Trader::new(); - let core_payment: MultiAsset = (Concrete(core_id), 69).into(); - let res = dbg!(trader.buy_weight(1_000_000, core_payment.into())); + let payment: MultiAsset = (Concrete(core_id), 69).into(); + let res = dbg!(trader.buy_weight(1_000_000, payment.into())); assert_eq!(res, Err(XcmError::TooExpensive)); } + + #[test] + fn cannot_buy_with_unknown_token() { + let unknown_token = GeneralKey(9876u32.encode()); + + let mut trader = Trader::new(); + let payment: MultiAsset = (Concrete(unknown_token.into()), 1_000_000).into(); + let res = dbg!(trader.buy_weight(1_000_000, payment.into())); + assert_eq!(res, Err(XcmError::AssetNotFound)); + } + + #[test] + fn overflow_errors() { + // Create a mock fee calculator that always returns `max_value`. + pub struct MaxFee; + impl WeightToFeePolynomial for MaxFee + { + type Balance = Balance; + + fn polynomial() -> WeightToFeeCoefficients { + smallvec!(WeightToFeeCoefficient { + coeff_integer: Balance::max_value(), + coeff_frac: Perbill::zero(), + negative: false, + degree: 1, + }) + } + } + type Trader = MultiCurrencyTrader; + + let overflow_id = MockConvert::convert(OVERFLOW_ASSET_ID).unwrap(); + + let mut trader = Trader::new(); + + let amount = 1_000; + let payment: MultiAsset = (Concrete(overflow_id), amount).into(); + let weight = 1_000; + let res = dbg!(trader.buy_weight(weight, payment.into())); + assert_eq!(res, Err(XcmError::Overflow)); + } + + #[test] + fn refunds_first_asset_completely() { + let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); + + let mut trader = Trader::new(); + + let weight = 1_000_000; + let tokens = 1_000_000; + let core_payment: MultiAsset = (Concrete(core_id), tokens).into(); + let res = dbg!(trader.buy_weight(weight, core_payment.clone().into())); + assert!(res.expect("buy_weight should succeed because payment == weight").is_empty()); + assert_eq!(trader.refund_weight(weight), Some(core_payment.into())); + } + + #[test] + fn needs_multiple_refunds_for_multiple_currencies() { + let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); + let test_id = MockConvert::convert(TEST_ASSET_ID).unwrap(); + + let mut trader = Trader::new(); + + let weight = 1_000_000; + let core_payment: MultiAsset = (Concrete(core_id), 1_000_000).into(); + let res = dbg!(trader.buy_weight(weight, core_payment.clone().into())); + assert!(res.expect("buy_weight should succeed because payment == weight").is_empty()); + + let test_payment: MultiAsset = (Concrete(test_id), 500_000).into(); + let res = dbg!(trader.buy_weight(weight, test_payment.clone().into())); + assert!(res.expect("buy_weight should succeed because payment == 0.5 * weight").is_empty()); + + assert_eq!(trader.refund_weight(weight), Some(core_payment.into())); + assert_eq!(trader.refund_weight(weight), Some(test_payment.into())); + } } From dac2c7dd6452143ed1c21ce01f13df53a4e2840e Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 10 May 2022 19:20:52 +0200 Subject: [PATCH 09/34] remove unused imports --- runtime/basilisk/src/xcm.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 953899fbacc..afdc1267559 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -390,7 +390,7 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< mod tests { use super::*; use frame_support::weights::IdentityFee; - use sp_runtime::traits::{Bounded, One}; + use sp_runtime::traits::One; const TEST_ASSET_ID: AssetId = 123; const CHEAP_ASSET_ID: AssetId = 420; From d2ff0798ee4e7c94e16ae563d1b3a3370ba2caac Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Fri, 13 May 2022 14:06:34 +0100 Subject: [PATCH 10/34] point warehouse pallets to weight-trader branch --- Cargo.toml | 10 +++++----- integration-tests/Cargo.toml | 8 ++++---- pallets/exchange/Cargo.toml | 4 ++-- pallets/exchange/benchmarking/Cargo.toml | 4 ++-- pallets/lbp/Cargo.toml | 2 +- pallets/liquidity-mining/Cargo.toml | 2 +- pallets/liquidity-mining/benchmarking/Cargo.toml | 4 ++-- pallets/offchain-duster/Cargo.toml | 2 +- pallets/xyk/Cargo.toml | 4 ++-- runtime/basilisk/Cargo.toml | 10 +++++----- runtime/common/Cargo.toml | 8 ++++---- runtime/testing-basilisk/Cargo.toml | 10 +++++----- 12 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0b9258e192c..0e1c704bba0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -198,8 +198,8 @@ cumulus-relay-chain-interface = { git = "https://github.com/paritytech//cumulus" cumulus-relay-chain-local = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" } [patch."https://github.com/galacticcouncil/warehouse"] -pallet-price-oracle = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1"} -pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1"} -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1"} -pallet-asset-registry= { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1"} -hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1"} +pallet-price-oracle = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} +pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} +pallet-asset-registry= { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} +hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 7fe6ae8fdef..ec39ae4a31c 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -20,8 +20,8 @@ trie-db = { version = "0.22.6", default-features = false } smallvec = "1.6.1" # local dependencies -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "d0c99033c5d1f686a31cc311b8d96af2a3de9d76", default-features = false} -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "d0c99033c5d1f686a31cc311b8d96af2a3de9d76", default-features = false} +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false} +pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false} pallet-exchange = { path = "../pallets/exchange", default-features=false} pallet-exchange-benchmarking = { path = "../pallets/exchange/benchmarking", optional = true, default-features = false} @@ -77,8 +77,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 = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } # Substrate dependencies frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false, optional = true } diff --git a/pallets/exchange/Cargo.toml b/pallets/exchange/Cargo.toml index b32b25a99fa..1ac6cee774e 100644 --- a/pallets/exchange/Cargo.toml +++ b/pallets/exchange/Cargo.toml @@ -29,8 +29,8 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } hydra-dx-math = { default-features = false, version = "4.1.1" } # Substrate dependencies diff --git a/pallets/exchange/benchmarking/Cargo.toml b/pallets/exchange/benchmarking/Cargo.toml index 61fb02289bc..b7abd79d885 100644 --- a/pallets/exchange/benchmarking/Cargo.toml +++ b/pallets/exchange/benchmarking/Cargo.toml @@ -29,8 +29,8 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } # Substrate dependencies frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index d1e5048e1ce..8038394d8bd 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -22,7 +22,7 @@ serde = { features = ["derive"], optional = true, version = "1.0.136" } # HydraDX dependencies hydra-dx-math = { default-features = false, version = "4.0.0" } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } ## Local dependencies primitives = { default-features = false, path = "../../primitives" } diff --git a/pallets/liquidity-mining/Cargo.toml b/pallets/liquidity-mining/Cargo.toml index 63a7f52b604..df26b8c183c 100644 --- a/pallets/liquidity-mining/Cargo.toml +++ b/pallets/liquidity-mining/Cargo.toml @@ -23,7 +23,7 @@ pallet-uniques = { git = "https://github.com/paritytech/substrate", branch = "po orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev="e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } primitives = { path = "../../primitives", default-features = false } diff --git a/pallets/liquidity-mining/benchmarking/Cargo.toml b/pallets/liquidity-mining/benchmarking/Cargo.toml index ec8adb3cfa9..8244430852d 100644 --- a/pallets/liquidity-mining/benchmarking/Cargo.toml +++ b/pallets/liquidity-mining/benchmarking/Cargo.toml @@ -24,8 +24,8 @@ pallet-liquidity-mining = { path = "../../liquidity-mining", default-features = orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev="e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } primitives = { path = "../../../primitives", default-features = false } diff --git a/pallets/offchain-duster/Cargo.toml b/pallets/offchain-duster/Cargo.toml index b3344933a69..735a4430445 100644 --- a/pallets/offchain-duster/Cargo.toml +++ b/pallets/offchain-duster/Cargo.toml @@ -26,7 +26,7 @@ primitives = { path = "../../primitives", default-features = false } pallet-duster = { path = "../duster", default-features = false } # Warehouse dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } # ORML dependencies orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index 2f2cfcf18e5..1932600cd22 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -31,7 +31,7 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-utilities = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } # Substrate dependencies frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false, optional = true } @@ -44,7 +44,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v [dev-dependencies] sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17" } [features] diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index bca13b2b7fb..0d6b2b6261f 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -49,11 +49,11 @@ pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", b pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } # Warehouse dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false} -pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false} +pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } # collator support pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.17", default-features = false } diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index b0419a79388..b731aeb732b 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -27,10 +27,10 @@ pallet-lbp = { path = "../../pallets/lbp", default-features = false } pallet-marketplace = { path = '../../pallets/marketplace', default-features = false } # Warehouse dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false} -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false} +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } # Substrate dependencies sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } diff --git a/runtime/testing-basilisk/Cargo.toml b/runtime/testing-basilisk/Cargo.toml index a2f5f598104..fc03002c90d 100644 --- a/runtime/testing-basilisk/Cargo.toml +++ b/runtime/testing-basilisk/Cargo.toml @@ -48,11 +48,11 @@ pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", b pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } # Warehouse dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false} -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "e428fd81f84781c4508df72f095e7bed6bb58ea1", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false} +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader", default-features = false } # collator support pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.17", default-features = false } From 1f9c75f3059015329f7a0c69b3a8fc12e97e72af Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 19 May 2022 16:08:35 +0100 Subject: [PATCH 11/34] use warehouse adapters instead of custom --- Cargo.lock | 381 +++++++++++++++++++++++++++++++++--- Cargo.toml | 104 +++++++++- runtime/basilisk/Cargo.toml | 2 + runtime/basilisk/src/lib.rs | 6 + runtime/basilisk/src/xcm.rs | 286 +-------------------------- 5 files changed, 456 insertions(+), 323 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82aecb8655d..3525f06354d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,6 +518,7 @@ dependencies = [ "getrandom 0.2.6", "hash-db", "hex-literal", + "hydradx-adapters", "hydradx-traits", "log", "memory-db 0.27.0", @@ -608,7 +609,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "beefy-primitives", "fnv", @@ -637,7 +638,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "beefy-gadget", "beefy-primitives", @@ -660,12 +661,12 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "parity-scale-codec", "scale-info", @@ -3204,10 +3205,26 @@ dependencies = [ "primitive-types 0.8.0", ] +[[package]] +name = "hydradx-adapters" +version = "0.1.0" +source = "git+https://github.com/galacticcouncil/warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +dependencies = [ + "frame-support", + "hydradx-traits", + "log", + "pallet-transaction-multi-payment", + "parity-scale-codec", + "sp-runtime", + "sp-std", + "xcm", + "xcm-executor", +] + [[package]] name = "hydradx-traits" version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?rev=e428fd81f84781c4508df72f095e7bed6bb58ea1#e428fd81f84781c4508df72f095e7bed6bb58ea1" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" dependencies = [ "frame-support", "parity-scale-codec", @@ -5190,7 +5207,7 @@ dependencies = [ "frame-support", "frame-system", "orml-traits", - "orml-utilities 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=aac79b3b31953381669a2ffa9b3e9bfe48e87f38)", + "orml-utilities", "parity-scale-codec", "scale-info", "serde", @@ -5222,7 +5239,7 @@ dependencies = [ "frame-support", "impl-trait-for-tuples", "num-traits", - "orml-utilities 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=aac79b3b31953381669a2ffa9b3e9bfe48e87f38)", + "orml-utilities", "parity-scale-codec", "scale-info", "serde", @@ -5247,19 +5264,6 @@ dependencies = [ "xcm", ] -[[package]] -name = "orml-utilities" -version = "0.4.1-dev" -source = "git+https://github.com/open-web3-stack/open-runtime-module-library?rev=63b32194e7b9aff6a6350d2d4434525de4eec7c1#63b32194e7b9aff6a6350d2d4434525de4eec7c1" -dependencies = [ - "frame-support", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "orml-utilities" version = "0.4.1-dev" @@ -5355,7 +5359,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?rev=e428fd81f84781c4508df72f095e7bed6bb58ea1#e428fd81f84781c4508df72f095e7bed6bb58ea1" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" dependencies = [ "frame-benchmarking", "frame-support", @@ -5448,7 +5452,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5483,7 +5487,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "beefy-primitives", "frame-support", @@ -5499,7 +5503,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -5970,7 +5974,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "orml-utilities 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=63b32194e7b9aff6a6350d2d4434525de4eec7c1)", + "orml-utilities", "pallet-balances", "pallet-nft", "pallet-uniques", @@ -6074,7 +6078,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "orml-utilities 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=aac79b3b31953381669a2ffa9b3e9bfe48e87f38)", + "orml-utilities", "pallet-balances", "pallet-uniques", "parity-scale-codec", @@ -6144,7 +6148,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22d40c761a985482f93bbbea5ba4199bdba74f8e" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" dependencies = [ "frame-benchmarking", "frame-support", @@ -6160,7 +6164,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?rev=e428fd81f84781c4508df72f095e7bed6bb58ea1#e428fd81f84781c4508df72f095e7bed6bb58ea1" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6205,7 +6209,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?rev=e428fd81f84781c4508df72f095e7bed6bb58ea1#e428fd81f84781c4508df72f095e7bed6bb58ea1" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6381,7 +6385,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" version = "7.0.2" -source = "git+https://github.com/galacticcouncil//warehouse?rev=e428fd81f84781c4508df72f095e7bed6bb58ea1#e428fd81f84781c4508df72f095e7bed6bb58ea1" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" dependencies = [ "frame-support", "frame-system", @@ -6551,7 +6555,7 @@ dependencies = [ "hydradx-traits", "orml-tokens", "orml-traits", - "orml-utilities 0.4.1-dev (git+https://github.com/open-web3-stack/open-runtime-module-library?rev=aac79b3b31953381669a2ffa9b3e9bfe48e87f38)", + "orml-utilities", "pallet-asset-registry", "parity-scale-codec", "primitive-types 0.8.0", @@ -12732,3 +12736,318 @@ dependencies = [ "cc", "libc", ] + +[[patch.unused]] +name = "chain-spec-builder" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "frame-support-test" +version = "3.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "frame-support-test-compile-pass" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "frame-support-test-pallet" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "generate-bags" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-bench" +version = "0.9.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-cli" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-executor" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-inspect" +version = "0.9.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-rpc" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-runtime" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-runtime-generate-bags" +version = "3.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-template" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-template-runtime" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "node-testing" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-asset-tx-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-assets" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-atomic-swap" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-bags-list-fuzzer" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-bags-list-remote-tests" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-child-bounties" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-contracts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-contracts-primitives" +version = "5.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-contracts-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-contracts-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-contracts-rpc-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-conviction-voting" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-example-basic" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-example-offchain-worker" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-example-parallel" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-lottery" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-node-authorization" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-randomness-collective-flip" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-referenda" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-scored-pool" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-template" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "pallet-transaction-storage" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sc-consensus-manual-seal" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sc-consensus-pow" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sc-network-test" +version = "0.8.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sc-runtime-test" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sc-service-test" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-api-test" +version = "2.0.1" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-application-crypto-test" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-arithmetic-fuzzer" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-consensus-pow" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-npos-elections-fuzzer" +version = "2.0.0-alpha.5" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-runtime-interface-test" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-runtime-interface-test-wasm" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-runtime-interface-test-wasm-deprecated" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-sandbox" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "sp-test-primitives" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "subkey" +version = "2.0.1" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-frame-cli" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-frame-rpc-support" +version = "3.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-client" +version = "2.0.1" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-runtime" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-runtime-client" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-runtime-transaction-pool" +version = "2.0.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-utils" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-utils-derive" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" + +[[patch.unused]] +name = "substrate-test-utils-test-crate" +version = "0.1.0" +source = "git+https://github.com/paritytech//substrate?rev=22d40c761a985482f93bbbea5ba4199bdba74f8e#22d40c761a985482f93bbbea5ba4199bdba74f8e" diff --git a/Cargo.toml b/Cargo.toml index 0e1c704bba0..40189cf75de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } @@ -150,6 +150,94 @@ substrate-frame-rpc-system = { git = "https://github.com/paritytech//substrate", substrate-prometheus-endpoint = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } substrate-wasm-builder = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } try-runtime-cli = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-template = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-core-hashing = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-panic-handler = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-api-proc-macro = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-core-hashing-proc-macro = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-version-proc-macro = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-test-primitives = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-runtime-client = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-allocator = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-executor-wasmi = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-runtime-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-sandbox = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-tasks = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-tracing-proc-macro = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-database = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-runtime = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-npos-elections-solution-type = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-utils = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-utils-derive = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-chain-spec-derive = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +fork-tree = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-peerset = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-state-db = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-runtime-transaction-pool = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-transaction-storage-proof = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-bags-list = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-client = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-runtime-interface-test-wasm = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-template-runtime = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-randomness-collective-flip = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-template = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-proposer-metrics = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-network-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-bench = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-primitives = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-runtime = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-asset-tx-payment = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-assets = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-child-bounties = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-contracts = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-contracts-primitives = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-contracts-proc-macro = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-contracts-rpc-runtime-api = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-conviction-voting = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-preimage = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-lottery = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +frame-support-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +frame-support-test-pallet = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-referenda = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-transaction-storage = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-testing = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-executor = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-cli = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-inspect = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-rpc = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-contracts-rpc = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-service-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-frame-cli = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +chain-spec-builder = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +subkey = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +beefy-gadget = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +beefy-primitives = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +beefy-gadget-rpc = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-consensus-manual-seal = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sc-consensus-pow = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-consensus-pow = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-atomic-swap = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-bags-list-fuzzer = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-bags-list-remote-tests = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-beefy = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-beefy-mmr = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +beefy-merkle-tree = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-example-basic = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-example-offchain-worker = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-example-parallel = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-node-authorization = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +pallet-scored-pool = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +frame-support-test-compile-pass = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-api-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-application-crypto-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-arithmetic-fuzzer = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-npos-elections-fuzzer = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-runtime-interface-test = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +sp-runtime-interface-test-wasm-deprecated = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-test-utils-test-crate = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +substrate-frame-rpc-support = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +generate-bags = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } +node-runtime-generate-bags = { git = "https://github.com/paritytech//substrate", rev = "22d40c761a985482f93bbbea5ba4199bdba74f8e" } [patch."https://github.com/paritytech/polkadot"] kusama-runtime = { git = "https://github.com/paritytech//polkadot", rev = "de0ecd4760b146ecf33f5e867d707d789e21e060" } @@ -185,7 +273,7 @@ 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" } @@ -193,13 +281,13 @@ cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech// 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" } [patch."https://github.com/galacticcouncil/warehouse"] -pallet-price-oracle = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} -pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} -pallet-asset-registry= { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} -hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader"} +pallet-price-oracle = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } +pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } +hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index 0d6b2b6261f..ec40c9ec185 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -49,6 +49,7 @@ pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate", b pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } # Warehouse dependencies +hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false } pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", branch = "apopiak/weight-trader", default-features = false} @@ -204,6 +205,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", diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index d338d312dfa..f203f69c824 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -178,6 +178,12 @@ impl WeightToFeePolynomial for WeightToFee { } } +impl PriceOracle for MultiTransactionPayment { + fn price(currency: AssetId) -> Option { + MultiTransactionPayment::currency_price(currency) + } +} + // Relay chain Block number provider. // Reason why the implementation is different for benchmarks is that it is not possible // to set or change the block number in a benchmark using parachain system pallet. diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 7ab2f2852d9..e9d1e1f13a8 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -3,6 +3,7 @@ use super::{AssetId, *}; use codec::{Decode, Encode}; use cumulus_primitives_core::ParaId; use frame_support::traits::{Everything, Nothing}; +use hydradx_adapters::MultiCurrencyAdapter; pub use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}; use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; @@ -17,7 +18,6 @@ use xcm_builder::{ SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; -use xcm_executor::traits::WeightTrader; use xcm_executor::{Assets, Config, XcmExecutor}; pub type LocalOriginToLocation = SignedToAccountId32; @@ -83,108 +83,6 @@ impl WeightTrader for TradePassthrough { } } -/// Very simple price oracle trait. -/// TODO: Move to correct location and properly define the price oracle interface. -pub trait PriceOracle { - fn price(currency: AssetId) -> Option; -} - -impl PriceOracle for MultiTransactionPayment { - fn price(currency: AssetId) -> Option { - MultiTransactionPayment::currency_price(currency) - } -} - -/// Weight trader which uses `WeightToFee` in combination with a `PriceOracle` to set the right -/// price for weight. Keeps track of the assets used used to pay for weight and can refund them one -/// by one (interface only allows returning one asset per refund). -pub struct MultiCurrencyTrader< - WeightToFee: WeightToFeePolynomial, - AcceptedCurrencyPrices: PriceOracle, - ConvertCurrency: Convert>, -> { - weight: Weight, - paid_assets: BTreeMap<(MultiLocation, Price), u128>, - _phantom: PhantomData<(WeightToFee, AcceptedCurrencyPrices, ConvertCurrency)>, -} - -impl< - WeightToFee: WeightToFeePolynomial, - AcceptedCurrencyPrices: PriceOracle, - ConvertCurrency: Convert>, - > - MultiCurrencyTrader -{ - /// Get the asset id of the first asset in `payment` and try to determine its price via the - /// price oracle. - fn get_asset_and_price(&mut self, payment: &Assets) -> Option<(MultiLocation, Price)> { - if let Some(asset) = payment.fungible_assets_iter().next() { - // TODO: consider optimizing out the clone - ConvertCurrency::convert(asset.clone()) - .and_then(|currency| { - AcceptedCurrencyPrices::price(currency) - }).and_then(|price| match asset.id.clone() { - Concrete(location) => Some((location, price)), - _ => None, - }) - } else { - None - } - } -} - -impl< - WeightToFee: WeightToFeePolynomial, - AcceptedCurrencyPrices: PriceOracle, - ConvertCurrency: Convert>, - > WeightTrader for MultiCurrencyTrader -{ - fn new() -> Self { - Self { weight: 0, paid_assets: Default::default(), _phantom: PhantomData } - } - - /// Will try to buy weight with the first asset in `payment`. - /// The fee is determined by `WeightToFee` in combination with the determined price. - fn buy_weight(&mut self, weight: Weight, payment: Assets) -> Result { - log::trace!(target: "xcm::weight", "MultiCurrencyTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment); - let (asset_loc, price) = self.get_asset_and_price(&payment).ok_or(XcmError::AssetNotFound)?; - let fee = WeightToFee::calc(&weight); - let converted_fee = price.checked_mul_int(fee).ok_or(XcmError::Overflow)?; - let amount: u128 = converted_fee.try_into().map_err(|_| XcmError::Overflow)?; - let required = (Concrete(asset_loc.clone()), amount).into(); - let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?; - self.weight = self.weight.saturating_add(weight); - let key = (asset_loc, price); - match self.paid_assets.get_mut(&key) { - Some(v) => v.saturating_accrue(amount), - None => { self.paid_assets.insert(key, amount); }, - } - Ok(unused) - } - - /// Will refund up to `weight` from the first asset tracked by the trader. - fn refund_weight(&mut self, weight: Weight) -> Option { - log::trace!(target: "xcm::weight", "MultiCurrencyTrader::refund_weight weight: {:?}, paid_assets: {:?}", weight, self.paid_assets); - let weight = weight.min(self.weight); - self.weight -= weight; // Will not underflow because of `min()` above. - let fee = WeightToFee::calc(&weight); - if let Some(((asset_loc, price), amount)) = self.paid_assets.iter_mut().next() { - let converted_fee: u128 = price.saturating_mul_int(fee).saturated_into(); - let refund = converted_fee.min(*amount); - *amount -= refund; // Will not underflow because of `min()` above. - - let refund_asset = asset_loc.clone(); - if amount.is_zero() { - let key = (asset_loc.clone(), price.clone()); - self.paid_assets.remove(&key); - } - Some((Concrete(refund_asset), refund).into()) - } else { - None - } - } -} - pub struct XcmConfig; impl Config for XcmConfig { type Call = Call; @@ -201,7 +99,7 @@ impl Config for XcmConfig { type Weigher = FixedWeightBounds; // 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. - type Trader = MultiCurrencyTrader; + type Trader = MultiCurrencyTrader; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; @@ -385,183 +283,3 @@ pub type LocalAssetTransactor = MultiCurrencyAdapter< CurrencyIdConvert, (), >; - -#[cfg(test)] -mod tests { - use super::*; - use frame_support::weights::IdentityFee; - use sp_runtime::traits::One; - - const TEST_ASSET_ID: AssetId = 123; - const CHEAP_ASSET_ID: AssetId = 420; - const OVERFLOW_ASSET_ID: AssetId = 1_000; - - struct MockOracle; - impl PriceOracle for MockOracle { - fn price(currency: AssetId) -> Option { - match currency { - CORE_ASSET_ID => Some(Price::one()), - TEST_ASSET_ID => Some(Price::from_float(0.5)), - CHEAP_ASSET_ID => Some(Price::saturating_from_integer(4)), - OVERFLOW_ASSET_ID => Some(Price::saturating_from_integer(2_147_483_647)), - _ => None, - } - } - } - - struct MockConvert; - impl Convert> for MockConvert { - fn convert(id: AssetId) -> Option { - match id { - CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID | OVERFLOW_ASSET_ID => Some(MultiLocation::new( - 0, - X1(GeneralKey(id.encode())), - )), - _ => None - } - } - } - - impl Convert> for MockConvert { - fn convert(location: MultiLocation) -> Option { - match location { - MultiLocation { - parents: 0, - interior: X1(GeneralKey(key)), - } => { - if let Ok(currency_id) = AssetId::decode(&mut &key[..]) { - // we currently have only one native asset - match currency_id { - CORE_ASSET_ID | TEST_ASSET_ID | CHEAP_ASSET_ID | OVERFLOW_ASSET_ID => Some(currency_id), - _ => None, - } - } else { - None - } - } - _ => None, - } - } - } - - impl Convert> for MockConvert { - fn convert(asset: MultiAsset) -> Option { - if let MultiAsset { - id: Concrete(location), .. - } = asset - { - Self::convert(location) - } else { - None - } - } - } - - type Trader = MultiCurrencyTrader, MockOracle, MockConvert>; - - #[test] - fn can_buy_weight() { - let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); - let test_id = MockConvert::convert(TEST_ASSET_ID).unwrap(); - let cheap_id = MockConvert::convert(CHEAP_ASSET_ID).unwrap(); - - let mut trader = Trader::new(); - - let core_payment: MultiAsset = (Concrete(core_id), 1_000_000).into(); - let res = dbg!(trader.buy_weight(1_000_000, core_payment.into())); - assert!(res.expect("buy_weight should succeed because payment == weight").is_empty()); - - let test_payment: MultiAsset = (Concrete(test_id), 500_000).into(); - let res = dbg!(trader.buy_weight(1_000_000, test_payment.into())); - assert!(res.expect("buy_weight should succeed because payment == 0.5 * weight").is_empty()); - - let cheap_payment: MultiAsset = (Concrete(cheap_id), 4_000_000).into(); - let res = dbg!(trader.buy_weight(1_000_000, cheap_payment.into())); - assert!(res.expect("buy_weight should succeed because payment == 4 * weight").is_empty()); - } - - #[test] - fn cannot_buy_with_too_few_tokens() { - let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); - - let mut trader = Trader::new(); - - let payment: MultiAsset = (Concrete(core_id), 69).into(); - let res = dbg!(trader.buy_weight(1_000_000, payment.into())); - assert_eq!(res, Err(XcmError::TooExpensive)); - } - - #[test] - fn cannot_buy_with_unknown_token() { - let unknown_token = GeneralKey(9876u32.encode()); - - let mut trader = Trader::new(); - let payment: MultiAsset = (Concrete(unknown_token.into()), 1_000_000).into(); - let res = dbg!(trader.buy_weight(1_000_000, payment.into())); - assert_eq!(res, Err(XcmError::AssetNotFound)); - } - - #[test] - fn overflow_errors() { - // Create a mock fee calculator that always returns `max_value`. - pub struct MaxFee; - impl WeightToFeePolynomial for MaxFee - { - type Balance = Balance; - - fn polynomial() -> WeightToFeeCoefficients { - smallvec!(WeightToFeeCoefficient { - coeff_integer: Balance::max_value(), - coeff_frac: Perbill::zero(), - negative: false, - degree: 1, - }) - } - } - type Trader = MultiCurrencyTrader; - - let overflow_id = MockConvert::convert(OVERFLOW_ASSET_ID).unwrap(); - - let mut trader = Trader::new(); - - let amount = 1_000; - let payment: MultiAsset = (Concrete(overflow_id), amount).into(); - let weight = 1_000; - let res = dbg!(trader.buy_weight(weight, payment.into())); - assert_eq!(res, Err(XcmError::Overflow)); - } - - #[test] - fn refunds_first_asset_completely() { - let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); - - let mut trader = Trader::new(); - - let weight = 1_000_000; - let tokens = 1_000_000; - let core_payment: MultiAsset = (Concrete(core_id), tokens).into(); - let res = dbg!(trader.buy_weight(weight, core_payment.clone().into())); - assert!(res.expect("buy_weight should succeed because payment == weight").is_empty()); - assert_eq!(trader.refund_weight(weight), Some(core_payment.into())); - } - - #[test] - fn needs_multiple_refunds_for_multiple_currencies() { - let core_id = MockConvert::convert(CORE_ASSET_ID).unwrap(); - let test_id = MockConvert::convert(TEST_ASSET_ID).unwrap(); - - let mut trader = Trader::new(); - - let weight = 1_000_000; - let core_payment: MultiAsset = (Concrete(core_id), 1_000_000).into(); - let res = dbg!(trader.buy_weight(weight, core_payment.clone().into())); - assert!(res.expect("buy_weight should succeed because payment == weight").is_empty()); - - let test_payment: MultiAsset = (Concrete(test_id), 500_000).into(); - let res = dbg!(trader.buy_weight(weight, test_payment.clone().into())); - assert!(res.expect("buy_weight should succeed because payment == 0.5 * weight").is_empty()); - - assert_eq!(trader.refund_weight(weight), Some(core_payment.into())); - assert_eq!(trader.refund_weight(weight), Some(test_payment.into())); - } -} From c0e072a0e7ac831ff4a24592f2eeb486953e13d6 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 19 May 2022 16:09:01 +0100 Subject: [PATCH 12/34] use same version of orml-utilities pallet --- pallets/marketplace/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/marketplace/Cargo.toml b/pallets/marketplace/Cargo.toml index 0ce59d73d3f..05184db9b23 100644 --- a/pallets/marketplace/Cargo.toml +++ b/pallets/marketplace/Cargo.toml @@ -17,7 +17,7 @@ scale-info = { version = "1.0", default-features = false, features = ["derive"] frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false, optional = true } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } -orml-utilities = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "63b32194e7b9aff6a6350d2d4434525de4eec7c1", default-features = false } +orml-utilities = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } serde = { version = "1.0.111", optional = true, features = ["derive"] } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } From 83dbf35855b8440eaa02faf61ef6e05ad848b4fb Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 19 May 2022 16:39:53 +0100 Subject: [PATCH 13/34] update warehouse crates in Cargo.lock --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3525f06354d..2cdf290a6b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3208,7 +3208,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +source = "git+https://github.com/galacticcouncil/warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" dependencies = [ "frame-support", "hydradx-traits", @@ -3224,7 +3224,7 @@ dependencies = [ [[package]] name = "hydradx-traits" version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" dependencies = [ "frame-support", "parity-scale-codec", @@ -5359,7 +5359,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" dependencies = [ "frame-benchmarking", "frame-support", @@ -6164,7 +6164,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" dependencies = [ "frame-benchmarking", "frame-support", @@ -6209,7 +6209,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6385,7 +6385,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" version = "7.0.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f6683eb2e24171f75b88e57eca3da793c9fa34fe" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" dependencies = [ "frame-support", "frame-system", From 077259b2806de2ca74eaf5f8657d4d2578f94830 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 19 May 2022 17:00:48 +0100 Subject: [PATCH 14/34] add adapters crate to overrides --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 40189cf75de..e28f33f3ffc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -291,3 +291,4 @@ pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse" pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } +hydradx-adapters = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } From 64617336b519c0e1b0f83d913969a6ad398aab7a Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 19 May 2022 17:01:04 +0100 Subject: [PATCH 15/34] update warehouse crates in Cargo.lock --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2cdf290a6b3..da06d47c1fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3208,7 +3208,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil/warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" dependencies = [ "frame-support", "hydradx-traits", @@ -3224,7 +3224,7 @@ dependencies = [ [[package]] name = "hydradx-traits" version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" dependencies = [ "frame-support", "parity-scale-codec", @@ -5359,7 +5359,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6164,7 +6164,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6209,7 +6209,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6385,7 +6385,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" version = "7.0.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#f2237cd20d071922925b8d23a9dfb8b277f2c396" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" dependencies = [ "frame-support", "frame-system", @@ -11663,7 +11663,7 @@ dependencies = [ "chrono", "lazy_static", "matchers", - "parking_lot 0.11.2", + "parking_lot 0.10.2", "regex", "serde", "serde_json", From 551dd66f2c00880594481b51a5aa7aca03fdcfbf Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 19 May 2022 17:01:15 +0100 Subject: [PATCH 16/34] fix compile errors --- runtime/basilisk/src/lib.rs | 5 +++-- runtime/basilisk/src/xcm.rs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index f203f69c824..0f63349c473 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -146,7 +146,7 @@ impl Contains for BaseFilter { use common_runtime::adapter::OrmlTokensAdapter; use primitives::{ nft::{ClassType, NftPermissions}, - ClassId, InstanceId, + ClassId, InstanceId, Price, }; use smallvec::smallvec; use sp_runtime::traits::BlockNumberProvider; @@ -178,7 +178,8 @@ impl WeightToFeePolynomial for WeightToFee { } } -impl PriceOracle for MultiTransactionPayment { +pub struct MtpOracle; +impl hydradx_traits::PriceOracle for MtpOracle { fn price(currency: AssetId) -> Option { MultiTransactionPayment::currency_price(currency) } diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index e9d1e1f13a8..97060feed96 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -3,7 +3,7 @@ use super::{AssetId, *}; use codec::{Decode, Encode}; use cumulus_primitives_core::ParaId; use frame_support::traits::{Everything, Nothing}; -use hydradx_adapters::MultiCurrencyAdapter; +use hydradx_adapters::MultiCurrencyTrader; pub use orml_xcm_support::{IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset}; use pallet_xcm::XcmPassthrough; use polkadot_parachain::primitives::Sibling; @@ -18,7 +18,7 @@ use xcm_builder::{ SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; -use xcm_executor::{Assets, Config, XcmExecutor}; +use xcm_executor::{Assets, Config, traits::WeightTrader, XcmExecutor}; pub type LocalOriginToLocation = SignedToAccountId32; @@ -99,7 +99,7 @@ impl Config for XcmConfig { type Weigher = FixedWeightBounds; // 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. - type Trader = MultiCurrencyTrader; + type Trader = MultiCurrencyTrader; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; From 5c4d259f0dfe7d4dcd6eb0fa4095283031c8b1e5 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 26 May 2022 00:49:43 +0100 Subject: [PATCH 17/34] update MultiCurrencyTrader to include TakeRevenue type --- Cargo.lock | 15 ++++++++------- runtime/basilisk/src/xcm.rs | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da06d47c1fb..074d04cdde8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3208,7 +3208,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" dependencies = [ "frame-support", "hydradx-traits", @@ -3218,13 +3218,14 @@ dependencies = [ "sp-runtime", "sp-std", "xcm", + "xcm-builder", "xcm-executor", ] [[package]] name = "hydradx-traits" version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" dependencies = [ "frame-support", "parity-scale-codec", @@ -5359,7 +5360,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" dependencies = [ "frame-benchmarking", "frame-support", @@ -6164,7 +6165,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" dependencies = [ "frame-benchmarking", "frame-support", @@ -6209,7 +6210,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6385,7 +6386,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" version = "7.0.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#170ae16551e2f295868b19d0d26f961a215fd73d" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" dependencies = [ "frame-support", "frame-system", @@ -11663,7 +11664,7 @@ dependencies = [ "chrono", "lazy_static", "matchers", - "parking_lot 0.10.2", + "parking_lot 0.11.2", "regex", "serde", "serde_json", diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 97060feed96..80f98c8eccb 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -98,8 +98,8 @@ impl Config for XcmConfig { type Barrier = Barrier; type Weigher = FixedWeightBounds; // 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. - type Trader = MultiCurrencyTrader; + // of accepted currencies of the transaction payment pallet. Burn fee revenue. + type Trader = MultiCurrencyTrader; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; From 58269a7f2f61361543b6286b559b7e785cfa4d8a Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 26 May 2022 13:42:56 +0100 Subject: [PATCH 18/34] use PriceOracle impl from warehouse --- Cargo.lock | 12 ++++++------ runtime/basilisk/src/lib.rs | 7 ------- runtime/basilisk/src/xcm.rs | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 074d04cdde8..40299f7257a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3208,7 +3208,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" dependencies = [ "frame-support", "hydradx-traits", @@ -3225,7 +3225,7 @@ dependencies = [ [[package]] name = "hydradx-traits" version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" dependencies = [ "frame-support", "parity-scale-codec", @@ -5360,7 +5360,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" dependencies = [ "frame-benchmarking", "frame-support", @@ -6165,7 +6165,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" dependencies = [ "frame-benchmarking", "frame-support", @@ -6210,7 +6210,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6386,7 +6386,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" version = "7.0.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ba0580be85256ea6513fb6f50bc6acae9ac65df4" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" dependencies = [ "frame-support", "frame-system", diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 0f63349c473..9736cbd467e 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -178,13 +178,6 @@ impl WeightToFeePolynomial for WeightToFee { } } -pub struct MtpOracle; -impl hydradx_traits::PriceOracle for MtpOracle { - fn price(currency: AssetId) -> Option { - MultiTransactionPayment::currency_price(currency) - } -} - // Relay chain Block number provider. // Reason why the implementation is different for benchmarks is that it is not possible // to set or change the block number in a benchmark using parachain system pallet. diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 80f98c8eccb..f108de21414 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -99,7 +99,7 @@ impl Config for XcmConfig { type Weigher = FixedWeightBounds; // 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. Burn fee revenue. - type Trader = MultiCurrencyTrader; + type Trader = MultiCurrencyTrader; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; From ea91993ae5421bfe2aabf309738c75589c942954 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:11:19 +0200 Subject: [PATCH 19/34] remove unused imports --- pallets/marketplace/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/marketplace/src/lib.rs b/pallets/marketplace/src/lib.rs index 2f111b32089..c0659ea518c 100644 --- a/pallets/marketplace/src/lib.rs +++ b/pallets/marketplace/src/lib.rs @@ -6,7 +6,7 @@ use frame_support::{ dispatch::DispatchResult, ensure, traits::{Currency, ExistenceRequirement, NamedReservableCurrency}, - transactional, BoundedVec, + transactional, }; use frame_system::{ensure_signed, RawOrigin}; use sp_runtime::{ From f0a5b6f779d21cdb99d8502908be7e5fea5972bd Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:12:01 +0200 Subject: [PATCH 20/34] transfer fees to FeeReceiver --- runtime/basilisk/src/lib.rs | 9 +++++++-- runtime/basilisk/src/xcm.rs | 26 ++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index d12fc35f2f4..6890fe4cf9f 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -76,7 +76,7 @@ use orml_currencies::BasicCurrencyAdapter; use common_runtime::locked_balance::MultiCurrencyLockedBalance; pub use common_runtime::*; -use pallet_transaction_multi_payment::MultiCurrencyAdapter; +use pallet_transaction_multi_payment::{DepositAll, TransferFees}; /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats @@ -334,13 +334,17 @@ pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = MultiCurrencyAdapter; + type OnChargeTransaction = TransferFees>; type TransactionByteFee = TransactionByteFee; type OperationalFeeMultiplier = (); type WeightToFee = WeightToFee; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } +parameter_types! { + pub FeeReceiver: AccountId = Treasury::account_id(); +} + impl pallet_transaction_multi_payment::Config for Runtime { type Event = Event; type AcceptedCurrencyOrigin = EnsureSuperMajorityTechCommitteeOrRoot; @@ -350,6 +354,7 @@ impl pallet_transaction_multi_payment::Config for Runtime { type WithdrawFeeForSetCurrency = MultiPaymentCurrencySetFee; type WeightToFee = WeightToFee; type NativeAssetId = NativeAssetId; + type FeeReceiver = FeeReceiver; } impl pallet_sudo::Config for Runtime { diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 0cb800dd820..8c62d0cc2aa 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -6,14 +6,17 @@ use frame_support::{ traits::{Everything, Nothing}, PalletId, }; -use hydradx_adapters::MultiCurrencyTrader; +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, Saturating, Zero}, FixedPointNumber, SaturatedConversion}; +use sp_runtime::{ + traits::{Convert, Saturating, Zero}, + FixedPointNumber, SaturatedConversion, +}; use sp_std::collections::btree_map::BTreeMap; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, @@ -21,7 +24,7 @@ use xcm_builder::{ SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, }; -use xcm_executor::{Assets, Config, traits::WeightTrader, XcmExecutor}; +use xcm_executor::{traits::WeightTrader, Assets, Config, XcmExecutor}; pub type LocalOriginToLocation = SignedToAccountId32; @@ -102,7 +105,22 @@ impl Config for XcmConfig { type Weigher = FixedWeightBounds; // 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. Burn fee revenue. - type Trader = MultiCurrencyTrader; + type Trader = MultiCurrencyTrader< + AssetId, + Balance, + WeightToFee, + MultiTransactionPayment, + CurrencyIdConvert, + ToFeeReceiver< + AccountId, + AssetId, + Balance, + Price, + CurrencyIdConvert, + DepositAll, + MultiTransactionPayment, + >, + >; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; From 0171c9f05815bd87a89221df9cae8eef7929fb3b Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:12:27 +0200 Subject: [PATCH 21/34] update warehouse crates in Cargo.lock --- Cargo.lock | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00129289062..b015316daae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3221,7 +3221,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" dependencies = [ "frame-support", "hydradx-traits", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "hydradx-traits" version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" dependencies = [ "frame-support", "parity-scale-codec", @@ -5373,7 +5373,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" dependencies = [ "frame-benchmarking", "frame-support", @@ -6179,7 +6179,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" dependencies = [ "frame-benchmarking", "frame-support", @@ -6224,7 +6224,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6399,12 +6399,13 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" -version = "7.0.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#b97c43f7347732ff62ee6aae26a347b20c895a24" +version = "7.1.0" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" dependencies = [ "frame-support", "frame-system", "hydradx-traits", + "itertools", "orml-traits", "pallet-transaction-payment", "parity-scale-codec", From 381b0b304e2147633f659f34a36a37d23c0c5970 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:35:47 +0200 Subject: [PATCH 22/34] remove fallback account in intregation tests --- integration-tests/src/kusama_test_net.rs | 4 +--- integration-tests/src/non_native_fee.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/kusama_test_net.rs b/integration-tests/src/kusama_test_net.rs index 8b3d46ccba5..0fd9afb4056 100644 --- a/integration-tests/src/kusama_test_net.rs +++ b/integration-tests/src/kusama_test_net.rs @@ -7,7 +7,6 @@ pub const ALICE: [u8; 32] = [4u8; 32]; pub const BOB: [u8; 32] = [5u8; 32]; pub const CHARLIE: [u8; 32] = [6u8; 32]; pub const DAVE: [u8; 32] = [7u8; 32]; -pub const FALLBACK: [u8; 32] = [99u8; 32]; pub const BSX: Balance = 1_000_000_000_000; @@ -195,7 +194,7 @@ pub fn basilisk_ext() -> sp_io::TestExternalities { >::assimilate_storage( ¶chain_info::GenesisConfig { - parachain_id: 2000.into(), + parachain_id: 2000u32.into(), }, &mut t, ) @@ -221,7 +220,6 @@ pub fn basilisk_ext() -> sp_io::TestExternalities { pallet_transaction_multi_payment::GenesisConfig:: { currencies: vec![(1, Price::from(1))], - fallback_account: Some(FALLBACK.into()), account_currencies: vec![], } .assimilate_storage(&mut t) diff --git a/integration-tests/src/non_native_fee.rs b/integration-tests/src/non_native_fee.rs index 87e1dca77ec..a53c3dc4fe5 100644 --- a/integration-tests/src/non_native_fee.rs +++ b/integration-tests/src/non_native_fee.rs @@ -116,7 +116,7 @@ fn non_native_fee_payment_works() { 1, 462_676_500_000, 265_222_898_276, - FALLBACK.into(), + basilisk_runtime::Treasury::account_id(), ) .into(), pallet_transaction_multi_payment::Event::CurrencySet(DAVE.into(), 1).into(), From fbd8fd953b5cd9acf58dbfe61bab4c17d5ce0661 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:36:03 +0200 Subject: [PATCH 23/34] check that fees end up in treasury in integration tests --- integration-tests/src/cross_chain_transfer.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/integration-tests/src/cross_chain_transfer.rs b/integration-tests/src/cross_chain_transfer.rs index 9444c4e93a7..0a62d853916 100644 --- a/integration-tests/src/cross_chain_transfer.rs +++ b/integration-tests/src/cross_chain_transfer.rs @@ -46,6 +46,10 @@ fn transfer_from_relay_chain() { basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), 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 + ); }); } @@ -131,6 +135,10 @@ fn transfer_from_hydra() { basilisk_runtime::Tokens::free_balance(1, &AccountId::from(BOB)), 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 + ); }); } #[test] From b8740ffad78d24ac5b2f30028adafcb994ca8bfe Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:44:11 +0200 Subject: [PATCH 24/34] use TransferFees in testing runtime --- runtime/testing-basilisk/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/testing-basilisk/src/lib.rs b/runtime/testing-basilisk/src/lib.rs index a294b1d82f5..2bff203c046 100644 --- a/runtime/testing-basilisk/src/lib.rs +++ b/runtime/testing-basilisk/src/lib.rs @@ -73,7 +73,7 @@ use pallet_xyk_rpc_runtime_api as xyk_rpc; use orml_currencies::BasicCurrencyAdapter; pub use common_runtime::*; -use pallet_transaction_multi_payment::MultiCurrencyAdapter; +use pallet_transaction_multi_payment::{DepositAll, TransferFees}; /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats @@ -288,7 +288,7 @@ pub type SlowAdjustingFeeUpdate = TargetedFeeAdjustment; impl pallet_transaction_payment::Config for Runtime { - type OnChargeTransaction = MultiCurrencyAdapter; + type OnChargeTransaction = TransferFees>; type TransactionByteFee = TransactionByteFee; type OperationalFeeMultiplier = (); type WeightToFee = WeightToFee; From 152129996ac438eee0f0247089d2844ce85f98ce Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:47:01 +0200 Subject: [PATCH 25/34] set treasury as FeeReceiver in testing runtime --- runtime/testing-basilisk/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/testing-basilisk/src/lib.rs b/runtime/testing-basilisk/src/lib.rs index 2bff203c046..5633d5feb27 100644 --- a/runtime/testing-basilisk/src/lib.rs +++ b/runtime/testing-basilisk/src/lib.rs @@ -295,6 +295,10 @@ impl pallet_transaction_payment::Config for Runtime { type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; } +parameter_types! { + pub TreasuryAccount: AccountId = Treasury::account_id(); +} + impl pallet_transaction_multi_payment::Config for Runtime { type Event = Event; type AcceptedCurrencyOrigin = EnsureSuperMajorityTechCommitteeOrRoot; @@ -304,6 +308,7 @@ impl pallet_transaction_multi_payment::Config for Runtime { type WithdrawFeeForSetCurrency = MultiPaymentCurrencySetFee; type WeightToFee = WeightToFee; type NativeAssetId = (); + type FeeReceiver = TreasuryAccount; } impl pallet_sudo::Config for Runtime { From 020e23c0aa1a65d656f1c43c62293f3b52c03768 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 12:50:32 +0200 Subject: [PATCH 26/34] add import for BoundedVec in marketplace tests --- pallets/marketplace/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/marketplace/src/tests.rs b/pallets/marketplace/src/tests.rs index 53f862b0ae6..181049d71a5 100644 --- a/pallets/marketplace/src/tests.rs +++ b/pallets/marketplace/src/tests.rs @@ -1,4 +1,4 @@ -use frame_support::{assert_noop, assert_ok}; +use frame_support::{assert_noop, assert_ok, BoundedVec}; use super::*; use mock::{Event, *}; From 8d4e68852668dd5a8df050a8e5688a78f0f03c0f Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 13:25:06 +0200 Subject: [PATCH 27/34] remove fallback account in more places --- node/src/chain_spec.rs | 2 -- node/src/testing_chain_spec.rs | 1 - runtime/basilisk/src/benchmarking/multi_payment.rs | 2 -- 3 files changed, 5 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 7d8217f27e3..c36333ed723 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -712,7 +712,6 @@ fn parachain_genesis( }, multi_transaction_payment: MultiTransactionPaymentConfig { currencies: vec![], - fallback_account: Some(tx_fee_payment_account), account_currencies: vec![], }, tokens: TokensConfig { balances: vec![] }, @@ -814,7 +813,6 @@ fn testnet_parachain_genesis( }, multi_transaction_payment: MultiTransactionPaymentConfig { currencies: accepted_assets, - fallback_account: Some(tx_fee_payment_account), account_currencies: vec![], }, tokens: TokensConfig { diff --git a/node/src/testing_chain_spec.rs b/node/src/testing_chain_spec.rs index f285610becb..b6f0ddb5ced 100644 --- a/node/src/testing_chain_spec.rs +++ b/node/src/testing_chain_spec.rs @@ -438,7 +438,6 @@ fn testnet_parachain_genesis( }, multi_transaction_payment: MultiTransactionPaymentConfig { currencies: accepted_assets, - fallback_account: Some(tx_fee_payment_account), account_currencies: vec![], }, tokens: TokensConfig { diff --git a/runtime/basilisk/src/benchmarking/multi_payment.rs b/runtime/basilisk/src/benchmarking/multi_payment.rs index a67da5fb686..6baeab6140c 100644 --- a/runtime/basilisk/src/benchmarking/multi_payment.rs +++ b/runtime/basilisk/src/benchmarking/multi_payment.rs @@ -62,8 +62,6 @@ runtime_benchmarks! { set_currency { let maker: AccountId = account("maker", 0, SEED); let caller: AccountId = account("caller", 0, SEED); - let fallback_account: AccountId = account("fallback_account", 1, SEED); - pallet_transaction_multi_payment::FallbackAccount::::put(fallback_account); let asset_id = register_asset(b"TST".to_vec(), 100u128).map_err(|_| BenchmarkError::Stop("Failed to register asset"))?; From 64de585ba9f8ac1a578e3aa2d5d74a999911f59a Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Sat, 28 May 2022 15:06:30 +0200 Subject: [PATCH 28/34] remove fallback accounts everywhere --- node/src/chain_spec.rs | 9 --------- node/src/testing_chain_spec.rs | 6 ------ runtime/basilisk/src/lib.rs | 4 ++-- runtime/basilisk/src/xcm.rs | 5 ++--- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index c36333ed723..a0d2698a5d1 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -150,7 +150,6 @@ pub fn kusama_staging_parachain_config() -> Result { true, PARA_ID.into(), //technical committee - hex!["6d6f646c70792f74727372790000000000000000000000000000000000000000"].into(), // TREASURY - Fallback for multi tx payment ) }, // Bootnodes @@ -227,7 +226,6 @@ pub fn testnet_parachain_config() -> Result { vec![hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into()], //technical committee vec![hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into()], - hex!["30035c21ba9eda780130f2029a80c3e962f56588bc04c36be95a225cb536fb55"].into(), // SAME AS ROOT vec![], vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)], vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))], @@ -314,7 +312,6 @@ pub fn parachain_development_config() -> Result { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Eve"), ], - get_account_id_from_seed::("Alice"), // SAME AS ROOT get_vesting_config_for_test(), vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)], vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))], @@ -381,7 +378,6 @@ pub fn rococo_parachain_config() -> Result { //technical committee vec![hex!["3418b257de81886bef265495f3609def9a083869f32ef5a03f7351956497d41a"].into()], // same as sudo vec![], - hex!["3418b257de81886bef265495f3609def9a083869f32ef5a03f7351956497d41a"].into(), // same as sudo vec![], vec![], vec![], @@ -459,7 +455,6 @@ pub fn karura_testnet_parachain_config() -> Result { //technical committee vec![hex!["0897746a8df7df1969bf5fdb4f048221109830994c8afa001e9454c525211404"].into()], // same as sudo vec![], - hex!["0897746a8df7df1969bf5fdb4f048221109830994c8afa001e9454c525211404"].into(), // same as sudo vec![], vec![], vec![], @@ -545,7 +540,6 @@ pub fn benchmarks_development_config() -> Result { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Eve"), ], - get_account_id_from_seed::("Alice"), // SAME AS ROOT get_vesting_config_for_test(), vec![], vec![], @@ -624,7 +618,6 @@ pub fn local_parachain_config() -> Result { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Eve"), ], - get_account_id_from_seed::("Alice"), // SAME AS ROOT get_vesting_config_for_test(), vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)], vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))], @@ -657,7 +650,6 @@ fn parachain_genesis( _endowed_accounts: Vec, _enable_println: bool, parachain_id: ParaId, - tx_fee_payment_account: AccountId, ) -> GenesisConfig { GenesisConfig { system: SystemConfig { @@ -761,7 +753,6 @@ fn testnet_parachain_genesis( parachain_id: ParaId, council_members: Vec, tech_committee_members: Vec, - tx_fee_payment_account: AccountId, vesting_list: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>, registered_assets: Vec<(Vec, Balance)>, // (Asset name, Existential deposit) accepted_assets: Vec<(AssetId, Price)>, // (Asset id, Fallback price) - asset which fee can be paid with diff --git a/node/src/testing_chain_spec.rs b/node/src/testing_chain_spec.rs index b6f0ddb5ced..61f7eaf0e95 100644 --- a/node/src/testing_chain_spec.rs +++ b/node/src/testing_chain_spec.rs @@ -129,7 +129,6 @@ pub fn parachain_development_config() -> Result { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Eve"), ], - get_account_id_from_seed::("Alice"), // SAME AS ROOT get_vesting_config_for_test(), vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)], vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))], @@ -208,7 +207,6 @@ pub fn local_parachain_config() -> Result { get_account_id_from_seed::("Bob"), get_account_id_from_seed::("Eve"), ], - get_account_id_from_seed::("Alice"), // SAME AS ROOT get_vesting_config_for_test(), vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)], vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))], @@ -272,9 +270,7 @@ pub fn k8s_testnet_parachain_config() -> Result { PARA_ID.into(), //technical committee vec![hex!["a62f1daf8e490a1c0514c7d9f3a700999100f2aeb1d67a2ca68b241d3d6b3547"].into()], - // TREASURY - Fallback for multi tx payment vec![], - hex!["a62f1daf8e490a1c0514c7d9f3a700999100f2aeb1d67a2ca68b241d3d6b3547"].into(), get_vesting_config_for_test(), vec![(b"KSM".to_vec(), 1_000u128), (b"KUSD".to_vec(), 1_000u128)], vec![(1, Price::from_float(0.0000212)), (2, Price::from_float(0.000806))], @@ -339,7 +335,6 @@ pub fn moonbase_parachain_config() -> Result { //technical committee vec![hex!["9eaea650948488ccc720491b8e40be7436359dc4213a6487ba758ed496f9e53f"].into()], // same as sudo vec![], - hex!["9eaea650948488ccc720491b8e40be7436359dc4213a6487ba758ed496f9e53f"].into(), // same as sudo vec![], vec![], vec![], @@ -386,7 +381,6 @@ fn testnet_parachain_genesis( parachain_id: ParaId, council_members: Vec, tech_committee_members: Vec, - tx_fee_payment_account: AccountId, vesting_list: Vec<(AccountId, BlockNumber, BlockNumber, u32, Balance)>, registered_assets: Vec<(Vec, Balance)>, // (Asset name, Existential deposit) accepted_assets: Vec<(AssetId, Price)>, // (Asset id, Fallback price) - asset which fee can be paid with diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 6890fe4cf9f..5502fc0bf43 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -342,7 +342,7 @@ impl pallet_transaction_payment::Config for Runtime { } parameter_types! { - pub FeeReceiver: AccountId = Treasury::account_id(); + pub TreasuryAccount: AccountId = Treasury::account_id(); } impl pallet_transaction_multi_payment::Config for Runtime { @@ -354,7 +354,7 @@ impl pallet_transaction_multi_payment::Config for Runtime { type WithdrawFeeForSetCurrency = MultiPaymentCurrencySetFee; type WeightToFee = WeightToFee; type NativeAssetId = NativeAssetId; - type FeeReceiver = FeeReceiver; + type FeeReceiver = TreasuryAccount; } impl pallet_sudo::Config for Runtime { diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 8c62d0cc2aa..bf6dcc006e2 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -14,10 +14,9 @@ use polkadot_xcm::latest::prelude::*; use polkadot_xcm::latest::Error; use primitives::Price; use sp_runtime::{ - traits::{Convert, Saturating, Zero}, - FixedPointNumber, SaturatedConversion, + traits::{Convert}, }; -use sp_std::collections::btree_map::BTreeMap; + use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, EnsureXcmOrigin, FixedWeightBounds, LocationInverter, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, From 2d3e4c7179d0a82d9ba1cc666ed68f3a0929ed43 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 14 Jun 2022 10:36:48 +0200 Subject: [PATCH 29/34] update Cargo.lock --- Cargo.lock | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5b78ca86d5..1218c8fee99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3209,7 +3209,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" dependencies = [ "frame-support", "hydradx-traits", @@ -3225,8 +3225,8 @@ dependencies = [ [[package]] name = "hydradx-traits" -version = "0.5.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" +version = "0.6.0" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" dependencies = [ "frame-support", "parity-scale-codec", @@ -5360,8 +5360,8 @@ dependencies = [ [[package]] name = "pallet-asset-registry" -version = "1.2.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" +version = "1.3.0" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" dependencies = [ "frame-benchmarking", "frame-support", @@ -6166,8 +6166,8 @@ dependencies = [ [[package]] name = "pallet-price-oracle" -version = "0.2.2" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" +version = "0.3.0" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" dependencies = [ "frame-benchmarking", "frame-support", @@ -6211,8 +6211,8 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" -version = "0.2.1" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" +version = "0.3.0" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6387,13 +6387,12 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" -version = "7.1.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#ce9027586f28410ae1e1df7e4316aaa28c59d192" +version = "8.0.0" +source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" dependencies = [ "frame-support", "frame-system", "hydradx-traits", - "itertools", "orml-traits", "pallet-transaction-payment", "parity-scale-codec", From 7147a57e7933a221492b1dcdd5da035dd54e660f Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 14 Jun 2022 14:26:24 +0200 Subject: [PATCH 30/34] update warehouse crates to merge commit and fix issues --- Cargo.lock | 12 ++++++------ Cargo.toml | 12 ++++++------ integration-tests/Cargo.toml | 8 ++++---- integration-tests/src/non_native_fee.rs | 4 +++- pallets/exchange/Cargo.toml | 4 ++-- pallets/exchange/benchmarking/Cargo.toml | 4 ++-- pallets/lbp/Cargo.toml | 2 +- pallets/liquidity-mining/benchmarking/Cargo.toml | 2 +- pallets/offchain-duster/Cargo.toml | 2 +- pallets/xyk/Cargo.toml | 4 ++-- runtime/basilisk/Cargo.toml | 12 ++++++------ runtime/basilisk/src/lib.rs | 2 +- runtime/basilisk/src/xcm.rs | 1 + runtime/common/Cargo.toml | 8 ++++---- runtime/testing-basilisk/Cargo.toml | 10 +++++----- 15 files changed, 45 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9adfc18f703..61e599b9b6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3197,7 +3197,7 @@ dependencies = [ [[package]] name = "hydradx-adapters" version = "0.1.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" +source = "git+https://github.com/galacticcouncil//warehouse?rev=7052eeab309742dccfe7e307c15fc4f780713553#7052eeab309742dccfe7e307c15fc4f780713553" dependencies = [ "frame-support", "hydradx-traits", @@ -3214,7 +3214,7 @@ dependencies = [ [[package]] name = "hydradx-traits" version = "0.6.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" +source = "git+https://github.com/galacticcouncil//warehouse?rev=7052eeab309742dccfe7e307c15fc4f780713553#7052eeab309742dccfe7e307c15fc4f780713553" dependencies = [ "frame-support", "parity-scale-codec", @@ -5349,7 +5349,7 @@ dependencies = [ [[package]] name = "pallet-asset-registry" version = "1.3.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" +source = "git+https://github.com/galacticcouncil//warehouse?rev=7052eeab309742dccfe7e307c15fc4f780713553#7052eeab309742dccfe7e307c15fc4f780713553" dependencies = [ "frame-benchmarking", "frame-support", @@ -6155,7 +6155,7 @@ dependencies = [ [[package]] name = "pallet-price-oracle" version = "0.3.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" +source = "git+https://github.com/galacticcouncil//warehouse?rev=7052eeab309742dccfe7e307c15fc4f780713553#7052eeab309742dccfe7e307c15fc4f780713553" dependencies = [ "frame-benchmarking", "frame-support", @@ -6200,7 +6200,7 @@ dependencies = [ [[package]] name = "pallet-relaychain-info" version = "0.3.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" +source = "git+https://github.com/galacticcouncil//warehouse?rev=7052eeab309742dccfe7e307c15fc4f780713553#7052eeab309742dccfe7e307c15fc4f780713553" dependencies = [ "cumulus-pallet-parachain-system", "cumulus-primitives-core", @@ -6376,7 +6376,7 @@ dependencies = [ [[package]] name = "pallet-transaction-multi-payment" version = "8.0.0" -source = "git+https://github.com/galacticcouncil//warehouse?branch=apopiak/weight-trader#41173c5b4fa87c9dd1c80026e593b4c5e63aa33f" +source = "git+https://github.com/galacticcouncil//warehouse?rev=7052eeab309742dccfe7e307c15fc4f780713553#7052eeab309742dccfe7e307c15fc4f780713553" dependencies = [ "frame-support", "frame-system", diff --git a/Cargo.toml b/Cargo.toml index e28f33f3ffc..4975c3f870c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -286,9 +286,9 @@ cumulus-relay-chain-interface = { git = "https://github.com/paritytech//cumulus" cumulus-relay-chain-local = { git = "https://github.com/paritytech//cumulus", rev = "76479e7fef3af7c8828a44647847b01afd5fefe5" } [patch."https://github.com/galacticcouncil/warehouse"] -pallet-price-oracle = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } -pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } -pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } -hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } -hydradx-adapters = { git = "https://github.com/galacticcouncil//warehouse", branch = "apopiak/weight-trader" } +pallet-price-oracle = { git = "https://github.com/galacticcouncil//warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553" } +pallet-relaychain-info = { git = "https://github.com/galacticcouncil//warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553" } +pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil//warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553" } +pallet-asset-registry = { git = "https://github.com/galacticcouncil//warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553" } +hydradx-traits = { git = "https://github.com/galacticcouncil//warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553" } +hydradx-adapters = { git = "https://github.com/galacticcouncil//warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553" } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 5e5412c2209..7d48fe1505d 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -20,8 +20,8 @@ trie-db = { version = "0.22.6", default-features = false } smallvec = "1.6.1" # local dependencies -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false} -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", 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} @@ -75,8 +75,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 = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", 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 } diff --git a/integration-tests/src/non_native_fee.rs b/integration-tests/src/non_native_fee.rs index abbd6ab7589..6217a164a42 100644 --- a/integration-tests/src/non_native_fee.rs +++ b/integration-tests/src/non_native_fee.rs @@ -34,6 +34,8 @@ pub fn basilisk_run_to_block(to: BlockNumber) { #[test] fn non_native_fee_payment_works() { + use pallet_transaction_multi_payment::TransactionMultiPaymentDataProvider; + TestNet::reset(); Basilisk::execute_with(|| { @@ -116,7 +118,7 @@ fn non_native_fee_payment_works() { asset_id: 1, native_fee_amount: 462_676_500_000, non_native_fee_amount: 265_222_898_276, - destination_account_id: FALLBACK.into(), + destination_account_id: basilisk_runtime::MultiTransactionPayment::get_fee_receiver(), } .into(), pallet_transaction_multi_payment::Event::CurrencySet { diff --git a/pallets/exchange/Cargo.toml b/pallets/exchange/Cargo.toml index 5387ac2ace2..05d79eebfa6 100644 --- a/pallets/exchange/Cargo.toml +++ b/pallets/exchange/Cargo.toml @@ -29,8 +29,8 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", 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 } hydra-dx-math = { git = "https://github.com/galacticcouncil/HydraDX-math", rev="1bafe7bb96864f5d29bab68061719c541ef06648", default-features = false } # Substrate dependencies diff --git a/pallets/exchange/benchmarking/Cargo.toml b/pallets/exchange/benchmarking/Cargo.toml index 91475052177..bca9994b1ea 100644 --- a/pallets/exchange/benchmarking/Cargo.toml +++ b/pallets/exchange/benchmarking/Cargo.toml @@ -29,8 +29,8 @@ orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", 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 } diff --git a/pallets/lbp/Cargo.toml b/pallets/lbp/Cargo.toml index 09b8bef2873..2aabe8dec3b 100644 --- a/pallets/lbp/Cargo.toml +++ b/pallets/lbp/Cargo.toml @@ -22,7 +22,7 @@ serde = { features = ["derive"], optional = true, version = "1.0.136" } # HydraDX dependencies hydra-dx-math = { git = "https://github.com/galacticcouncil/HydraDX-math", rev="1bafe7bb96864f5d29bab68061719c541ef06648", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } +hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false } ## Local dependencies primitives = { default-features = false, path = "../../primitives" } diff --git a/pallets/liquidity-mining/benchmarking/Cargo.toml b/pallets/liquidity-mining/benchmarking/Cargo.toml index 9cdc92ef519..1ecd342b60f 100644 --- a/pallets/liquidity-mining/benchmarking/Cargo.toml +++ b/pallets/liquidity-mining/benchmarking/Cargo.toml @@ -24,7 +24,7 @@ pallet-liquidity-mining = { path = "../../liquidity-mining", default-features = orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", 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="c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } primitives = { path = "../../../primitives", default-features = false } diff --git a/pallets/offchain-duster/Cargo.toml b/pallets/offchain-duster/Cargo.toml index 8f8be2fa49a..808765a95e1 100644 --- a/pallets/offchain-duster/Cargo.toml +++ b/pallets/offchain-duster/Cargo.toml @@ -26,7 +26,7 @@ primitives = { path = "../../primitives", default-features = false } pallet-duster = { path = "../duster", default-features = false } # Warehouse dependencies -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false } # ORML dependencies orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } diff --git a/pallets/xyk/Cargo.toml b/pallets/xyk/Cargo.toml index c52bef338e8..5d789564331 100644 --- a/pallets/xyk/Cargo.toml +++ b/pallets/xyk/Cargo.toml @@ -31,7 +31,7 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li orml-utilities = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "aac79b3b31953381669a2ffa9b3e9bfe48e87f38", default-features = false } # HydraDX dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", 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 } @@ -44,7 +44,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v [dev-dependencies] sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } +pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false } sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17" } [features] diff --git a/runtime/basilisk/Cargo.toml b/runtime/basilisk/Cargo.toml index c991221f2fb..d7d77d8a5c6 100644 --- a/runtime/basilisk/Cargo.toml +++ b/runtime/basilisk/Cargo.toml @@ -49,12 +49,12 @@ pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polka pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } # Warehouse dependencies -hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse",rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false} -pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } +hydradx-adapters = { git = "https://github.com/galacticcouncil/warehouse",rev = "7052eeab309742dccfe7e307c15fc4f780713553", default-features = false } +hydradx-traits = { 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-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 } # collator support pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.17", default-features = false } diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 1febf273297..02bfe7e9ff1 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -146,7 +146,7 @@ impl Contains for BaseFilter { use common_runtime::adapter::OrmlTokensAdapter; use primitives::{ nft::{ClassType, NftPermissions}, - ClassId, InstanceId, Price, + ClassId, InstanceId, }; use smallvec::smallvec; use sp_runtime::traits::BlockNumberProvider; diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index 90744aa529e..c06dbcd2be4 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -104,6 +104,7 @@ impl Config for XcmConfig { type Trader = MultiCurrencyTrader< AssetId, Balance, + Price, WeightToFee, MultiTransactionPayment, CurrencyIdConvert, diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 93ddbb9ab00..b5c226b0aa2 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -27,10 +27,10 @@ pallet-lbp = { path = "../../pallets/lbp", default-features = false } pallet-marketplace = { path = '../../pallets/marketplace', default-features = false } # Warehouse dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false} -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } +hydradx-traits = { 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-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 } # Substrate dependencies sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } diff --git a/runtime/testing-basilisk/Cargo.toml b/runtime/testing-basilisk/Cargo.toml index 795d3d057ca..906bea8cc1c 100644 --- a/runtime/testing-basilisk/Cargo.toml +++ b/runtime/testing-basilisk/Cargo.toml @@ -48,11 +48,11 @@ pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "polka pallet-identity = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.17", default-features = false } # Warehouse dependencies -hydradx-traits = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-price-oracle = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-relaychain-info = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } -pallet-transaction-multi-payment = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false} -pallet-asset-registry = { git = "https://github.com/galacticcouncil/warehouse", rev = "c73846ec093357fea1b35da5c56ecb37592d4896", default-features = false } +hydradx-traits = { 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-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 } # collator support pallet-collator-selection = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.17", default-features = false } From 4c7aa1a5c4d8b72f5293aeb94b621f8cb16b560e Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 14 Jun 2022 14:32:41 +0200 Subject: [PATCH 31/34] Adjust Weight Trader Comment --- runtime/basilisk/src/xcm.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/basilisk/src/xcm.rs b/runtime/basilisk/src/xcm.rs index c06dbcd2be4..626d8ab8763 100644 --- a/runtime/basilisk/src/xcm.rs +++ b/runtime/basilisk/src/xcm.rs @@ -100,7 +100,8 @@ impl Config for XcmConfig { type Barrier = Barrier; type Weigher = FixedWeightBounds; // 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. Burn fee revenue. + // of accepted currencies of the transaction payment pallet. Fees go to the same fee receiver as + // configured in `MultiTransactionPayment`. type Trader = MultiCurrencyTrader< AssetId, Balance, From 8a14a749688a844a955bb33fbef29bd1e5df8fc5 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 14 Jun 2022 16:26:28 +0200 Subject: [PATCH 32/34] bump spec_version --- runtime/basilisk/src/lib.rs | 2 +- runtime/testing-basilisk/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/basilisk/src/lib.rs b/runtime/basilisk/src/lib.rs index 02bfe7e9ff1..1e63390c357 100644 --- a/runtime/basilisk/src/lib.rs +++ b/runtime/basilisk/src/lib.rs @@ -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: 51, + spec_version: 52, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtime/testing-basilisk/src/lib.rs b/runtime/testing-basilisk/src/lib.rs index 30d6970d5c6..888a415378e 100644 --- a/runtime/testing-basilisk/src/lib.rs +++ b/runtime/testing-basilisk/src/lib.rs @@ -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: 51, + spec_version: 52, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From ae64c25f518f6e390851e5ca80c7daa4bb8c6bee Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 16 Jun 2022 14:37:07 +0200 Subject: [PATCH 33/34] use same trader in testing-basilisk --- Cargo.lock | 1 + runtime/testing-basilisk/Cargo.toml | 1 + runtime/testing-basilisk/src/xcm.rs | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e1403e4ca05..018886cd5e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11250,6 +11250,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", + "hydradx-adapters", "hydradx-traits", "orml-currencies", "orml-tokens", diff --git a/runtime/testing-basilisk/Cargo.toml b/runtime/testing-basilisk/Cargo.toml index c3dd7d11794..ce57f754f5f 100644 --- a/runtime/testing-basilisk/Cargo.toml +++ b/runtime/testing-basilisk/Cargo.toml @@ -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 } diff --git a/runtime/testing-basilisk/src/xcm.rs b/runtime/testing-basilisk/src/xcm.rs index e792b1033d4..44dbd41bcba 100644 --- a/runtime/testing-basilisk/src/xcm.rs +++ b/runtime/testing-basilisk/src/xcm.rs @@ -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; @@ -96,7 +97,26 @@ impl Config for XcmConfig { type Barrier = Barrier; type Weigher = FixedWeightBounds; - 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, + MultiTransactionPayment, + >, + >; type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; @@ -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> for CurrencyIdConvert { fn convert(id: AssetId) -> Option { From 7eac58ab2d651f6c4c29a8fa0636286d2d756714 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Thu, 16 Jun 2022 16:15:25 +0200 Subject: [PATCH 34/34] fix cross chain transfer test --- integration-tests/src/cross_chain_transfer.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/integration-tests/src/cross_chain_transfer.rs b/integration-tests/src/cross_chain_transfer.rs index a546a08f7d0..f945461b203 100644 --- a/integration-tests/src/cross_chain_transfer.rs +++ b/integration-tests/src/cross_chain_transfer.rs @@ -241,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!(