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

Support different assets for delivery fees #4375

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
eea690b
feat(xcm-executor): add AssetConverter config item to support multipl…
franciscoaguirre May 8, 2024
5d74482
fix: implement AssetConverter in all runtimes
franciscoaguirre May 8, 2024
8e9df56
feat: add AssetConverters copying the traders
franciscoaguirre May 8, 2024
3ed0430
test(asset-hub-westend): add tests for paying delivery fees with diff…
franciscoaguirre May 8, 2024
da83c68
fix: update lock
franciscoaguirre May 8, 2024
efab825
fix(pallet-xcm): remove jit withdrawal to allow paying delivery fees …
franciscoaguirre May 11, 2024
da7b054
doc: add TODOs I'm considering
franciscoaguirre May 11, 2024
bdfbeaf
feat: start with SwapAssetConverter
franciscoaguirre May 11, 2024
a81ba18
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre May 15, 2024
c69095f
feat: SwapAssetConverter. Some tests failing
franciscoaguirre May 22, 2024
0193e60
fix(asset-hub-rococo-integration-tests): delivery fee taken from holding
franciscoaguirre May 22, 2024
0b0437c
fix(integration-tests): stick to jit withdrawal for now
franciscoaguirre May 22, 2024
03c01ff
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 1, 2024
502ebf6
chore: update Cargo.lock
franciscoaguirre Jul 1, 2024
550d92a
fix: fmt
franciscoaguirre Jul 1, 2024
ba024d1
feat(xcm-executor): remove all logic regarding local execution
franciscoaguirre Jul 1, 2024
69d1043
feat: complete tests
franciscoaguirre Jul 2, 2024
820160e
fix: fmt
franciscoaguirre Jul 2, 2024
677129d
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 2, 2024
99c9749
feat: remove support for sufficient asset converters
franciscoaguirre Jul 2, 2024
05b620d
feat(asset-hub-rococo): add a PoolAssetsConverter
franciscoaguirre Jul 2, 2024
522e7c7
feat(emulated-tests): add USDT to genesis and create WND<>USDT pool i…
franciscoaguirre Jul 3, 2024
629dcce
doc: prdoc
franciscoaguirre Jul 3, 2024
b6f3b6e
doc(asset-hub-westend-integration-tests): change the docs for a test
franciscoaguirre Jul 3, 2024
7ffd02a
chore(xcm-executor): change order of associated types in config
franciscoaguirre Jul 3, 2024
69c22ce
fix: fmt
franciscoaguirre Jul 3, 2024
b485475
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 3, 2024
df196fe
feat: remove AssetConverter and use AssetExchanger instead
franciscoaguirre Jul 4, 2024
1639489
doc: prdoc
franciscoaguirre Jul 4, 2024
9875ee2
doc: prdoc
franciscoaguirre Jul 4, 2024
c3d1554
fix: clippy and feedback
franciscoaguirre Jul 4, 2024
ab890aa
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 4, 2024
e2107f8
fix: zepter and taplo
franciscoaguirre Jul 4, 2024
84d0f14
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 5, 2024
77b0cc8
feat(xcm-executor): not error in case there are no delivery fees
franciscoaguirre Jul 5, 2024
2888826
chore(xcm-executor): deduplicate swapping logic in take_fees
franciscoaguirre Jul 5, 2024
90807aa
fix(assets-common): remove duplicated feature flags
franciscoaguirre Jul 5, 2024
10dd60f
chore(xcm-executor): remove default implementation for AssetExchange
franciscoaguirre Jul 5, 2024
49d76b9
doc: update prdoc crate bumps
franciscoaguirre Jul 5, 2024
a2d3b68
Apply suggestions from code review
acatangiu Jul 9, 2024
d4d6055
fix executor
acatangiu Jul 9, 2024
8f266c4
clean up tests
acatangiu Jul 9, 2024
11a03ee
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 17, 2024
b0e1c60
chore: address some docs and naming feedback
franciscoaguirre Jul 17, 2024
18e8b7c
fix(staging-xcm-executor): move log to tracing
franciscoaguirre Jul 18, 2024
d1baffc
chore: address more feedback
franciscoaguirre Jul 18, 2024
28553fb
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 18, 2024
d576a76
fix: fmt
franciscoaguirre Jul 18, 2024
1605b8a
Merge branch 'master' into different-assets-delivery-fees
franciscoaguirre Jul 22, 2024
5e1c999
fix: fmt
franciscoaguirre Jul 22, 2024
1fe6c08
feat(xcm-builder): rename FungiblesPoolAdapter to SingleAssetExchange…
franciscoaguirre Jul 22, 2024
184b2eb
feat(xcm-builder): tests for SingleAssetExchangeAdapter
franciscoaguirre Jul 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
5 changes: 5 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ use sp_core::{sr25519, storage::Storage};
use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, get_account_id_from_seed,
PenpalSiblingSovereignAccount, PenpalTeleportableAssetLocation, RESERVABLE_ASSET_ID,
SAFE_XCM_VERSION,
SAFE_XCM_VERSION, USDT_ID,
};
use parachains_common::{AccountId, Balance};

pub const PARA_ID: u32 = 1000;
pub const ED: Balance = testnet_parachains_constants::westend::currency::EXISTENTIAL_DEPOSIT;
pub const USDT_ED: Balance = 70_000;

parameter_types! {
pub AssetHubWestendAssetOwner: AccountId = get_account_id_from_seed::<sr25519::Public>("Alice");
Expand Down Expand Up @@ -64,7 +65,10 @@ pub fn genesis() -> Storage {
..Default::default()
},
assets: asset_hub_westend_runtime::AssetsConfig {
assets: vec![(RESERVABLE_ASSET_ID, AssetHubWestendAssetOwner::get(), true, ED)],
assets: vec![
(RESERVABLE_ASSET_ID, AssetHubWestendAssetOwner::get(), true, ED),
(USDT_ID, AssetHubWestendAssetOwner::get(), true, USDT_ED),
],
..Default::default()
},
foreign_assets: asset_hub_westend_runtime::ForeignAssetsConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ use emulated_integration_tests_common::{
accounts, build_genesis_storage, collators, get_account_id_from_seed, SAFE_XCM_VERSION,
};
use parachains_common::{AccountId, Balance};
use penpal_runtime::xcm_config::{LocalReservableFromAssetHub, RelayLocation};
use penpal_runtime::xcm_config::{LocalReservableFromAssetHub, RelayLocation, UsdtFromAssetHub};
// Penpal
pub const PARA_ID_A: u32 = 2000;
pub const PARA_ID_B: u32 = 2001;
pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT;
pub const USDT_ED: Balance = 70_000;

parameter_types! {
pub PenpalSudoAccount: AccountId = get_account_id_from_seed::<sr25519::Public>("Alice");
Expand Down Expand Up @@ -80,6 +81,8 @@ pub fn genesis(para_id: u32) -> Storage {
(RelayLocation::get(), PenpalAssetOwner::get(), true, ED),
// Sufficient AssetHub asset representation
(LocalReservableFromAssetHub::get(), PenpalAssetOwner::get(), true, ED),
// USDT from AssetHub
(UsdtFromAssetHub::get(), PenpalAssetOwner::get(), true, USDT_ED),
],
..Default::default()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ decl_test_parachains! {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
ForeignAssets: penpal_runtime::ForeignAssets,
AssetConversion: penpal_runtime::AssetConversion,
Balances: penpal_runtime::Balances,
}
},
Expand All @@ -76,6 +77,7 @@ decl_test_parachains! {
PolkadotXcm: penpal_runtime::PolkadotXcm,
Assets: penpal_runtime::Assets,
ForeignAssets: penpal_runtime::ForeignAssets,
AssetConversion: penpal_runtime::AssetConversion,
Balances: penpal_runtime::Balances,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
<ForeignAssets as Inspect<_>>::balance(wnd_at_rococo_parachains, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
// Sender's balance is reduced by amount sent plus delivery fees.
assert!(sender_rocs_after < sender_rocs_before - roc_to_send);
assert_eq!(sender_wnds_after, sender_wnds_before - wnd_to_send);
// Sovereign accounts on reserve are changed accordingly
Expand Down Expand Up @@ -798,7 +798,7 @@ fn transfer_native_asset_from_relay_to_para_through_asset_hub() {
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
// Sender's balance is reduced by amount sent plus delivery fees.
assert!(sender_balance_after < sender_balance_before - amount_to_send);
// SA on AH balance is increased
assert!(sov_penpal_on_ah_after > sov_penpal_on_ah_before);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,8 @@ fn reserve_transfer_native_asset_from_para_to_para_through_relay() {
<ForeignAssets as Inspect<_>>::balance(relay_native_asset_location, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
// Sender's balance is reduced by amount sent plus delivery fees.
assert!(sender_assets_after < sender_assets_before - amount_to_send);
// Receiver's balance is increased
// Receiver's balance is increased.
assert!(receiver_assets_after > receiver_assets_before);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ mod imports {
CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub,
LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub,
LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub,
UsdtFromAssetHub as PenpalUsdtFromAssetHub,
},
PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner,
PenpalBParaPallet as PenpalBPallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

use crate::imports::*;
use emulated_integration_tests_common::accounts::{ALICE, BOB};
use frame_support::traits::fungibles::{Create, Inspect, Mutate};
use frame_support::traits::fungibles::{Inspect, Mutate};
use polkadot_runtime_common::impls::VersionedLocatableAsset;
use xcm_executor::traits::ConvertLocation;

#[test]
fn create_and_claim_treasury_spend() {
const ASSET_ID: u32 = 1984;
const ASSET_ID: u32 = 1984; // USDT already created at genesis.
const SPEND_AMOUNT: u128 = 1_000_000;
// treasury location from a sibling parachain.
let treasury_location: Location =
Expand All @@ -44,13 +44,7 @@ fn create_and_claim_treasury_spend() {
AssetHubWestend::execute_with(|| {
type Assets = <AssetHubWestend as AssetHubWestendPallet>::Assets;

// create an asset class and mint some assets to the treasury account.
assert_ok!(<Assets as Create<_>>::create(
ASSET_ID,
treasury_account.clone(),
true,
SPEND_AMOUNT / 2
));
// USDT already created at genesis.
assert_ok!(<Assets as Mutate<_>>::mint_into(ASSET_ID, &treasury_account, SPEND_AMOUNT * 4));
// beneficiary has zero balance.
assert_eq!(<Assets as Inspect<_>>::balance(ASSET_ID, &alice,), 0u128,);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
<ForeignAssets as Inspect<_>>::balance(roc_at_westend_parachains, &receiver)
});

// Sender's balance is reduced by amount sent plus delivery fees
// Sender's balance is reduced by amount sent.
assert!(sender_wnds_after < sender_wnds_before - wnd_to_send);
assert_eq!(sender_rocs_after, sender_rocs_before - roc_to_send);
// Sovereign accounts on reserve are changed accordingly
Expand All @@ -630,8 +630,9 @@ fn transfer_foreign_assets_from_para_to_para_through_asset_hub() {
rocs_in_receiver_reserve_on_ah_after,
rocs_in_receiver_reserve_on_ah_before + roc_to_send
);
// Receiver's balance is increased
// Receiver's balance is increased by amount sent minus delivery fees.
assert!(receiver_wnds_after > receiver_wnds_before);
assert!(receiver_wnds_after < receiver_wnds_before + wnd_to_send);
assert_eq!(receiver_rocs_after, receiver_rocs_before + roc_to_send);
}

Expand Down
Loading
Loading