Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IT: Simplify liquidity_pool test module #1869

Merged
merged 25 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ea08cec
basic xtransfer tests
lemunozm Jun 11, 2024
0bc96f6
parachain transfer tested
lemunozm Jun 11, 2024
e9174c9
fix tests
lemunozm Jun 11, 2024
57908e9
transfer relay tests
lemunozm Jun 12, 2024
1770f11
polish and minor cleans
lemunozm Jun 13, 2024
5b41f5e
fixes
lemunozm Jun 13, 2024
cdf8837
Merge remote-tracking branch 'origin/main' into it/simplify-xtransfer…
lemunozm Jun 13, 2024
8dd05e3
assets tests
lemunozm Jun 13, 2024
bf338c8
currency conversion tests
lemunozm Jun 13, 2024
126eeb5
fix cargo fmt
lemunozm Jun 13, 2024
891bfe7
fix tests
lemunozm Jun 14, 2024
d781110
reduce xcm restricted_transfer tests
lemunozm Jun 14, 2024
eeb1dbf
rename file
lemunozm Jun 14, 2024
bdee3ed
restricted ethereum tests simplified and moved to restricted
lemunozm Jun 14, 2024
0c3bb43
cleaning warnings
lemunozm Jun 14, 2024
5a832ad
removed re-added tranche tokens tests
lemunozm Jun 17, 2024
de3760a
remove fudge from proxy tests
lemunozm Jun 17, 2024
1b79822
Merge remote-tracking branch 'origin/main' into it/simplify-xtransfer…
lemunozm Jun 17, 2024
abace1f
minor cleans
lemunozm Jun 17, 2024
a2f7119
fix warnings
lemunozm Jun 18, 2024
d24c686
decouple PARA_ID and SIBLING_ID from FudgeHandle
lemunozm Jun 20, 2024
415a158
Merge remote-tracking branch 'origin/main' into it/simplify-xtransfer…
lemunozm Jun 24, 2024
cce79b6
revert liquidity-pool changes
lemunozm Jun 24, 2024
7f79140
Merge branch 'main' into it/simplify-xtransfer-tests
lemunozm Jun 24, 2024
3991dea
William suggestions
lemunozm Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libs/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ pub mod constants {

/// The maximum number of pool fees per pool fee bucket
pub const MAX_POOL_FEES_PER_BUCKET: u32 = 100;

lemunozm marked this conversation as resolved.
Show resolved Hide resolved
pub const NATIVE_KEY: &[u8] = &[0, 1];
}

/// Listing of parachains we integrate with.
Expand All @@ -301,7 +303,7 @@ pub mod parachains {

pub mod altair {
pub const ID: u32 = 2088;
pub const AIR_KEY: &[u8] = &[0, 1];
pub const AIR_KEY: &[u8] = crate::NATIVE_KEY;
}
}

Expand All @@ -313,7 +315,7 @@ pub mod parachains {

pub mod centrifuge {
pub const ID: u32 = 2031;
pub const CFG_KEY: &[u8] = &[0, 1];
pub const CFG_KEY: &[u8] = crate::NATIVE_KEY;
}
}

Expand Down
17 changes: 17 additions & 0 deletions libs/types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,23 @@ impl CrossChainTransferability {
pub fn includes_liquidity_pools(self) -> bool {
matches!(self, Self::LiquidityPools)
}

/// Fees will be charged using `FixedRateOfFungible`.
#[cfg(feature = "std")]
pub fn xcm_default() -> Self {
Self::Xcm(XcmMetadata {
fee_per_second: None,
})
}

/// Fees will be charged using `AssetRegistryTrader`.
/// If value is 0, no fees will be charged.
#[cfg(feature = "std")]
pub fn xcm_with_fees(value: Balance) -> Self {
Self::Xcm(XcmMetadata {
fee_per_second: Some(value),
})
}
Comment on lines +368 to +383
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tech-debt to create some tests to be able to compute the exact fee charged in the above two cases. Using FixedRateOfFungible and using AssetRegistryTrader

}

/// Liquidity Pools-wrapped tokens
Expand Down
22 changes: 3 additions & 19 deletions runtime/altair/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use cfg_primitives::{
parachains,
types::{EnsureRootOr, HalfOfCouncil},
};
use cfg_primitives::types::{EnsureRootOr, HalfOfCouncil};
use cfg_types::tokens::CurrencyId;
use frame_support::{
parameter_types,
Expand All @@ -27,10 +24,9 @@ use pallet_xcm::XcmPassthrough;
use runtime_common::{
transfer_filter::PreXcmTransfer,
xcm::{
general_key, AccountIdToLocation, Barrier, FixedConversionRateProvider,
AccountIdToLocation, Barrier, CanonicalNativePerSecond, FixedConversionRateProvider,
LocalOriginToLocation, ToTreasury,
},
xcm_fees::native_per_second,
};
use sp_core::ConstU32;
use staging_xcm::{
Expand Down Expand Up @@ -88,25 +84,13 @@ impl staging_xcm_executor::Config for XcmConfig {
/// else the xcm executor won't know how to charge fees for a transfer of said
/// token.
pub type Trader = (
FixedRateOfFungible<CanonicalAirPerSecond, ToTreasury<Runtime>>,
FixedRateOfFungible<CanonicalNativePerSecond, ToTreasury<Runtime>>,
AssetRegistryTrader<
FixedRateAssetRegistryTrader<FixedConversionRateProvider<OrmlAssetRegistry>>,
ToTreasury<Runtime>,
>,
);

parameter_types! {
// Canonical location: https://github.com/paritytech/polkadot/pull/4470
pub CanonicalAirPerSecond: (AssetId, u128, u128) = (
Location::new(
0,
general_key(parachains::kusama::altair::AIR_KEY)
).into(),
native_per_second(),
0,
);
}

/// Means for transacting the fungibles assets of this parachain.
pub type FungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation
Expand Down
22 changes: 3 additions & 19 deletions runtime/centrifuge/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

use cfg_primitives::{
parachains,
types::{EnsureRootOr, HalfOfCouncil},
};
use cfg_primitives::types::{EnsureRootOr, HalfOfCouncil};
use cfg_traits::TryConvert;
use cfg_types::{tokens::CurrencyId, EVMChainId};
use frame_support::{
Expand All @@ -28,10 +25,9 @@ use pallet_xcm::XcmPassthrough;
use runtime_common::{
transfer_filter::PreXcmTransfer,
xcm::{
general_key, AccountIdToLocation, Barrier, FixedConversionRateProvider,
AccountIdToLocation, Barrier, CanonicalNativePerSecond, FixedConversionRateProvider,
LocalOriginToLocation, LpInstanceRelayer, ToTreasury,
},
xcm_fees::native_per_second,
};
use sp_core::ConstU32;
use staging_xcm::{
Expand Down Expand Up @@ -89,25 +85,13 @@ impl staging_xcm_executor::Config for XcmConfig {
/// else the xcm executor won't know how to charge fees for a transfer of said
/// token.
pub type Trader = (
FixedRateOfFungible<CanonicalCfgPerSecond, ToTreasury<Runtime>>,
FixedRateOfFungible<CanonicalNativePerSecond, ToTreasury<Runtime>>,
AssetRegistryTrader<
FixedRateAssetRegistryTrader<FixedConversionRateProvider<OrmlAssetRegistry>>,
ToTreasury<Runtime>,
>,
);

parameter_types! {
// Canonical location: https://github.com/paritytech/polkadot/pull/4470
pub CanonicalCfgPerSecond: (AssetId, u128, u128) = (
Location::new(
0,
general_key(parachains::polkadot::centrifuge::CFG_KEY),
).into(),
native_per_second(),
0,
);
}

/// Means for transacting the fungibles assets of this parachain.
pub type FungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation
Expand Down
14 changes: 13 additions & 1 deletion runtime/common/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use staging_xcm_builder::{
TakeWeightCredit,
};

use crate::xcm_fees::default_per_second;
use crate::xcm_fees::{default_per_second, native_per_second};

/// Our FixedConversionRateProvider, used to charge XCM-related fees for
/// tokens registered in the asset registry that were not already handled by
Expand Down Expand Up @@ -71,6 +71,18 @@ pub fn general_key(data: &[u8]) -> staging_xcm::latest::Junction {
}
}

frame_support::parameter_types! {
// Canonical location: https://github.com/paritytech/polkadot/pull/4470
pub CanonicalNativePerSecond: (AssetId, u128, u128) = (
Location::new(
0,
general_key(cfg_primitives::NATIVE_KEY),
).into(),
native_per_second(),
0,
);
}

/// How we convert an `[AccountId]` into an XCM Location
pub struct AccountIdToLocation;
impl<AccountId: Into<[u8; 32]>> Convert<AccountId, Location> for AccountIdToLocation {
Expand Down
21 changes: 2 additions & 19 deletions runtime/development/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
use cfg_primitives::{
parachains,
types::{EnsureRootOr, HalfOfCouncil},
};
use cfg_primitives::types::{EnsureRootOr, HalfOfCouncil};
use cfg_traits::TryConvert;
use cfg_types::{tokens::CurrencyId, EVMChainId};
use frame_support::{
Expand All @@ -27,10 +24,9 @@ use pallet_xcm::XcmPassthrough;
use runtime_common::{
transfer_filter::PreXcmTransfer,
xcm::{
general_key, AccountIdToLocation, Barrier, FixedConversionRateProvider,
AccountIdToLocation, Barrier, CanonicalNativePerSecond, FixedConversionRateProvider,
LocalOriginToLocation, LpInstanceRelayer, ToTreasury,
},
xcm_fees::native_per_second,
};
use sp_core::ConstU32;
use staging_xcm::{
Expand Down Expand Up @@ -95,19 +91,6 @@ pub type Trader = (
>,
);

parameter_types! {
// Canonical location: https://github.com/paritytech/polkadot/pull/4470
pub CanonicalNativePerSecond: (AssetId, u128, u128) = (
Location::new(
0,
general_key(parachains::kusama::altair::AIR_KEY),
).into(),
native_per_second(),
0,
);

}

/// Means for transacting the fungibles assets of this parachain.
pub type FungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation
Expand Down
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/generic/cases/investments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod common {
.add(genesis::balances::<T>(
T::ExistentialDeposit::get() + FOR_FEES,
))
.add(genesis::assets::<T>(vec![Box::new(Usd6)]))
.add(genesis::assets::<T>(vec![(Usd6.id(), &Usd6.metadata())]))
.add(genesis::tokens::<T>(vec![(Usd6.id(), Usd6.ed())]))
.storage(),
);
Expand Down
Loading
Loading