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 all 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
20 changes: 10 additions & 10 deletions cumulus/pallets/xcmp-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,13 @@ impl GetChannelInfo for MockedChannelInfo {
pub(crate) fn mk_page() -> Vec<u8> {
let mut page = Vec::<u8>::new();

let newer_xcm_version = xcm::prelude::XCM_VERSION;
let older_xcm_version = newer_xcm_version - 1;

for i in 0..100 {
page.extend(match i % 2 {
0 => v2_xcm().encode(),
1 => v3_xcm().encode(),
0 => versioned_xcm(older_xcm_version).encode(),
1 => versioned_xcm(newer_xcm_version).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 @@ -335,12 +338,9 @@ 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 versioned_xcm(version: XcmVersion) -> VersionedXcm<()> {
let instr = Instruction::<()>::Trap(1);
VersionedXcm::from(Xcm::<()>(vec![instr; 3]))
.into_version(version)
.expect("Version conversion should work")
}
18 changes: 12 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, versioned_xcm, EnqueuedMessages, HRMP_PARA_ID},
*,
};
use XcmpMessageFormat::*;
Expand Down Expand Up @@ -536,24 +536,27 @@ 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.
#[test]
fn maybe_double_encoded_versioned_xcm_decode_page_works() {
let page = mk_page();

let newer_xcm_version = xcm::prelude::XCM_VERSION;
let older_xcm_version = newer_xcm_version - 1;

// Now try to decode the page.
let input = &mut &page[..];
for i in 0..100 {
match (i % 2, VersionedXcm::<()>::decode(input)) {
(0, Ok(xcm)) => {
assert_eq!(xcm, v2_xcm());
assert_eq!(xcm, versioned_xcm(older_xcm_version));
},
(1, Ok(xcm)) => {
assert_eq!(xcm, v3_xcm());
assert_eq!(xcm, versioned_xcm(newer_xcm_version));
},
unexpected => unreachable!("{:?}", unexpected),
}
Expand All @@ -568,14 +571,17 @@ fn take_first_concatenated_xcm_works() {
let page = mk_page();
let input = &mut &page[..];

let newer_xcm_version = xcm::prelude::XCM_VERSION;
let older_xcm_version = newer_xcm_version - 1;

for i in 0..100 {
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, versioned_xcm(older_xcm_version).encode());
},
(1, data) | (3, data) => {
assert_eq!(data, v3_xcm().encode());
assert_eq!(data, versioned_xcm(newer_xcm_version).encode());
},
unexpected => unreachable!("{:?}", unexpected),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ 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));
let newer_xcm_version = xcm::prelude::XCM_VERSION;
let older_xcm_version = newer_xcm_version - 1;

AssetHubRococo::force_default_xcm_version(Some(older_xcm_version));
BridgeHubRococo::force_default_xcm_version(Some(older_xcm_version));
BridgeHubWestend::force_default_xcm_version(Some(older_xcm_version));
AssetHubWestend::force_default_xcm_version(Some(older_xcm_version));

// prepare data
let destination = asset_hub_westend_location();
Expand All @@ -87,42 +90,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(), newer_xcm_version);

// set version with `ExportMessage` for BridgeHubRococo
AssetHubRococo::force_xcm_version(
ParentThen(Parachain(BridgeHubRococo::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
newer_xcm_version,
);
// send XCM from AssetHubRococo - ok
assert_ok!(send_asset_from_asset_hub_rococo(
Expand All @@ -134,14 +107,11 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
assert_bridge_hub_rococo_message_accepted(false);

// set version for remote BridgeHub on BridgeHubRococo
BridgeHubRococo::force_xcm_version(
bridge_hub_westend_location(),
xcm::v3::prelude::XCM_VERSION,
);
BridgeHubRococo::force_xcm_version(bridge_hub_westend_location(), newer_xcm_version);
// set version for AssetHubWestend on BridgeHubWestend
BridgeHubWestend::force_xcm_version(
ParentThen(Parachain(AssetHubWestend::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
newer_xcm_version,
);

// 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,13 @@ 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));
let newer_xcm_version = xcm::prelude::XCM_VERSION;
let older_xcm_version = newer_xcm_version - 1;

AssetHubRococo::force_default_xcm_version(Some(older_xcm_version));
BridgeHubRococo::force_default_xcm_version(Some(older_xcm_version));
BridgeHubWestend::force_default_xcm_version(Some(older_xcm_version));
AssetHubWestend::force_default_xcm_version(Some(older_xcm_version));

// prepare data
let destination = asset_hub_rococo_location();
Expand All @@ -87,42 +90,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(), newer_xcm_version);

// set version with `ExportMessage` for BridgeHubWestend
AssetHubWestend::force_xcm_version(
ParentThen(Parachain(BridgeHubWestend::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
newer_xcm_version,
);
// send XCM from AssetHubWestend - ok
assert_ok!(send_asset_from_asset_hub_westend(
Expand All @@ -134,14 +107,11 @@ fn send_xcm_through_opened_lane_with_different_xcm_version_on_hops_works() {
assert_bridge_hub_westend_message_accepted(false);

// set version for remote BridgeHub on BridgeHubWestend
BridgeHubWestend::force_xcm_version(
bridge_hub_rococo_location(),
xcm::v3::prelude::XCM_VERSION,
);
BridgeHubWestend::force_xcm_version(bridge_hub_rococo_location(), newer_xcm_version);
// set version for AssetHubRococo on BridgeHubRococo
BridgeHubRococo::force_xcm_version(
ParentThen(Parachain(AssetHubRococo::para_id().into()).into()).into(),
xcm::v3::prelude::XCM_VERSION,
newer_xcm_version,
);

// 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);
}
}
21 changes: 11 additions & 10 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::*;
use xcm_builder::EnsureDelivery;
use xcm_executor::traits::FeeReason;

Expand Down Expand Up @@ -313,15 +312,17 @@ 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,
}
.into();
let bad_loc = VersionedLocation::from(bad_loc);
let newer_xcm_version = xcm::prelude::XCM_VERSION;
let older_xcm_version = newer_xcm_version - 1;
let bad_location: Location = Plurality {
id: BodyId::Unit,
part: BodyPart::Voice,
}.into();
let bad_location = VersionedLocation::from(bad_location)
.into_version(older_xcm_version)
.expect("Version convertion should work");
let current_version = T::AdvertisedXcmVersion::get();
VersionNotifyTargets::<T>::insert(current_version, bad_loc, (0, Weight::zero(), current_version));
VersionNotifyTargets::<T>::insert(current_version, bad_location, (0, Weight::zero(), current_version));
}: {
crate::Pallet::<T>::check_xcm_version_change(VersionMigrationStage::MigrateAndNotifyOldTargets, Weight::zero());
}
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