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

Update foreign asset ids from v3 to v4 #472

Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Changelog for the runtimes governed by the Polkadot Fellowship.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

- Update foreign asset ids in Asset Hub Polkadot and Asset Hub Kusama from v3 to v4 locations ([polkadot-fellows/runtimes#472](https://github.com/polkadot-fellows/runtimes/pull/472))

## [1.3.3] 01.10.2024

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ impl_accounts_helpers_for_parachain!(AssetHubKusama);
impl_assert_events_helpers_for_parachain!(AssetHubKusama);
impl_assets_helpers_for_system_parachain!(AssetHubKusama, Kusama);
impl_assets_helpers_for_parachain!(AssetHubKusama);
impl_foreign_assets_helpers_for_parachain!(AssetHubKusama, xcm::v3::Location);
impl_foreign_assets_helpers_for_parachain!(AssetHubKusama, xcm::v4::Location);
impl_xcm_helpers_for_parachain!(AssetHubKusama);
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ impl_accounts_helpers_for_parachain!(AssetHubPolkadot);
impl_assert_events_helpers_for_parachain!(AssetHubPolkadot);
impl_assets_helpers_for_system_parachain!(AssetHubPolkadot, Polkadot);
impl_assets_helpers_for_parachain!(AssetHubPolkadot);
impl_foreign_assets_helpers_for_parachain!(AssetHubPolkadot, xcm::v3::Location);
impl_foreign_assets_helpers_for_parachain!(AssetHubPolkadot, xcm::v4::Location);
impl_xcm_helpers_for_parachain!(AssetHubPolkadot);
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use sp_runtime::traits::Dispatchable;
// Polkadot
pub use xcm::{
prelude::{AccountId32 as AccountId32Junction, *},
v3::{self, Error, NetworkId::Kusama as KusamaId},
v4::{self, Error, NetworkId::Kusama as KusamaId},
};
pub use xcm_executor::traits::TransferType;

Expand All @@ -41,7 +41,7 @@ pub use emulated_integration_tests_common::{
RelayChain as Relay, Test, TestArgs, TestContext, TestExt,
},
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, RESERVABLE_ASSET_ID, XCM_V3,
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, RESERVABLE_ASSET_ID, XCM_V4,
};
pub use integration_tests_helpers::{
test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() {
let para_sovereign_account = AssetHubKusama::sovereign_account_id_of(
AssetHubKusama::sibling_location_of(PenpalA::para_id()),
);
let asset_location_on_penpal = v3::Location::new(
let asset_location_on_penpal = v4::Location::new(
0,
[
v3::Junction::PalletInstance(ASSETS_PALLET_ID),
v3::Junction::GeneralIndex(ASSET_ID.into()),
v4::Junction::PalletInstance(ASSETS_PALLET_ID),
v4::Junction::GeneralIndex(ASSET_ID.into()),
],
);
let foreign_asset_at_asset_hub =
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
v4::Location::new(1, [v4::Junction::Parachain(PenpalA::para_id().into())])
.appended_with(asset_location_on_penpal)
.unwrap();

// Encoded `create_asset` call to be executed in AssetHub
let call = AssetHubKusama::create_foreign_asset_call(
foreign_asset_at_asset_hub,
foreign_asset_at_asset_hub.clone(),
ASSET_MIN_BALANCE,
para_sovereign_account.clone(),
);
Expand Down Expand Up @@ -97,7 +97,7 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() {
},
// Foreign Asset created
RuntimeEvent::ForeignAssets(pallet_assets::Event::Created { asset_id, creator, owner }) => {
asset_id: *asset_id == foreign_asset_at_asset_hub,
asset_id: *asset_id == foreign_asset_at_asset_hub.clone(),
creator: *creator == para_sovereign_account.clone(),
owner: *owner == para_sovereign_account,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn relay_sets_system_para_xcm_supported_version() {
assert_ok!(<Kusama as KusamaPallet>::XcmPallet::force_xcm_version(
sudo_origin,
bx!(system_para_destination.clone()),
XCM_V3
XCM_V4
));

type RuntimeEvent = <Kusama as Chain>::RuntimeEvent;
Expand All @@ -36,7 +36,7 @@ fn relay_sets_system_para_xcm_supported_version() {
vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {
location,
version: XCM_V3
version: XCM_V4
}) => { location: *location == system_para_destination, },
]
);
Expand All @@ -52,7 +52,7 @@ fn system_para_sets_relay_xcm_supported_version() {
<AssetHubKusama as Chain>::Runtime,
>::force_xcm_version {
location: bx!(parent_location.clone()),
version: XCM_V3,
version: XCM_V4,
})
.encode()
.into();
Expand All @@ -74,7 +74,7 @@ fn system_para_sets_relay_xcm_supported_version() {
vec![
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {
location,
version: XCM_V3
version: XCM_V4
}) => { location: *location == parent_location, },
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ use system_parachains_constants::kusama::currency::SYSTEM_PARA_EXISTENTIAL_DEPOS
#[test]
fn swap_locally_on_chain_using_local_assets() {
let asset_native = Box::new(
v3::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get())
v4::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get())
.expect("conversion works"),
);
let asset_one = Box::new(v3::Location::new(
let asset_one = Box::new(v4::Location::new(
0,
[
v3::Junction::PalletInstance(ASSETS_PALLET_ID),
v3::Junction::GeneralIndex(ASSET_ID.into()),
v4::Junction::PalletInstance(ASSETS_PALLET_ID),
v4::Junction::GeneralIndex(ASSET_ID.into()),
],
));

Expand Down Expand Up @@ -120,13 +120,13 @@ fn swap_locally_on_chain_using_local_assets() {
#[test]
fn swap_locally_on_chain_using_foreign_assets() {
let asset_native = Box::new(
v3::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get())
v4::Location::try_from(asset_hub_kusama_runtime::xcm_config::KsmLocation::get())
.expect("conversion works"),
);
let asset_location_on_penpal =
v3::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works");
v4::Location::try_from(PenpalLocalTeleportableToAssetHub::get()).expect("conversion works");
let foreign_asset_at_asset_hub_kusama =
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
v4::Location::new(1, [v4::Junction::Parachain(PenpalA::para_id().into())])
.appended_with(asset_location_on_penpal)
.unwrap();

Expand All @@ -151,7 +151,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
// 3. Mint foreign asset (in reality this should be a teleport or some such)
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::ForeignAssets::mint(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()),
foreign_asset_at_asset_hub_kusama,
foreign_asset_at_asset_hub_kusama.clone(),
sov_penpal_on_ahk.clone().into(),
ASSET_HUB_KUSAMA_ED * 3_000_000_000_000,
));
Expand All @@ -167,7 +167,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::create_pool(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
asset_native.clone(),
Box::new(foreign_asset_at_asset_hub_kusama),
Box::new(foreign_asset_at_asset_hub_kusama.clone()),
));

assert_expected_events!(
Expand All @@ -181,7 +181,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::add_liquidity(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(sov_penpal_on_ahk.clone()),
asset_native.clone(),
Box::new(foreign_asset_at_asset_hub_kusama),
Box::new(foreign_asset_at_asset_hub_kusama.clone()),
1_000_000_000_000,
2_000_000_000_000,
0,
Expand All @@ -199,7 +199,7 @@ fn swap_locally_on_chain_using_foreign_assets() {
);

// 6. Swap!
let path = vec![asset_native.clone(), Box::new(foreign_asset_at_asset_hub_kusama)];
let path = vec![asset_native.clone(), Box::new(foreign_asset_at_asset_hub_kusama.clone())];

assert_ok!(
<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::swap_exact_tokens_for_tokens(
Expand Down Expand Up @@ -277,14 +277,14 @@ fn cannot_create_pool_from_pool_assets() {

#[test]
fn pay_xcm_fee_with_some_asset_swapped_for_native() {
let asset_native: xcm::v3::Location = asset_hub_kusama_runtime::xcm_config::KsmLocation::get()
let asset_native: xcm::v4::Location = asset_hub_kusama_runtime::xcm_config::KsmLocation::get()
.try_into()
.expect("conversion works");
let asset_one = xcm::v3::Location {
let asset_one = xcm::v4::Location {
parents: 0,
interior: [
xcm::v3::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v3::Junction::GeneralIndex(ASSET_ID.into()),
xcm::v4::Junction::PalletInstance(ASSETS_PALLET_ID),
xcm::v4::Junction::GeneralIndex(ASSET_ID.into()),
]
.into(),
};
Expand Down Expand Up @@ -313,8 +313,8 @@ fn pay_xcm_fee_with_some_asset_swapped_for_native() {

assert_ok!(<AssetHubKusama as AssetHubKusamaPallet>::AssetConversion::create_pool(
<AssetHubKusama as Chain>::RuntimeOrigin::signed(AssetHubKusamaSender::get()),
Box::new(asset_native),
Box::new(asset_one),
Box::new(asset_native.clone()),
Box::new(asset_one.clone()),
));

assert_expected_events!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
);
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
let expected_foreign_asset_id_v3: v3::Location = expected_foreign_asset_id.try_into().unwrap();

AssetHubKusama::assert_xcmp_queue_success(None);
assert_expected_events!(
Expand All @@ -103,7 +102,7 @@ fn penpal_to_ah_foreign_assets_receiver_assertions(t: ParaToSystemParaTest) {
who: *who == t.receiver.account_id,
},
RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { asset_id, owner, amount }) => {
asset_id: *asset_id == expected_foreign_asset_id_v3,
asset_id: *asset_id == expected_foreign_asset_id,
owner: *owner == t.receiver.account_id,
amount: *amount == expected_foreign_asset_amount,
},
Expand All @@ -117,7 +116,6 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
AssetHubKusama::assert_xcm_pallet_attempted_complete(None);
let (expected_foreign_asset_id, expected_foreign_asset_amount) =
non_fee_asset(&t.args.assets, t.args.fee_asset_item as usize).unwrap();
let expected_foreign_asset_id_v3: v3::Location = expected_foreign_asset_id.try_into().unwrap();
assert_expected_events!(
AssetHubKusama,
vec![
Expand All @@ -133,7 +131,7 @@ fn ah_to_penpal_foreign_assets_sender_assertions(t: SystemParaToParaTest) {
},
// foreign asset is burned locally as part of teleportation
RuntimeEvent::ForeignAssets(pallet_assets::Event::Burned { asset_id, owner, balance }) => {
asset_id: *asset_id == expected_foreign_asset_id_v3,
asset_id: *asset_id == expected_foreign_asset_id,
owner: *owner == t.sender.account_id,
balance: *balance == expected_foreign_asset_amount,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ fn create_and_claim_treasury_spend_in_usdt() {
)
.unwrap();
let asset_hub_location =
v3::Location::new(0, v3::Junction::Parachain(AssetHubKusama::para_id().into()));
v4::Location::new(0, v4::Junction::Parachain(AssetHubKusama::para_id().into()));
let root = <Kusama as Chain>::RuntimeOrigin::root();
// asset kind to be spend from the treasury.
let asset_kind = VersionedLocatableAsset::V3 {
let asset_kind = VersionedLocatableAsset::V4 {
location: asset_hub_location,
asset_id: v3::AssetId::Concrete(
(v3::Junction::PalletInstance(50), v3::Junction::GeneralIndex(USDT_ID.into())).into(),
asset_id: v4::AssetId(
(v4::Junction::PalletInstance(50), v4::Junction::GeneralIndex(USDT_ID.into())).into(),
),
};
// treasury spend beneficiary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use sp_runtime::traits::Dispatchable;
// Polkadot
pub use xcm::{
prelude::{AccountId32 as AccountId32Junction, *},
v3::{self, Error, NetworkId::Polkadot as PolkadotId},
v4::{self, Error, NetworkId::Polkadot as PolkadotId},
};
pub use xcm_executor::traits::TransferType;

Expand All @@ -43,7 +43,7 @@ pub use emulated_integration_tests_common::{
RelayChain as Relay, Test, TestArgs, TestContext, TestExt,
},
xcm_helpers::{xcm_transact_paid_execution, xcm_transact_unpaid_execution},
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3,
PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V4,
};
pub use integration_tests_helpers::{
test_parachain_is_trusted_teleporter_for_relay, test_relay_is_trusted_teleporter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ fn create_and_claim_treasury_spend_in_usdt() {
)
.unwrap();
let asset_hub_location =
v3::Location::new(1, v3::Junction::Parachain(AssetHubPolkadot::para_id().into()));
v4::Location::new(1, v4::Junction::Parachain(AssetHubPolkadot::para_id().into()));
let root = <CollectivesPolkadot as Chain>::RuntimeOrigin::root();
// asset kind to be spent from the treasury.
let asset_kind = VersionedLocatableAsset::V3 {
let asset_kind = VersionedLocatableAsset::V4 {
location: asset_hub_location,
asset_id: v3::AssetId::Concrete(
(v3::Junction::PalletInstance(50), v3::Junction::GeneralIndex(USDT_ID.into())).into(),
asset_id: v4::AssetId(
(v4::Junction::PalletInstance(50), v4::Junction::GeneralIndex(USDT_ID.into())).into(),
),
};
// treasury spend beneficiary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() {
let para_sovereign_account = AssetHubPolkadot::sovereign_account_id_of(
AssetHubPolkadot::sibling_location_of(PenpalA::para_id()),
);
let asset_location_on_penpal = v3::Location::new(
let asset_location_on_penpal = v4::Location::new(
0,
[
v3::Junction::PalletInstance(ASSETS_PALLET_ID),
v3::Junction::GeneralIndex(ASSET_ID.into()),
v4::Junction::PalletInstance(ASSETS_PALLET_ID),
v4::Junction::GeneralIndex(ASSET_ID.into()),
],
);
let foreign_asset_at_asset_hub =
v3::Location::new(1, [v3::Junction::Parachain(PenpalA::para_id().into())])
v4::Location::new(1, [v4::Junction::Parachain(PenpalA::para_id().into())])
.appended_with(asset_location_on_penpal)
.unwrap();

// Encoded `create_asset` call to be executed in AssetHub
let call = AssetHubPolkadot::create_foreign_asset_call(
foreign_asset_at_asset_hub,
foreign_asset_at_asset_hub.clone(),
ASSET_MIN_BALANCE,
para_sovereign_account.clone(),
);
Expand Down Expand Up @@ -97,7 +97,7 @@ fn send_xcm_from_para_to_asset_hub_paying_fee_with_system_asset() {
},
// Foreign Asset created
RuntimeEvent::ForeignAssets(pallet_assets::Event::Created { asset_id, creator, owner }) => {
asset_id: *asset_id == foreign_asset_at_asset_hub,
asset_id: *asset_id == foreign_asset_at_asset_hub.clone(),
creator: *creator == para_sovereign_account.clone(),
owner: *owner == para_sovereign_account,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn relay_sets_system_para_xcm_supported_version() {
assert_ok!(<Polkadot as PolkadotPallet>::XcmPallet::force_xcm_version(
sudo_origin,
bx!(system_para_destination.clone()),
XCM_V3
XCM_V4
));

type RuntimeEvent = <Polkadot as Chain>::RuntimeEvent;
Expand All @@ -37,7 +37,7 @@ fn relay_sets_system_para_xcm_supported_version() {
vec![
RuntimeEvent::XcmPallet(pallet_xcm::Event::SupportedVersionChanged {
location,
version: XCM_V3
version: XCM_V4
}) => { location: *location == system_para_destination, },
]
);
Expand All @@ -53,7 +53,7 @@ fn system_para_sets_relay_xcm_supported_version() {
<AssetHubPolkadot as Chain>::Runtime,
>::force_xcm_version {
location: bx!(parent_location.clone()),
version: XCM_V3,
version: XCM_V4,
})
.encode()
.into();
Expand All @@ -78,7 +78,7 @@ fn system_para_sets_relay_xcm_supported_version() {
vec![
RuntimeEvent::PolkadotXcm(pallet_xcm::Event::SupportedVersionChanged {
location,
version: XCM_V3
version: XCM_V4
}) => { location: *location == parent_location, },
]
);
Expand Down
Loading
Loading