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

Add pallet-xcm patch with claim_assets extrinsic #7

Merged
merged 8 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pallet-staking = "29.0.0"
sc-consensus-grandpa = "0.20.0"
sp-runtime = "32.0.0"
sp-consensus-beefy = "14.0.0"
xcm = { package = "staging-xcm", version = "8.0.0" }
xcm = { package = "staging-xcm", version = "8.0.1" }
parachains-common = { version = "8.0.0" }
cumulus-primitives-core = { version = "0.8.0" }

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/emulated/helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pallet-balances = { version = "29.0.0" }
pallet-message-queue = { version = "32.0.0" }

# Polkadot
xcm = { package = "staging-xcm", version = "8.0.0" }
pallet-xcm = { version = "8.0.1" }
xcm = { package = "staging-xcm", version = "8.0.1" }
pallet-xcm = { version = "8.0.2" }

# Cumulus
xcm-emulator = { version = "0.6.0" }
Expand Down
56 changes: 55 additions & 1 deletion integration-tests/emulated/helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use pallet_message_queue;

// Polkadot
pub use pallet_xcm;
pub use xcm::prelude::{AccountId32, WeightLimit};
pub use xcm::prelude::{AccountId32, VersionedAssets, Weight, WeightLimit};

// Cumulus
pub use asset_test_utils;
Expand Down Expand Up @@ -122,3 +122,57 @@ macro_rules! test_parachain_is_trusted_teleporter {
}
};
}

#[macro_export]
macro_rules! test_parachain_can_claim_assets {
( $sender_para:ty, $runtime_call:ty, $network_id:expr, $assets:expr, $amount:expr ) => {
$crate::paste::paste! {
let sender = [<$sender_para Sender>]::get();
let origin = <$sender_para as $crate::Chain>::RuntimeOrigin::signed(sender.clone());
// Receiver is the same as sender
let beneficiary: Location =
$crate::AccountId32 { network: Some($network_id), id: sender.clone().into() }.into();
let versioned_assets: $crate::VersionedAssets = $assets.clone().into();

<$sender_para>::execute_with(|| {
// Assets are trapped for whatever reason.
// The possible reasons for this might differ from runtime to runtime, so here we just drop them directly.
<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::drop_assets(
&beneficiary,
$assets.into(),
&XcmContext { origin: None, message_id: [0u8; 32], topic: None },
);

type RuntimeEvent = <$sender_para as $crate::Chain>::RuntimeEvent;
assert_expected_events!(
$sender_para,
vec![
RuntimeEvent::PolkadotXcm(
$crate::pallet_xcm::Event::AssetsTrapped { origin: beneficiary, assets: versioned_assets, .. }
) => {},
]
);

let balance_before = <$sender_para as [<$sender_para Pallet>]>::Balances::free_balance(&sender);

assert_ok!(<$sender_para as [<$sender_para Pallet>]>::PolkadotXcm::claim_assets(
origin.clone(),
bx!(versioned_assets.clone().into()),
bx!(beneficiary.clone().into()),
));

assert_expected_events!(
$sender_para,
vec![
RuntimeEvent::PolkadotXcm(
$crate::pallet_xcm::Event::AssetsClaimed { origin: beneficiary, assets: versioned_assets, .. }
) => {},
]
);

let balance_after = <$sender_para as [<$sender_para Pallet>]>::Balances::free_balance(&sender);
assert_eq!(balance_after, balance_before + $amount);
});
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pallet-asset-conversion = { version = "11.0.0" }
pallet-message-queue = { version = "32.0.0" }

# Polkadot
xcm = { package = "staging-xcm", version = "8.0.0" }
xcm = { package = "staging-xcm", version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false, version = "8.0.1" }
pallet-xcm = { version = "8.0.1" }
pallet-xcm = { version = "8.0.2" }

# Cumulus
parachains-common = { version = "8.0.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ emulated_integration_tests_common::include_penpal_create_foreign_asset_on_asset_
KUSAMA_ED,
system_parachains_constants::kusama::fee::WeightToFee
);

#[test]
fn assets_can_be_claimed() {
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
use asset_hub_kusama_runtime::ExistentialDeposit;
use integration_tests_helpers::test_parachain_can_claim_assets;
use xcm_executor::traits::DropAssets;

let amount = ExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_parachain_can_claim_assets!(AssetHubKusama, RuntimeCall, NetworkId::Kusama, assets, amount);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ pallet-message-queue = { version = "32.0.0" }

# Polkadot
polkadot-runtime-common = { version = "8.0.1" }
xcm = { package = "staging-xcm", version = "8.0.0" }
pallet-xcm = { version = "8.0.1" }
xcm = { package = "staging-xcm", version = "8.0.1" }
pallet-xcm = { version = "8.0.2" }
xcm-executor = { package = "staging-xcm-executor", version = "8.0.1" }

# Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@ emulated_integration_tests_common::include_penpal_create_foreign_asset_on_asset_
POLKADOT_ED,
system_parachains_constants::polkadot::fee::WeightToFee
);

#[test]
fn assets_can_be_claimed() {
use asset_hub_polkadot_runtime::ExistentialDeposit;
use integration_tests_helpers::test_parachain_can_claim_assets;
use xcm_executor::traits::DropAssets;

let amount = ExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_parachain_can_claim_assets!(AssetHubPolkadot, RuntimeCall, NetworkId::Polkadot, assets, amount);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pallet-assets = { version = "30.0.0" }
pallet-message-queue = { version = "32.0.0" }

# Polkadot
xcm = { package = "staging-xcm", version = "8.0.0" }
pallet-xcm = { version = "8.0.1" }
xcm = { package = "staging-xcm", version = "8.0.1" }
pallet-xcm = { version = "8.0.2" }
xcm-executor = { package = "staging-xcm-executor", version = "8.0.1" }

# Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,15 @@ pub(crate) fn assert_bridge_hub_polkadot_message_received() {
);
})
}

#[test]
fn assets_can_be_claimed() {
use bridge_hub_kusama_runtime::ExistentialDeposit;
use integration_tests_helpers::test_parachain_can_claim_assets;
use xcm_executor::traits::DropAssets;

let amount = ExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_parachain_can_claim_assets!(AssetHubKusama, RuntimeCall, NetworkId::Kusama, assets, amount);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pallet-assets = { version = "30.0.0" }
pallet-message-queue = { version = "32.0.0" }

# Polkadot
xcm = { package = "staging-xcm", version = "8.0.0" }
pallet-xcm = { version = "8.0.1" }
xcm = { package = "staging-xcm", version = "8.0.1" }
pallet-xcm = { version = "8.0.2" }
xcm-executor = { package = "staging-xcm-executor", version = "8.0.1" }

# Cumulus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,15 @@ pub(crate) fn assert_bridge_hub_kusama_message_received() {
);
})
}

#[test]
fn assets_can_be_claimed() {
use bridge_hub_polkadot_runtime::ExistentialDeposit;
use integration_tests_helpers::test_parachain_can_claim_assets;
use xcm_executor::traits::DropAssets;

let amount = ExistentialDeposit::get();
let assets: Assets = (Parent, amount).into();

test_parachain_can_claim_assets!(AssetHubPolkadot, RuntimeCall, NetworkId::Polkadot, assets, amount);
}
4 changes: 2 additions & 2 deletions relay/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pallet-treasury = { default-features = false , version = "28.0.0" }
pallet-utility = { default-features = false , version = "29.0.0" }
pallet-vesting = { default-features = false , version = "29.0.0" }
pallet-whitelist = { default-features = false , version = "28.0.0" }
pallet-xcm = { default-features = false , version = "8.0.1" }
pallet-xcm = { default-features = false , version = "8.0.2" }
pallet-xcm-benchmarks = { default-features = false, optional = true , version = "8.0.2" }
frame-election-provider-support = { default-features = false , version = "29.0.0" }

Expand All @@ -98,7 +98,7 @@ runtime-common = { package = "polkadot-runtime-common", default-features = false
runtime-parachains = { package = "polkadot-runtime-parachains", default-features = false , version = "8.0.1" }
primitives = { package = "polkadot-primitives", default-features = false , version = "8.0.1" }

xcm = { package = "staging-xcm", default-features = false , version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false , version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false , version = "8.0.1" }
xcm-builder = { package = "staging-xcm-builder", default-features = false , version = "8.0.1" }

Expand Down
3 changes: 3 additions & 0 deletions relay/kusama/src/weights/pallet_xcm.rs

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

4 changes: 2 additions & 2 deletions relay/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pallet-whitelist = { default-features = false , version = "28.0.0" }
pallet-vesting = { default-features = false , version = "29.0.0" }
pallet-utility = { default-features = false , version = "29.0.0" }
frame-election-provider-support = { default-features = false , version = "29.0.0" }
pallet-xcm = { default-features = false, version = "8.0.1" }
pallet-xcm = { default-features = false, version = "8.0.2" }
pallet-xcm-benchmarks = { default-features = false, optional = true , version = "8.0.2" }

frame-benchmarking = { default-features = false, optional = true , version = "29.0.0" }
Expand All @@ -94,7 +94,7 @@ runtime-common = { package = "polkadot-runtime-common", default-features = false
runtime-parachains = { package = "polkadot-runtime-parachains", default-features = false , version = "8.0.1" }
primitives = { package = "polkadot-primitives", default-features = false , version = "8.0.1" }

xcm = { package = "staging-xcm", default-features = false , version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false , version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false , version = "8.0.1" }
xcm-builder = { package = "staging-xcm-builder", default-features = false , version = "8.0.1" }

Expand Down
3 changes: 3 additions & 0 deletions relay/polkadot/src/weights/pallet_xcm.rs

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

4 changes: 2 additions & 2 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ sp-weights = { default-features = false, version = "28.0.0" }
primitive-types = { version = "0.12.2", default-features = false, features = ["codec", "scale-info", "num-traits"] }

# Polkadot
pallet-xcm = { default-features = false, version = "8.0.1" }
pallet-xcm = { default-features = false, version = "8.0.2" }
pallet-xcm-benchmarks = { default-features = false, optional = true , version = "8.0.2" }
polkadot-core-primitives = { default-features = false, version = "8.0.0" }
polkadot-parachain-primitives = { default-features = false, version = "7.0.0" }
polkadot-runtime-common = { default-features = false, version = "8.0.1" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" }
xcm-builder = { package = "staging-xcm-builder", default-features = false, version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false, version = "8.0.1" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ frame-support = { default-features = false, version = "29.0.0" }
sp-std = { default-features = false, version = "14.0.0" }

# Polkadot
xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" }

[features]
default = [ "std" ]
Expand Down

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

4 changes: 2 additions & 2 deletions system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ sp-version = { default-features = false, version = "30.0.0" }
sp-weights = { default-features = false, version = "28.0.0" }

# Polkadot
pallet-xcm = { default-features = false, version = "8.0.1" }
pallet-xcm = { default-features = false, version = "8.0.2" }
pallet-xcm-benchmarks = { default-features = false, optional = true , version = "8.0.2" }
polkadot-core-primitives = { default-features = false, version = "8.0.0" }
polkadot-parachain-primitives = { default-features = false, version = "7.0.0" }
polkadot-runtime-common = { default-features = false, version = "8.0.1" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" }
xcm-builder = { package = "staging-xcm-builder", default-features = false, version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false, version = "8.0.1" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ frame-support = { default-features = false, version = "29.0.0" }
sp-std = { default-features = false, version = "14.0.0" }

# Polkadot
xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" }

[features]
default = [ "std" ]
Expand Down

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

4 changes: 2 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ sp-transaction-pool = { default-features = false, version = "27.0.0" }
sp-version = { default-features = false, version = "30.0.0" }

# Polkadot
pallet-xcm = { default-features = false, version = "8.0.1" }
pallet-xcm = { default-features = false, version = "8.0.2" }
pallet-xcm-benchmarks = { default-features = false, optional = true , version = "8.0.2" }
polkadot-core-primitives = { default-features = false, version = "8.0.0" }
polkadot-parachain-primitives = { default-features = false, version = "7.0.0" }
polkadot-runtime-common = { default-features = false, version = "8.0.1" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" }
xcm-builder = { package = "staging-xcm-builder", default-features = false, version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false, version = "8.0.1" }

Expand Down

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

4 changes: 2 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ sp-transaction-pool = { default-features = false, version = "27.0.0" }
sp-version = { default-features = false, version = "30.0.0" }

# Polkadot
pallet-xcm = { default-features = false, version = "8.0.1" }
pallet-xcm = { default-features = false, version = "8.0.2" }
pallet-xcm-benchmarks = { default-features = false, optional = true , version = "8.0.2" }
polkadot-core-primitives = { default-features = false, version = "8.0.0" }
polkadot-parachain-primitives = { default-features = false, version = "7.0.0" }
polkadot-runtime-common = { default-features = false, version = "8.0.1" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" }
xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" }
xcm-builder = { package = "staging-xcm-builder", default-features = false, version = "8.0.1" }
xcm-executor = { package = "staging-xcm-executor", default-features = false, version = "8.0.1" }

Expand Down

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

Loading
Loading