diff --git a/Makefile b/Makefile index 78df54e64..9357d769b 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,8 @@ LAUNCH_CONFIG_YAML := config.yml LAUNCH_CONFIG_JSON := config.json DOCKER_OVERRIDE_YAML := docker-compose.override.yml DOCKER_TAG := latest_evm -RELAY_DOCKER_TAG := v0.9.24 -CUMULUS_DOCKER_TAG := v0.9.24 +RELAY_DOCKER_TAG := v0.9.28 +CUMULUS_DOCKER_TAG := v0.9.28 .PHONY: init init: submodules diff --git a/config.yml b/config.yml index 420ed5f1d..9f558d99f 100644 --- a/config.yml +++ b/config.yml @@ -1,5 +1,5 @@ relaychain: - image: parallelfinance/polkadot:v0.9.24 + image: parallelfinance/polkadot:v0.9.28 chain: polkadot-local runtimeGenesisConfig: hrmp: @@ -50,9 +50,9 @@ parachains: nodes: - flags: - --alice - - image: parallelfinance/cumulus:v0.9.24 + - image: parallelfinance/cumulus:v0.9.28 chain: - base: statemint-dev + base: statemint-local collators: - alice sudo: dave diff --git a/pallets/traits/src/xcm.rs b/pallets/traits/src/xcm.rs index 438151dee..38b361b70 100644 --- a/pallets/traits/src/xcm.rs +++ b/pallets/traits/src/xcm.rs @@ -145,6 +145,11 @@ impl< // For cases (specially tests) where the asset is very cheap with respect // to the weight needed if amount.is_zero() { + log::trace!( + target: "xcm::buy_weight::payment", + "asset_type: {:?}", + id, + ); return Ok(payment); } @@ -165,6 +170,11 @@ impl< // In short, we only refund on the asset the trader first successfully was able // to pay for an execution + log::trace!( + target: "xcm::buy_weight::unused", + "asset_type: {:?}", + id, + ); let new_asset = match self.1.clone() { Some((prev_id, prev_amount, units_per_second)) => { if prev_id == id { @@ -181,7 +191,6 @@ impl< self.0 = self.0.saturating_add(weight); self.1 = Some(new_asset); }; - Ok(unused) } _ => Err(XcmError::TooExpensive), @@ -198,6 +207,11 @@ impl< prev_amount.saturating_sub(amount), units_per_second, )); + log::trace!( + target: "xcm::refund_weight", + "id: {:?}", + id, + ); Some(MultiAsset { fun: Fungibility::Fungible(amount), id: xcmAssetId::Concrete(id), @@ -319,27 +333,6 @@ impl From for CurrencyId { } } -// How to convert from CurrencyId to MultiLocation -pub struct CurrencyIdtoMultiLocation( - sp_std::marker::PhantomData<(LegacyAssetConverter, ForeignAssetConverter)>, -); -impl - sp_runtime::traits::Convert> - for CurrencyIdtoMultiLocation -where - LegacyAssetConverter: Convert>, - ForeignAssetConverter: xcm_executor::traits::Convert, -{ - fn convert(currency_id: CurrencyId) -> Option { - let mut multi_location = LegacyAssetConverter::convert(currency_id); - multi_location = match multi_location { - Some(_) => multi_location, - None => ForeignAssetConverter::reverse_ref(¤cy_id).ok(), - }; - multi_location - } -} - pub struct MultiCurrencyAdapter< MultiCurrency, Match, diff --git a/runtime/heiko/src/lib.rs b/runtime/heiko/src/lib.rs index 0b6cefe8b..872ada723 100644 --- a/runtime/heiko/src/lib.rs +++ b/runtime/heiko/src/lib.rs @@ -73,7 +73,10 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::{traits::JustTry, Config, XcmExecutor}; +use xcm_executor::{ + traits::{Convert as XcmConvert, JustTry}, + Config, XcmExecutor, +}; // A few exports that help ease life for downstream crates. // re-exports @@ -99,8 +102,7 @@ pub use pallet_streaming; use pallet_traits::{ xcm::{ - AccountIdToMultiLocation, AsAssetType, AssetType, CurrencyIdtoMultiLocation, - FirstAssetTrader, MultiCurrencyAdapter, + AccountIdToMultiLocation, AsAssetType, AssetType, FirstAssetTrader, MultiCurrencyAdapter, }, DecimalProvider, EmergencyCallFilter, ValidationDataProvider, }; @@ -365,6 +367,17 @@ parameter_types! { pub struct CurrencyIdConvert; impl Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { + let multi_location = + AsAssetType::::reverse_ref(&id).ok(); + log::trace!( + target: "xcm::convert", + "currency_id: {:?}, multi_location: {:?}", + id, + multi_location, + ); + if multi_location.is_some() { + return multi_location; + } match id { KSM => Some(MultiLocation::parent()), SKSM => Some(MultiLocation::new( @@ -462,6 +475,17 @@ impl Convert> for CurrencyIdConvert { impl Convert> for CurrencyIdConvert { fn convert(location: MultiLocation) -> Option { + let currency_id = + AsAssetType::::convert_ref(&location).ok(); + log::trace!( + target: "xcm::convert", + "multi_location: {:?}. currency_id: {:?}", + location, + currency_id, + ); + if currency_id.is_some() { + return currency_id; + } match location { MultiLocation { parents: 1, @@ -580,10 +604,7 @@ impl orml_xtokens::Config for Runtime { type Event = Event; type Balance = Balance; type CurrencyId = CurrencyId; - type CurrencyIdConvert = CurrencyIdtoMultiLocation< - CurrencyIdConvert, - AsAssetType, - >; + type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; type XcmExecutor = XcmExecutor; @@ -1367,6 +1388,9 @@ impl TakeRevenue for ToTreasury { } pub type Trader = ( + // we can try use asset-registry for statemine asset first,just comment following + // FixedRateOfFungible, + FirstAssetTrader, FixedRateOfFungible, FixedRateOfFungible, FixedRateOfFungible, @@ -1389,9 +1413,6 @@ pub type Trader = ( FixedRateOfFungible, // Calamari FixedRateOfFungible, - // we can try use asset-registry for statemine asset first,just comment following - // FixedRateOfFungible, - FirstAssetTrader, ); parameter_types! { diff --git a/runtime/kerria/src/constants.rs b/runtime/kerria/src/constants.rs index 697e9f66e..da1d3f24b 100644 --- a/runtime/kerria/src/constants.rs +++ b/runtime/kerria/src/constants.rs @@ -102,7 +102,7 @@ pub mod paras { pub const ACA_KEY: &[u8] = &[0, 0]; pub const AUSD_KEY: &[u8] = &[0, 1]; pub const LDOT_KEY: &[u8] = &[0, 3]; - pub const LCDOT_KEY: &[u8] = &[2, 13]; + pub const LCDOT_KEY: &[u8] = &[4, 13]; } pub mod moonbeam { diff --git a/runtime/kerria/src/lib.rs b/runtime/kerria/src/lib.rs index 8e2ac9e43..bf779a81b 100644 --- a/runtime/kerria/src/lib.rs +++ b/runtime/kerria/src/lib.rs @@ -77,7 +77,10 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::{traits::JustTry, Config, XcmExecutor}; +use xcm_executor::{ + traits::{Convert as XcmConvert, JustTry}, + Config, XcmExecutor, +}; // A few exports that help ease life for downstream crates. // re-exports @@ -103,8 +106,7 @@ pub use pallet_streaming; use pallet_traits::{ xcm::{ - AccountIdToMultiLocation, AsAssetType, AssetType, CurrencyIdtoMultiLocation, - FirstAssetTrader, MultiCurrencyAdapter, + AccountIdToMultiLocation, AsAssetType, AssetType, FirstAssetTrader, MultiCurrencyAdapter, }, DecimalProvider, EmergencyCallFilter, ValidationDataProvider, }; @@ -404,6 +406,17 @@ parameter_types! { pub struct CurrencyIdConvert; impl Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { + let multi_location = + AsAssetType::::reverse_ref(&id).ok(); + log::trace!( + target: "xcm::convert", + "currency_id: {:?}, multi_location: {:?}", + id, + multi_location, + ); + if multi_location.is_some() { + return multi_location; + } match id { DOT => Some(MultiLocation::parent()), SDOT => Some(MultiLocation::new( @@ -507,6 +520,17 @@ impl Convert> for CurrencyIdConvert { impl Convert> for CurrencyIdConvert { fn convert(location: MultiLocation) -> Option { + let currency_id = + AsAssetType::::convert_ref(&location).ok(); + log::trace!( + target: "xcm::convert", + "multi_location: {:?}. currency_id: {:?}", + location, + currency_id, + ); + if currency_id.is_some() { + return currency_id; + } match location { MultiLocation { parents: 1, @@ -607,10 +631,7 @@ impl orml_xtokens::Config for Runtime { type Event = Event; type Balance = Balance; type CurrencyId = CurrencyId; - type CurrencyIdConvert = CurrencyIdtoMultiLocation< - CurrencyIdConvert, - AsAssetType, - >; + type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; type XcmExecutor = XcmExecutor; @@ -1521,6 +1542,9 @@ impl TakeRevenue for ToTreasury { } pub type Trader = ( + // Foreign Assets registered in AssetRegistry + // TODO: replace all above except local reserved asset later + FirstAssetTrader, FixedRateOfFungible, FixedRateOfFungible, FixedRateOfFungible, @@ -1540,9 +1564,6 @@ pub type Trader = ( FixedRateOfFungible, // Equilibrium FixedRateOfFungible, - // Foreign Assets registered in AssetRegistry - // TODO: replace all above except local reserved asset later - FirstAssetTrader, ); // Min fee required when transferring non-reserve asset back to sibling chain diff --git a/runtime/parallel/src/constants.rs b/runtime/parallel/src/constants.rs index bdda1957a..ad64126cf 100644 --- a/runtime/parallel/src/constants.rs +++ b/runtime/parallel/src/constants.rs @@ -102,7 +102,7 @@ pub mod paras { pub const ACA_KEY: &[u8] = &[0, 0]; pub const AUSD_KEY: &[u8] = &[0, 1]; pub const LDOT_KEY: &[u8] = &[0, 3]; - pub const LCDOT_KEY: &[u8] = &[2, 13]; + pub const LCDOT_KEY: &[u8] = &[4, 13]; } pub mod moonbeam { diff --git a/runtime/parallel/src/lib.rs b/runtime/parallel/src/lib.rs index 01b3add52..f06192a8d 100644 --- a/runtime/parallel/src/lib.rs +++ b/runtime/parallel/src/lib.rs @@ -74,7 +74,10 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::{traits::JustTry, Config, XcmExecutor}; +use xcm_executor::{ + traits::{Convert as XcmConvert, JustTry}, + Config, XcmExecutor, +}; // A few exports that help ease life for downstream crates. // re-exports @@ -100,8 +103,7 @@ pub use pallet_streaming; use pallet_traits::{ xcm::{ - AccountIdToMultiLocation, AsAssetType, AssetType, CurrencyIdtoMultiLocation, - FirstAssetTrader, MultiCurrencyAdapter, + AccountIdToMultiLocation, AsAssetType, AssetType, FirstAssetTrader, MultiCurrencyAdapter, }, DecimalProvider, EmergencyCallFilter, ValidationDataProvider, }; @@ -370,6 +372,17 @@ parameter_types! { pub struct CurrencyIdConvert; impl Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { + let multi_location = + AsAssetType::::reverse_ref(&id).ok(); + log::trace!( + target: "xcm::convert", + "currency_id: {:?}, multi_location: {:?}", + id, + multi_location, + ); + if multi_location.is_some() { + return multi_location; + } match id { DOT => Some(MultiLocation::parent()), SDOT => Some(MultiLocation::new( @@ -472,6 +485,18 @@ impl Convert> for CurrencyIdConvert { impl Convert> for CurrencyIdConvert { fn convert(location: MultiLocation) -> Option { + let currency_id = + AsAssetType::::convert_ref(&location).ok(); + log::trace!( + target: "xcm::convert", + "multi_location: {:?}. currency_id: {:?}", + location, + currency_id, + ); + if currency_id.is_some() { + return currency_id; + } + match location { MultiLocation { parents: 1, @@ -600,10 +625,7 @@ impl orml_xtokens::Config for Runtime { type Event = Event; type Balance = Balance; type CurrencyId = CurrencyId; - type CurrencyIdConvert = CurrencyIdtoMultiLocation< - CurrencyIdConvert, - AsAssetType, - >; + type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; type XcmExecutor = XcmExecutor; @@ -1358,6 +1380,9 @@ impl TakeRevenue for ToTreasury { } pub type Trader = ( + // Foreign Assets registered in AssetRegistry + // TODO: replace all above except local reserved asset later + FirstAssetTrader, FixedRateOfFungible, FixedRateOfFungible, FixedRateOfFungible, @@ -1377,9 +1402,6 @@ pub type Trader = ( FixedRateOfFungible, // Equilibrium FixedRateOfFungible, - // Foreign Assets registered in AssetRegistry - // TODO: replace all above except local reserved asset later - FirstAssetTrader, ); parameter_types! { diff --git a/runtime/vanilla/src/lib.rs b/runtime/vanilla/src/lib.rs index a0f413600..13376bf15 100644 --- a/runtime/vanilla/src/lib.rs +++ b/runtime/vanilla/src/lib.rs @@ -74,7 +74,10 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeRevenue, TakeWeightCredit, }; -use xcm_executor::{traits::JustTry, Config, XcmExecutor}; +use xcm_executor::{ + traits::{Convert as XcmConvert, JustTry}, + Config, XcmExecutor, +}; // A few exports that help ease life for downstream crates. // re-exports @@ -103,8 +106,7 @@ pub use pallet_streaming; use pallet_evm::{FeeCalculator, Runner}; use pallet_traits::{ xcm::{ - AccountIdToMultiLocation, AsAssetType, AssetType, CurrencyIdtoMultiLocation, - FirstAssetTrader, MultiCurrencyAdapter, + AccountIdToMultiLocation, AsAssetType, AssetType, FirstAssetTrader, MultiCurrencyAdapter, }, DecimalProvider, EmergencyCallFilter, ValidationDataProvider, }; @@ -406,6 +408,17 @@ parameter_types! { pub struct CurrencyIdConvert; impl Convert> for CurrencyIdConvert { fn convert(id: CurrencyId) -> Option { + let multi_location = + AsAssetType::::reverse_ref(&id).ok(); + log::trace!( + target: "xcm::convert", + "currency_id: {:?}, multi_location: {:?}", + id, + multi_location, + ); + if multi_location.is_some() { + return multi_location; + } match id { KSM => Some(MultiLocation::parent()), SKSM => Some(MultiLocation::new( @@ -503,6 +516,17 @@ impl Convert> for CurrencyIdConvert { impl Convert> for CurrencyIdConvert { fn convert(location: MultiLocation) -> Option { + let currency_id = + AsAssetType::::convert_ref(&location).ok(); + log::trace!( + target: "xcm::convert", + "multi_location: {:?}. currency_id: {:?}", + location, + currency_id, + ); + if currency_id.is_some() { + return currency_id; + } match location { MultiLocation { parents: 1, @@ -609,10 +633,7 @@ impl orml_xtokens::Config for Runtime { type Event = Event; type Balance = Balance; type CurrencyId = CurrencyId; - type CurrencyIdConvert = CurrencyIdtoMultiLocation< - CurrencyIdConvert, - AsAssetType, - >; + type CurrencyIdConvert = CurrencyIdConvert; type AccountIdToMultiLocation = AccountIdToMultiLocation; type SelfLocation = SelfLocation; type XcmExecutor = XcmExecutor; @@ -1538,6 +1559,7 @@ impl TakeRevenue for ToTreasury { } pub type Trader = ( + FirstAssetTrader, FixedRateOfFungible, FixedRateOfFungible, FixedRateOfFungible, @@ -1560,7 +1582,6 @@ pub type Trader = ( FixedRateOfFungible, // Calamari FixedRateOfFungible, - FirstAssetTrader, ); // Min fee required when transferring asset back to reserve sibling chain diff --git a/scripts/helper/src/config/heiko.json b/scripts/helper/src/config/heiko.json index 85f70c256..7e12fe564 100644 --- a/scripts/helper/src/config/heiko.json +++ b/scripts/helper/src/config/heiko.json @@ -263,7 +263,7 @@ { "paraId": 2013, "derivativeIndex": 0, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 4000, "cap": "100000000000000", @@ -275,7 +275,7 @@ { "paraId": 2016, "derivativeIndex": 1, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 4000, "cap": "1000000000000000", @@ -287,7 +287,7 @@ { "paraId": 2100, "derivativeIndex": 2, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 4000, "cap": "10000000000000000", diff --git a/scripts/helper/src/config/parallel.json b/scripts/helper/src/config/parallel.json index ce09160ba..47058a76a 100644 --- a/scripts/helper/src/config/parallel.json +++ b/scripts/helper/src/config/parallel.json @@ -304,7 +304,7 @@ { "paraId": 2013, "derivativeIndex": 0, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 4000, "cap": "100000000000000", @@ -316,7 +316,7 @@ { "paraId": 2016, "derivativeIndex": 1, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 4000, "cap": "1000000000000000", @@ -328,7 +328,7 @@ { "paraId": 2100, "derivativeIndex": 2, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 4000, "cap": "10000000000000000", @@ -340,7 +340,7 @@ { "paraId": 2032, "derivativeIndex": 3, - "image": "parallelfinance/cumulus:v0.9.24", + "image": "parallelfinance/cumulus:v0.9.28", "chain": "shell", "ctokenId": 200070014, "cap": "10000000000000000",