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

[xcm-v5] implement RFC#122: InitiateTransfer can alias XCM original origin on destination #5971

Merged
merged 23 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
23965f1
xcm: add preserve origin capabilities to InitiateTransfer
acatangiu Oct 4, 2024
0b650f1
add origin alias helpers
acatangiu Oct 5, 2024
75da437
asset hub can proxy transact between two sibling parachains
acatangiu Oct 7, 2024
223b948
fix executor
acatangiu Oct 7, 2024
72e9fcc
fix AH transact proxy test
acatangiu Oct 7, 2024
6f17e4e
fix merge dmg
acatangiu Oct 22, 2024
55bf5da
add helper macros
acatangiu Oct 22, 2024
2113ebb
e2e test: add test for transacting on Parachain as user from Ethereum
acatangiu Oct 24, 2024
148f9a1
fix: conflicts and tests
franciscoaguirre Oct 25, 2024
4e6267f
fix: fix missing weights
franciscoaguirre Oct 25, 2024
245eae5
doc: add prdoc
franciscoaguirre Oct 25, 2024
1670e70
fix: benchmarks
franciscoaguirre Oct 25, 2024
05a4ac7
fix(asset-hub-rococo): add alias_origin benchmark
franciscoaguirre Oct 25, 2024
a05bc31
".git/.scripts/commands/fmt/fmt.sh"
Oct 25, 2024
24486a3
".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=as…
Oct 25, 2024
aacf800
".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=as…
Oct 25, 2024
530d10f
".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=as…
Oct 25, 2024
b9975d9
".git/.scripts/commands/bench/bench.sh" --subcommand=xcm --runtime=as…
Oct 25, 2024
516f0cb
fix: clippy
franciscoaguirre Oct 25, 2024
c0701a1
fix(asset-hub-rococo): enable benchmark for alias_origin
franciscoaguirre Oct 28, 2024
22ee919
fix: clippy
franciscoaguirre Oct 28, 2024
d431a1d
fix: clippy
franciscoaguirre Oct 28, 2024
c0edd03
Merge branch 'xcm-v5' into impl-rfc-122
bkontur Oct 29, 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
2 changes: 2 additions & 0 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,10 @@ where
{
fn convert_location(location: &Location) -> Option<AccountId> {
match location.unpack() {
(_, [GlobalConsensus(Ethereum { chain_id })]) =>
(2, [GlobalConsensus(Ethereum { chain_id })]) =>
Some(Self::from_chain_id(chain_id).into()),
(2, [GlobalConsensus(Ethereum { chain_id }), AccountKey20 { network: _, key }]) =>
Some(Self::from_chain_id_with_key(chain_id, *key).into()),
_ => None,
}
}
Expand All @@ -469,4 +471,7 @@ impl<AccountId> GlobalConsensusEthereumConvertsFor<AccountId> {
pub fn from_chain_id(chain_id: &u64) -> [u8; 32] {
(b"ethereum-chain", chain_id).using_encoded(blake2_256)
}
pub fn from_chain_id_with_key(chain_id: &u64, key: [u8; 20]) -> [u8; 32] {
(b"ethereum-chain", chain_id, key).using_encoded(blake2_256)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pallet-asset-tx-payment = { workspace = true }
# Polkadot
polkadot-runtime-common = { workspace = true, default-features = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
pallet-xcm = { workspace = true }
xcm-runtime-apis = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ mod imports {
};

// Polkadot
pub use xcm::prelude::{AccountId32 as AccountId32Junction, *};
pub use xcm::{
latest::AssetTransferFilter,
prelude::{AccountId32 as AccountId32Junction, *},
};
pub use xcm_executor::traits::TransferType;

// Cumulus
Expand All @@ -42,7 +45,7 @@ mod imports {
xcm_helpers::{
get_amount_from_versioned_assets, non_fee_asset, xcm_transact_paid_execution,
},
ASSETS_PALLET_ID, RESERVABLE_ASSET_ID, XCM_V3,
ASSETS_PALLET_ID, RESERVABLE_ASSET_ID, USDT_ID, XCM_V3,
};
pub use parachains_common::{AccountId, Balance};
pub use westend_system_emulated_network::{
Expand All @@ -68,6 +71,7 @@ mod imports {
CustomizableAssetFromSystemAssetHub as PenpalCustomizableAssetFromSystemAssetHub,
LocalReservableFromAssetHub as PenpalLocalReservableFromAssetHub,
LocalTeleportableToAssetHub as PenpalLocalTeleportableToAssetHub,
UniversalLocation as PenpalUniversalLocation,
UsdtFromAssetHub as PenpalUsdtFromAssetHub,
},
PenpalAParaPallet as PenpalAPallet, PenpalAssetOwner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::{
imports::*,
tests::teleport::do_bidirectional_teleport_foreign_assets_between_para_and_asset_hub_using_xt,
};
use xcm::latest::AssetTransferFilter;

fn para_to_para_assethub_hop_assertions(t: ParaToParaThroughAHTest) {
type RuntimeEvent = <AssetHubWestend as Chain>::RuntimeEvent;
Expand Down Expand Up @@ -851,6 +850,7 @@ fn bidirectional_transfer_multiple_assets_between_penpal_and_asset_hub() {
InitiateTransfer {
destination: t.args.dest,
remote_fees: Some(AssetTransferFilter::ReserveWithdraw(fees.into())),
preserve_origin: false,
assets: vec![AssetTransferFilter::Teleport(assets.into())],
remote_xcm: xcm_on_dest,
},
Expand Down Expand Up @@ -886,6 +886,7 @@ fn bidirectional_transfer_multiple_assets_between_penpal_and_asset_hub() {
InitiateTransfer {
destination: t.args.dest,
remote_fees: Some(AssetTransferFilter::ReserveDeposit(fees.into())),
preserve_origin: false,
assets: vec![AssetTransferFilter::Teleport(assets.into())],
remote_xcm: xcm_on_dest,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,82 @@ mod set_asset_claimer;
mod set_xcm_versions;
mod swap;
mod teleport;
mod transact;
mod treasury;
mod xcm_fee_estimation;

#[macro_export]
macro_rules! foreign_balance_on {
( $chain:ident, $id:expr, $who:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type ForeignAssets = <$chain as [<$chain Pallet>]>::ForeignAssets;
<ForeignAssets as Inspect<_>>::balance($id, $who)
})
}
};
}

#[macro_export]
macro_rules! create_pool_with_wnd_on {
( $chain:ident, $asset_id:expr, $is_foreign:expr, $asset_owner:expr ) => {
emulated_integration_tests_common::impls::paste::paste! {
<$chain>::execute_with(|| {
type RuntimeEvent = <$chain as Chain>::RuntimeEvent;
let owner = $asset_owner;
let signed_owner = <$chain as Chain>::RuntimeOrigin::signed(owner.clone());
let wnd_location: Location = Parent.into();
if $is_foreign {
assert_ok!(<$chain as [<$chain Pallet>]>::ForeignAssets::mint(
signed_owner.clone(),
$asset_id.clone().into(),
owner.clone().into(),
10_000_000_000_000, // For it to have more than enough.
));
} else {
let asset_id = match $asset_id.interior.last() {
Some(GeneralIndex(id)) => *id as u32,
_ => unreachable!(),
};
assert_ok!(<$chain as [<$chain Pallet>]>::Assets::mint(
signed_owner.clone(),
asset_id.into(),
owner.clone().into(),
10_000_000_000_000, // For it to have more than enough.
));
}

assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::create_pool(
signed_owner.clone(),
Box::new(wnd_location.clone()),
Box::new($asset_id.clone()),
));

assert_expected_events!(
$chain,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::PoolCreated { .. }) => {},
]
);

assert_ok!(<$chain as [<$chain Pallet>]>::AssetConversion::add_liquidity(
signed_owner,
Box::new(wnd_location),
Box::new($asset_id),
1_000_000_000_000,
2_000_000_000_000, // $asset_id is worth half of wnd
0,
0,
owner.into()
));

assert_expected_events!(
$chain,
vec![
RuntimeEvent::AssetConversion(pallet_asset_conversion::Event::LiquidityAdded { .. }) => {},
]
);
});
}
};
}
Loading
Loading