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

Deprecate XCMv2 #4131

Merged
merged 28 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
29790dc
feat(xcm-v2): add deprecation warnings
franciscoaguirre Apr 15, 2024
25b1654
Merge branch 'master' into deprecate-xcm-v2
franciscoaguirre May 23, 2024
e9cac9f
feat: just deprecate whole v2 module
franciscoaguirre May 23, 2024
aa09756
doc: prdoc
franciscoaguirre May 23, 2024
adde6be
Merge branch 'master' into deprecate-xcm-v2
franciscoaguirre May 23, 2024
e95aa65
fix: fmt
franciscoaguirre May 23, 2024
120accf
fix: change tests that used v2 and v3 to use v3 and v4
franciscoaguirre May 23, 2024
0c1827c
Merge branch 'master' into deprecate-xcm-v2
franciscoaguirre May 23, 2024
7cd9352
fix: fmt
franciscoaguirre May 23, 2024
1bf5fa9
fix: change v2 to v3 in benchmarks
franciscoaguirre May 23, 2024
c6148db
doc: update prdoc with more crate bumps
franciscoaguirre May 23, 2024
8dbe0cb
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
9ccc37f
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
d049685
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
7a4cd57
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
3e01c8a
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
cec84ae
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
3f0414f
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
b2f1291
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
45a1a2e
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
0c56171
Update cumulus/parachains/integration-tests/emulated/tests/bridges/br…
franciscoaguirre May 24, 2024
4ccedb5
Update polkadot/xcm/pallet-xcm/src/benchmarking.rs
franciscoaguirre May 24, 2024
2e1b596
Update polkadot/xcm/pallet-xcm/src/benchmarking.rs
franciscoaguirre May 24, 2024
29ed18c
Update polkadot/xcm/pallet-xcm/src/benchmarking.rs
franciscoaguirre May 24, 2024
21f60dd
chore(xcmp-queue): use latest and older instead of hardcoding versions
franciscoaguirre May 24, 2024
5e8501f
fix(pallet-xcm::benchmarking): go back to creating a bad location
franciscoaguirre May 24, 2024
fdbd578
Merge branch 'master' into deprecate-xcm-v2
franciscoaguirre May 24, 2024
8307f81
fix: fmt
franciscoaguirre May 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
14 changes: 7 additions & 7 deletions cumulus/pallets/xcmp-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ pub(crate) fn mk_page() -> Vec<u8> {

for i in 0..100 {
page.extend(match i % 2 {
0 => v2_xcm().encode(),
1 => v3_xcm().encode(),
0 => v3_xcm().encode(),
1 => v4_xcm().encode(),
// We cannot push an undecodable XCM here since it would break the decode stream.
// This is expected and the whole reason to introduce `MaybeDoubleEncodedVersionedXcm`
// instead.
Expand All @@ -337,12 +337,12 @@ pub(crate) fn mk_page() -> Vec<u8> {
page
}

pub(crate) fn v2_xcm() -> VersionedXcm<()> {
let instr = xcm::v2::Instruction::<()>::ClearOrigin;
VersionedXcm::V2(xcm::v2::Xcm::<()>(vec![instr; 3]))
}

pub(crate) fn v3_xcm() -> VersionedXcm<()> {
let instr = xcm::v3::Instruction::<()>::Trap(1);
VersionedXcm::V3(xcm::v3::Xcm::<()>(vec![instr; 3]))
}

pub(crate) fn v4_xcm() -> VersionedXcm<()> {
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
let instr = xcm::v4::Instruction::<()>::Trap(1);
VersionedXcm::V4(xcm::v4::Xcm::<()>(vec![instr; 3]))
}
12 changes: 6 additions & 6 deletions cumulus/pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.

use super::{
mock::{mk_page, v2_xcm, v3_xcm, EnqueuedMessages, HRMP_PARA_ID},
mock::{mk_page, v3_xcm, v4_xcm, EnqueuedMessages, HRMP_PARA_ID},
*,
};
use XcmpMessageFormat::*;
Expand Down Expand Up @@ -536,8 +536,8 @@ fn hrmp_signals_are_prioritized() {
#[test]
fn maybe_double_encoded_versioned_xcm_works() {
// pre conditions
assert_eq!(VersionedXcm::<()>::V2(Default::default()).encode(), &[2, 0]);
assert_eq!(VersionedXcm::<()>::V3(Default::default()).encode(), &[3, 0]);
assert_eq!(VersionedXcm::<()>::V4(Default::default()).encode(), &[4, 0]);
}

// Now also testing a page instead of just concat messages.
Expand All @@ -550,10 +550,10 @@ fn maybe_double_encoded_versioned_xcm_decode_page_works() {
for i in 0..100 {
match (i % 2, VersionedXcm::<()>::decode(input)) {
(0, Ok(xcm)) => {
assert_eq!(xcm, v2_xcm());
assert_eq!(xcm, v3_xcm());
},
(1, Ok(xcm)) => {
assert_eq!(xcm, v3_xcm());
assert_eq!(xcm, v4_xcm());
},
unexpected => unreachable!("{:?}", unexpected),
}
Expand All @@ -572,10 +572,10 @@ fn take_first_concatenated_xcm_works() {
let xcm = XcmpQueue::take_first_concatenated_xcm(input, &mut WeightMeter::new()).unwrap();
match (i % 2, xcm) {
(0, data) | (2, data) => {
assert_eq!(data, v2_xcm().encode());
assert_eq!(data, v3_xcm().encode());
},
(1, data) | (3, data) => {
assert_eq!(data, v3_xcm().encode());
assert_eq!(data, v4_xcm().encode());
},
unexpected => unreachable!("{:?}", unexpected),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ fn send_xcm_from_rococo_relay_to_westend_asset_hub_should_fail_on_not_applicable
#[test]
fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// Initially set only default version on all runtimes
AssetHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
AssetHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
AssetHubRococo::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
AssetHubWestend::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved

// prepare data
let destination = asset_hub_westend_location();
Expand All @@ -87,42 +87,12 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
);

// set destination version
AssetHubRococo::force_xcm_version(destination.clone(), xcm::v3::prelude::XCM_VERSION);

// TODO: remove this block, when removing `xcm:v2`
{
// send XCM from AssetHubRococo - fails - AssetHubRococo is set to the default/safe `2`
// version, which does not have the `ExportMessage` instruction. If the default `2` is
// changed to `3`, then this assert can go away"
assert_err!(
send_asset_from_asset_hub_rococo(destination.clone(), (native_token.clone(), amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);

// set exact version for BridgeHubWestend to `2` without `ExportMessage` instruction
AssetHubRococo::force_xcm_version(
ParentThen(Parachain(BridgeHubRococo::para_id().into()).into()).into(),
xcm::v2::prelude::XCM_VERSION,
);
// send XCM from AssetHubRococo - fails - `ExportMessage` is not in `2`
assert_err!(
send_asset_from_asset_hub_rococo(destination.clone(), (native_token.clone(), amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
}
AssetHubRococo::force_xcm_version(destination.clone(), xcm::v4::prelude::XCM_VERSION);
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved

// set version with `ExportMessage` for BridgeHubRococo
AssetHubRococo::force_xcm_version(
ParentThen(Parachain(BridgeHubRococo::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
xcm::v4::prelude::XCM_VERSION,
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
);
// send XCM from AssetHubRococo - ok
assert_ok!(send_asset_from_asset_hub_rococo(
Expand All @@ -136,12 +106,12 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// set version for remote BridgeHub on BridgeHubRococo
BridgeHubRococo::force_xcm_version(
bridge_hub_westend_location(),
xcm::v3::prelude::XCM_VERSION,
xcm::v4::prelude::XCM_VERSION,
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
);
// set version for AssetHubWestend on BridgeHubWestend
BridgeHubWestend::force_xcm_version(
ParentThen(Parachain(AssetHubWestend::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
xcm::v4::prelude::XCM_VERSION,
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
);

// send XCM from AssetHubRococo - ok
Expand All @@ -164,20 +134,4 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
]
);
});

// TODO: remove this block, when removing `xcm:v2`
{
// set `2` version for remote BridgeHub on BridgeHubRococo, which does not have
// `UniversalOrigin` and `DescendOrigin`
BridgeHubRococo::force_xcm_version(
bridge_hub_westend_location(),
xcm::v2::prelude::XCM_VERSION,
);

// send XCM from AssetHubRococo - ok
assert_ok!(send_asset_from_asset_hub_rococo(destination, (native_token, amount)));
// message is not accepted on the local BridgeHub (`DestinationUnsupported`) because we
// cannot add `UniversalOrigin` and `DescendOrigin`
assert_bridge_hub_rococo_message_accepted(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ fn send_xcm_from_westend_relay_to_rococo_asset_hub_should_fail_on_not_applicable
#[test]
fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// Initially set only default version on all runtimes
AssetHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
AssetHubWestend::force_default_xcm_version(Some(xcm::v2::prelude::XCM_VERSION));
AssetHubRococo::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
BridgeHubRococo::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
BridgeHubWestend::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
AssetHubWestend::force_default_xcm_version(Some(xcm::v3::prelude::XCM_VERSION));
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved

// prepare data
let destination = asset_hub_rococo_location();
Expand All @@ -87,42 +87,12 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
);

// set destination version
AssetHubWestend::force_xcm_version(destination.clone(), xcm::v3::prelude::XCM_VERSION);

// TODO: remove this block, when removing `xcm:v2`
{
// send XCM from AssetHubRococo - fails - AssetHubRococo is set to the default/safe `2`
// version, which does not have the `ExportMessage` instruction. If the default `2` is
// changed to `3`, then this assert can go away"
assert_err!(
send_asset_from_asset_hub_westend(destination.clone(), (native_token.clone(), amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);

// set exact version for BridgeHubWestend to `2` without `ExportMessage` instruction
AssetHubWestend::force_xcm_version(
ParentThen(Parachain(BridgeHubWestend::para_id().into()).into()).into(),
xcm::v2::prelude::XCM_VERSION,
);
// send XCM from AssetHubWestend - fails - `ExportMessage` is not in `2`
assert_err!(
send_asset_from_asset_hub_westend(destination.clone(), (native_token.clone(), amount)),
DispatchError::Module(sp_runtime::ModuleError {
index: 31,
error: [1, 0, 0, 0],
message: Some("SendFailure")
})
);
}
AssetHubWestend::force_xcm_version(destination.clone(), xcm::v4::prelude::XCM_VERSION);
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved

// set version with `ExportMessage` for BridgeHubWestend
AssetHubWestend::force_xcm_version(
ParentThen(Parachain(BridgeHubWestend::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
xcm::v4::prelude::XCM_VERSION,
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
);
// send XCM from AssetHubWestend - ok
assert_ok!(send_asset_from_asset_hub_westend(
Expand All @@ -136,12 +106,12 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
// set version for remote BridgeHub on BridgeHubWestend
BridgeHubWestend::force_xcm_version(
bridge_hub_rococo_location(),
xcm::v3::prelude::XCM_VERSION,
xcm::v4::prelude::XCM_VERSION,
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
);
// set version for AssetHubRococo on BridgeHubRococo
BridgeHubRococo::force_xcm_version(
ParentThen(Parachain(AssetHubRococo::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
xcm::v4::prelude::XCM_VERSION,
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
);

// send XCM from AssetHubWestend - ok
Expand All @@ -164,20 +134,4 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
]
);
});

// TODO: remove this block, when removing `xcm:v2`
{
// set `2` version for remote BridgeHub on BridgeHubRococo, which does not have
// `UniversalOrigin` and `DescendOrigin`
BridgeHubWestend::force_xcm_version(
bridge_hub_rococo_location(),
xcm::v2::prelude::XCM_VERSION,
);

// send XCM from AssetHubWestend - ok
assert_ok!(send_asset_from_asset_hub_westend(destination, (native_token, amount)));
// message is not accepted on the local BridgeHub (`DestinationUnsupported`) because we
// cannot add `UniversalOrigin` and `DescendOrigin`
assert_bridge_hub_westend_message_accepted(false);
}
}
12 changes: 5 additions & 7 deletions polkadot/xcm/pallet-xcm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use super::*;
use bounded_collections::{ConstU32, WeakBoundedVec};
use frame_benchmarking::{benchmarks, whitelisted_caller, BenchmarkError, BenchmarkResult};
use frame_support::{assert_ok, weights::Weight};
use frame_system::RawOrigin;
use sp_std::prelude::*;
use xcm::{latest::prelude::*, v2};
use xcm::{latest::prelude::*, v3};
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
use xcm_builder::EnsureDelivery;
use xcm_executor::traits::FeeReason;

Expand Down Expand Up @@ -313,13 +312,12 @@ benchmarks! {
}

notify_target_migration_fail {
let bad_loc: v2::MultiLocation = v2::Junction::Plurality {
id: v2::BodyId::Named(WeakBoundedVec::<u8, ConstU32<32>>::try_from(vec![0; 32])
.expect("vec has a length of 32 bits; qed")),
part: v2::BodyPart::Voice,
let bad_loc: v3::Location = v3::Junction::Plurality {
id: v3::BodyId::Unit,
part: v3::BodyPart::Voice,
}
.into();
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
let bad_loc = VersionedLocation::from(bad_loc);
let bad_loc = VersionedLocation::V3(bad_loc);
let current_version = T::AdvertisedXcmVersion::get();
VersionNotifyTargets::<T>::insert(current_version, bad_loc, (0, Weight::zero(), current_version));
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
}: {
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/pallet-xcm/src/tests/assets_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn limited_teleport_assets_works() {
)]
);
let versioned_sent = VersionedXcm::from(sent_xcm().into_iter().next().unwrap().1);
let _check_v2_ok: xcm::v2::Xcm<()> = versioned_sent.try_into().unwrap();
let _check_v3_ok: xcm::v3::Xcm<()> = versioned_sent.try_into().unwrap();

let mut last_events = last_events(3).into_iter();
assert_eq!(
Expand Down
Loading
Loading