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 v6 #7123

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from
Draft

XCM v6 #7123

Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ dyn-clonable = { version = "0.9.0" }
dyn-clone = { version = "1.0.16" }
ed25519-dalek = { version = "2.1", default-features = false }
ed25519-zebra = { version = "4.0.3", default-features = false }
educe = { version = "0.6.0", default-features = false, features = ["Clone", "Debug", "Default", "Eq", "Ord", "PartialEq", "PartialOrd"] }
either = { version = "1.8.1", default-features = false }
emulated-integration-tests-common = { path = "cumulus/parachains/integration-tests/emulated/common", default-features = false }
enumflags2 = { version = "0.7.7" }
Expand Down
2 changes: 1 addition & 1 deletion bridges/bin/runtime-common/src/messages_benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub fn generate_xcm_builder_bridge_message_sample(
expected_message_size, location_encoded_size, xcm_size, xcm_data_size,
);

let xcm = xcm::VersionedXcm::<()>::from(Xcm(vec![Instruction::<()>::ExpectPallet {
let xcm = xcm::VersionedXcm::<()>::from(Xcm::new(vec![Instruction::<()>::ExpectPallet {
index: 0,
name: vec![42; xcm_data_size],
module_name: vec![],
Expand Down
4 changes: 2 additions & 2 deletions bridges/snowbridge/primitives/router/src/inbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ where
// This `SetAppendix` ensures that `xcm_fee` not spent by `Transact` will be
// deposited to snowbridge sovereign, instead of being trapped, regardless of
// `Transact` success or not.
SetAppendix(Xcm(vec![
SetAppendix(Xcm::new(vec![
RefundSurplus,
DepositAsset { assets: AllCounted(1).into(), beneficiary: bridge_location },
])),
Expand Down Expand Up @@ -354,7 +354,7 @@ where
instructions.extend(vec![
// After program finishes deposit any leftover assets to the snowbridge
// sovereign.
SetAppendix(Xcm(vec![DepositAsset {
SetAppendix(Xcm::new(vec![DepositAsset {
assets: Wild(AllCounted(2)),
beneficiary: bridge_location,
}])),
Expand Down
2 changes: 1 addition & 1 deletion bridges/snowbridge/primitives/router/src/outbound/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ macro_rules! match_expression {
};
}

struct XcmConverter<'a, ConvertAssetId, Call> {
struct XcmConverter<'a, ConvertAssetId, Call: 'static> {
iter: Peekable<Iter<'a, Instruction<Call>>>,
ethereum_network: NetworkId,
agent_id: AgentId,
Expand Down
8 changes: 4 additions & 4 deletions bridges/snowbridge/runtime/test-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
};
let assets = vec![asset.clone()];

let inner_xcm = Xcm(vec![
let inner_xcm = Xcm::new(vec![
WithdrawAsset(Assets::from(assets.clone())),
ClearOrigin,
BuyExecution { fees: asset, weight_limit: Unlimited },
Expand All @@ -82,7 +82,7 @@ where
Asset { id: AssetId(Location { parents: 1, interior: Here }), fun: Fungible(fee_amount) };

// prepare transfer token message
let xcm = Xcm(vec![
let xcm = Xcm::new(vec![
WithdrawAsset(Assets::from(vec![fee.clone()])),
BuyExecution { fees: fee, weight_limit: Unlimited },
ExportMessage {
Expand Down Expand Up @@ -337,7 +337,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
};
let assets = vec![asset.clone()];

let inner_xcm = Xcm(vec![
let inner_xcm = Xcm::new(vec![
WithdrawAsset(Assets::from(assets.clone())),
ClearOrigin,
BuyExecution { fees: asset, weight_limit: Unlimited },
Expand All @@ -352,7 +352,7 @@ pub fn send_unpaid_transfer_token_message<Runtime, XcmConfig>(
]);

// prepare transfer token message
let xcm = Xcm(vec![
let xcm = Xcm::new(vec![
UnpaidExecution { weight_limit: Unlimited, check_origin: None },
ExportMessage {
network: Ethereum { chain_id: ethereum_chain_id },
Expand Down
42 changes: 21 additions & 21 deletions cumulus/pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl SendXcm for OkFixedXcmHashWithAssertingRequiredInputsSender {
#[test]
fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
// dummy message
let message = Xcm(vec![Trap(5)]);
let message = Xcm::new(vec![Trap(5)]);

// XcmpQueue - check dest is really not applicable
let dest = (Parent, Parent, Parent);
Expand Down Expand Up @@ -390,7 +390,7 @@ fn xcmp_queue_does_not_consume_dest_or_msg_on_not_applicable() {
#[test]
fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
// dummy message
let message = Xcm(vec![Trap(5)]);
let message = Xcm::new(vec![Trap(5)]);

// XcmpQueue - check dest/msg is valid
let dest: Location = (Parent, Parachain(5555)).into();
Expand Down Expand Up @@ -419,9 +419,9 @@ fn xcmp_queue_consumes_dest_and_msg_on_ok_validate() {
fn xcmp_queue_validate_nested_xcm_works() {
let dest = (Parent, Parachain(5555));
// Message that is not too deeply nested:
let mut good = Xcm(vec![ClearOrigin]);
let mut good = Xcm::new(vec![ClearOrigin]);
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
good = Xcm::new(vec![SetAppendix(good)]);
}

new_test_ext().execute_with(|| {
Expand All @@ -432,7 +432,7 @@ fn xcmp_queue_validate_nested_xcm_works() {
));

// Nesting the message one more time should reject it:
let bad = Xcm(vec![SetAppendix(good)]);
let bad = Xcm::new(vec![SetAppendix(good)]);
assert_eq!(
Err(SendError::ExceedsMaxMessageSize),
<XcmpQueue as SendXcm>::validate(&mut Some(dest.into()), &mut Some(bad))
Expand All @@ -444,9 +444,9 @@ fn xcmp_queue_validate_nested_xcm_works() {
fn send_xcm_nested_works() {
let dest = (Parent, Parachain(HRMP_PARA_ID));
// Message that is not too deeply nested:
let mut good = Xcm(vec![ClearOrigin]);
let mut good = Xcm::new(vec![ClearOrigin]);
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
good = Xcm::new(vec![SetAppendix(good)]);
}

// Check that the good message is sent:
Expand All @@ -463,7 +463,7 @@ fn send_xcm_nested_works() {
});

// Nesting the message one more time should not send it:
let bad = Xcm(vec![SetAppendix(good)]);
let bad = Xcm::new(vec![SetAppendix(good)]);
new_test_ext().execute_with(|| {
assert_err!(send_xcm::<XcmpQueue>(dest.into(), bad), SendError::ExceedsMaxMessageSize);
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
Expand All @@ -472,7 +472,7 @@ fn send_xcm_nested_works() {

#[test]
fn hrmp_signals_are_prioritized() {
let message = Xcm(vec![Trap(5)]);
let message = Xcm::new(vec![Trap(5)]);

let sibling_para_id = ParaId::from(12345);
let dest = (Parent, Parachain(sibling_para_id.into()));
Expand Down Expand Up @@ -596,7 +596,7 @@ fn take_first_concatenated_xcm_works() {
fn take_first_concatenated_xcm_good_recursion_depth_works() {
let mut good = Xcm::<()>(vec![ClearOrigin]);
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
good = Xcm::new(vec![SetAppendix(good)]);
}
let good = VersionedXcm::from(good);

Expand All @@ -609,7 +609,7 @@ fn take_first_concatenated_xcm_good_recursion_depth_works() {
fn take_first_concatenated_xcm_good_bad_depth_errors() {
let mut bad = Xcm::<()>(vec![ClearOrigin]);
for _ in 0..MAX_XCM_DECODE_DEPTH {
bad = Xcm(vec![SetAppendix(bad)]);
bad = Xcm::new(vec![SetAppendix(bad)]);
}
let bad = VersionedXcm::from(bad);

Expand Down Expand Up @@ -708,7 +708,7 @@ fn xcmp_queue_send_xcm_works() {
new_test_ext().execute_with(|| {
let sibling_para_id = ParaId::from(12345);
let dest: Location = (Parent, Parachain(sibling_para_id.into())).into();
let msg = Xcm(vec![ClearOrigin]);
let msg = Xcm::new(vec![ClearOrigin]);

// try to send without opened HRMP channel to the sibling_para_id
assert_eq!(
Expand Down Expand Up @@ -783,7 +783,7 @@ fn verify_fee_factor_increase_and_decrease() {

let sibling_para_id = ParaId::from(12345);
let destination: Location = (Parent, Parachain(sibling_para_id.into())).into();
let xcm = Xcm(vec![ClearOrigin; 100]);
let xcm = Xcm::new(vec![ClearOrigin; 100]);
let versioned_xcm = VersionedXcm::from(xcm.clone());
let mut xcmp_message = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
xcmp_message.extend(versioned_xcm.encode());
Expand Down Expand Up @@ -821,7 +821,7 @@ fn verify_fee_factor_increase_and_decrease() {
};
assert_eq!(delivery_fee_amount, 402_000_000);

let smaller_xcm = Xcm(vec![ClearOrigin; 30]);
let smaller_xcm = Xcm::new(vec![ClearOrigin; 30]);

// When we get to half of `max_total_size`, because `THRESHOLD_FACTOR` is 2,
// then the fee factor starts to increase.
Expand Down Expand Up @@ -861,7 +861,7 @@ fn get_messages_works() {
let destination: Location = (Parent, Parachain(sibling_para_id.into())).into();
let other_sibling_para_id = ParaId::from(2002);
let other_destination: Location = (Parent, Parachain(other_sibling_para_id.into())).into();
let message = Xcm(vec![ClearOrigin]);
let message = Xcm::new(vec![ClearOrigin]);
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), message.clone()));
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), message.clone()));
assert_ok!(send_xcm::<XcmpQueue>(destination.clone(), message.clone()));
Expand All @@ -875,16 +875,16 @@ fn get_messages_works() {
(
VersionedLocation::from(other_destination),
vec![
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm::new(vec![ClearOrigin])),
VersionedXcm::from(Xcm::new(vec![ClearOrigin])),
],
),
(
VersionedLocation::from(destination),
vec![
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm(vec![ClearOrigin])),
VersionedXcm::from(Xcm::new(vec![ClearOrigin])),
VersionedXcm::from(Xcm::new(vec![ClearOrigin])),
VersionedXcm::from(Xcm::new(vec![ClearOrigin])),
],
),
],
Expand All @@ -901,7 +901,7 @@ fn page_not_modified_when_fragment_does_not_fit() {
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(sibling);

let destination: Location = (Parent, Parachain(sibling.into())).into();
let message = Xcm(vec![ClearOrigin; 600]);
let message = Xcm::new(vec![ClearOrigin; 600]);

loop {
let old_page_zero = OutboundXcmpMessages::<Test>::get(sibling, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn xcm_transact_paid_execution(
) -> VersionedXcm<()> {
let weight_limit = WeightLimit::Unlimited;

VersionedXcm::from(Xcm(vec![
VersionedXcm::from(Xcm::new(vec![
WithdrawAsset(fees.clone().into()),
BuyExecution { fees, weight_limit },
Transact { origin_kind, call, fallback_max_weight: None },
Expand All @@ -51,7 +51,7 @@ pub fn xcm_transact_unpaid_execution(
let weight_limit = WeightLimit::Unlimited;
let check_origin = None;

VersionedXcm::from(Xcm(vec![
VersionedXcm::from(Xcm::new(vec![
UnpaidExecution { weight_limit, check_origin },
Transact { origin_kind, call, fallback_max_weight: None },
]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ fn reserve_withdraw_from_untrusted_reserve_fails() {

// this should also fail
AssetHubRococo::execute_with(|| {
let xcm: Xcm<asset_hub_rococo_runtime::RuntimeCall> = Xcm(vec![
let xcm: Xcm<asset_hub_rococo_runtime::RuntimeCall> = Xcm::new(vec![
WithdrawAsset(assets.into()),
InitiateReserveWithdraw {
assets: Wild(All),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fn teleport_to_untrusted_chain_fails() {

// this should also fail
AssetHubRococo::execute_with(|| {
let xcm: Xcm<asset_hub_rococo_runtime::RuntimeCall> = Xcm(vec![
let xcm: Xcm<asset_hub_rococo_runtime::RuntimeCall> = Xcm::new(vec![
WithdrawAsset(assets.into()),
InitiateTeleport { assets: Wild(All), dest: destination, xcm: Xcm::<()>::new() },
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fn multi_hop_works() {

// We get them from the PenpalA closure.
let mut delivery_fees_amount = 0;
let mut remote_message = VersionedXcm::from(Xcm(Vec::new()));
let mut remote_message = VersionedXcm::from(Xcm::new(vec::new()));
<PenpalA as TestExt>::execute_with(|| {
type Runtime = <PenpalA as Chain>::Runtime;
type OriginCaller = <PenpalA as Chain>::OriginCaller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ fn bidirectional_transfer_multiple_assets_between_penpal_and_asset_hub() {
fees.fun = Fungible(fees_amount / 2);
}
// xcm to be executed at dest
let xcm_on_dest = Xcm(vec![
let xcm_on_dest = Xcm::new(vec![
// since this is the last hop, we don't need to further use any assets previously
// reserved for fees (there are no further hops to cover delivery fees for); we
// RefundSurplus to get back any unspent fees
Expand Down Expand Up @@ -1008,7 +1008,7 @@ fn bidirectional_transfer_multiple_assets_between_penpal_and_asset_hub() {
fees.fun = Fungible(fees_amount / 2);
}
// xcm to be executed at dest
let xcm_on_dest = Xcm(vec![
let xcm_on_dest = Xcm::new(vec![
// since this is the last hop, we don't need to further use any assets previously
// reserved for fees (there are no further hops to cover delivery fees for); we
// RefundSurplus to get back any unspent fees
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ fn reserve_withdraw_from_untrusted_reserve_fails() {

// this should also fail
AssetHubWestend::execute_with(|| {
let xcm: Xcm<asset_hub_westend_runtime::RuntimeCall> = Xcm(vec![
let xcm: Xcm<asset_hub_westend_runtime::RuntimeCall> = Xcm::new(vec![
WithdrawAsset(assets.into()),
InitiateReserveWithdraw {
assets: Wild(All),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ fn teleport_to_untrusted_chain_fails() {

// this should also fail
AssetHubWestend::execute_with(|| {
let xcm: Xcm<asset_hub_westend_runtime::RuntimeCall> = Xcm(vec![
let xcm: Xcm<asset_hub_westend_runtime::RuntimeCall> = Xcm::new(vec![
WithdrawAsset(assets.into()),
InitiateTeleport { assets: Wild(All), dest: destination, xcm: Xcm::<()>::new() },
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn transfer_and_transact_in_same_xcm(
let usdt_to_ah_then_onward: Asset = (usdt.id.clone(), usdt_to_ah_then_onward_amount).into();

// xcm to be executed at dest
let xcm_on_dest = Xcm(vec![
let xcm_on_dest = Xcm::new(vec![
Transact { origin_kind: OriginKind::Xcm, call, fallback_max_weight: None },
ExpectTransactStatus(MaybeErrorCode::Success),
// since this is the last hop, we don't need to further use any assets previously
Expand All @@ -52,7 +52,7 @@ fn transfer_and_transact_in_same_xcm(
DepositAsset { assets: Wild(All), beneficiary },
]);
let destination = destination.reanchored(&asset_hub_location, &context).unwrap();
let xcm_on_ah = Xcm(vec![InitiateTransfer {
let xcm_on_ah = Xcm::new(vec![InitiateTransfer {
destination,
remote_fees: Some(AssetTransferFilter::ReserveDeposit(Wild(All))),
preserve_origin: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn multi_hop_works() {

// We get them from the PenpalA closure.
let mut delivery_fees_amount = 0;
let mut remote_message = VersionedXcm::from(Xcm(Vec::new()));
let mut remote_message = VersionedXcm::from(Xcm::new(vec::new()));
<PenpalA as TestExt>::execute_with(|| {
type Runtime = <PenpalA as Chain>::Runtime;
type OriginCaller = <PenpalA as Chain>::OriginCaller;
Expand Down
Loading
Loading