Skip to content
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
aad8e1d
cherry-pick https://github.com/paritytech/polkadot-sdk/pull/9137
RomarQ Aug 21, 2025
5f15108
update Cargo.lock
RomarQ Aug 21, 2025
54b924f
Handle AssetHub location as Parent and Parent as AssetHub
RomarQ Aug 22, 2025
7997e48
add AssetHubLocation
RomarQ Aug 22, 2025
f66a3a6
add migration
RomarQ Aug 23, 2025
cf093c2
Revert "Handle AssetHub location as Parent and Parent as AssetHub"
RomarQ Aug 23, 2025
3bc843a
Revert "add AssetHubLocation"
RomarQ Aug 23, 2025
170f82c
fix migration
RomarQ Aug 23, 2025
f827594
fix runtime tests
RomarQ Aug 23, 2025
c50e8f6
Account extra read in migration
RomarQ Aug 23, 2025
0a0c6c1
speed up moonbase runtime tests
RomarQ Aug 23, 2025
883e8ea
client: mock egress channel with asset_hub
RomarQ Aug 23, 2025
51ade7d
Revert "client: mock egress channel with asset_hub"
RomarQ Aug 23, 2025
f30c691
fix typescript tests
RomarQ Aug 23, 2025
27560be
remove file
RomarQ Aug 24, 2025
8a210ad
Merge branch 'master' into rq/transfer-assets-fix
RomarQ Aug 25, 2025
9b965fb
test: ignore moonbase xcm tests
RomarQ Aug 25, 2025
ba8406f
test: ignore xcm_tests
RomarQ Aug 25, 2025
4819e9e
Add comments to the migration
RomarQ Aug 25, 2025
aa97cb9
Revert "test: ignore moonbase xcm tests"
RomarQ Aug 25, 2025
e27caeb
fix moonriver tests
RomarQ Aug 25, 2025
5ea2846
Revert "test: ignore xcm_tests"
RomarQ Aug 25, 2025
1c7ad08
fix xcm test
RomarQ Aug 25, 2025
8f87e8e
don't change xcDot Location, it is still used in many dapps
RomarQ Aug 28, 2025
afbf233
remove log activation in tests
RomarQ Aug 29, 2025
601f011
remove migration
RomarQ Aug 29, 2025
0fedd9e
Merge branch 'master' into rq/transfer-assets-fix
RomarQ Aug 29, 2025
1016734
fix lint errors
RomarQ Aug 29, 2025
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
601 changes: 301 additions & 300 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pallets/xcm-weight-trader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub mod pallet {
}

impl<T: Config> Pallet<T> {
fn do_add_asset(location: Location, relative_price: u128) -> DispatchResult {
pub fn do_add_asset(location: Location, relative_price: u128) -> DispatchResult {
ensure!(relative_price != 0, Error::<T>::PriceCannotBeZero);
ensure!(
!SupportedAssets::<T>::contains_key(&location),
Expand Down
8 changes: 8 additions & 0 deletions runtime/moonbase/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

//! # Moonbase specific Migrations

use crate::xcm_config::AssetType;
use moonbeam_core_primitives::AssetId;
use sp_core::parameter_types;

parameter_types! {
pub RelayAssetId: AssetId = AssetType::Xcm(xcm::v3::Location::parent()).into();
}

type MoonbaseMigrations = ();

/// List of single block migrations to be executed by frame executive.
Expand Down
28 changes: 23 additions & 5 deletions runtime/moonbase/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ use sp_consensus_slots::Slot;
use sp_core::{Encode, H160};
use sp_runtime::{traits::Dispatchable, BuildStorage, Digest, DigestItem, Perbill, Percent};

use std::collections::BTreeMap;

use cumulus_pallet_parachain_system::MessagingStateSnapshot;
use cumulus_primitives_core::AbridgedHrmpChannel;
use fp_rpc::ConvertTransaction;
use moonbase_runtime::XcmWeightTrader;
use pallet_transaction_payment::Multiplier;
use std::collections::BTreeMap;
use xcm::prelude::{InteriorLocation, Location};

pub fn existential_deposit() -> u128 {
Expand Down Expand Up @@ -67,8 +68,6 @@ pub fn rpc_run_to_block(n: u32) {
/// Utility function that advances the chain to the desired block number.
/// If an author is provided, that author information is injected to all the blocks in the meantime.
pub fn run_to_block(n: u32, author: Option<NimbusId>) {
// Finalize the first block
Ethereum::on_finalize(System::block_number());
while System::block_number() < n {
// Set the new block number and author
match author {
Expand Down Expand Up @@ -96,7 +95,6 @@ pub fn run_to_block(n: u32, author: Option<NimbusId>) {
Ethereum::on_initialize(System::block_number());

// Finalize the block
Ethereum::on_finalize(System::block_number());
ParachainStaking::on_finalize(System::block_number());
}
}
Expand Down Expand Up @@ -323,6 +321,26 @@ impl ExtBuilder {
let xcm_assets = self.xcm_assets.clone();

ext.execute_with(|| {
// Mock hrmp egress_channels
cumulus_pallet_parachain_system::RelevantMessagingState::<Runtime>::put(
MessagingStateSnapshot {
dmq_mqc_head: Default::default(),
relay_dispatch_queue_remaining_capacity: Default::default(),
ingress_channels: vec![],
egress_channels: vec![(
1_001.into(),
AbridgedHrmpChannel {
max_capacity: u32::MAX,
max_total_size: u32::MAX,
max_message_size: u32::MAX,
msg_count: 0,
total_size: 0,
mqc_head: None,
},
)],
},
);

// If any xcm assets specified, we register them here
for xcm_asset_initialization in xcm_assets {
let asset_id = xcm_asset_initialization.asset_id;
Expand Down
30 changes: 14 additions & 16 deletions runtime/moonbase/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use frame_support::{
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
StorageHasher, Twox128,
};
use moonbase_runtime::xcm_config::XcmExecutor;
use moonbase_runtime::xcm_config::{AssetHubLocation, XcmExecutor};
use moonbase_runtime::{
moonbase_xcm_weights, xcm_config::SelfReserve, AccountId, AssetId, Balances, CrowdloanRewards,
EvmForeignAssets, Executive, OpenTechCommitteeCollective, ParachainStaking, PolkadotXcm,
Expand Down Expand Up @@ -1565,7 +1565,7 @@ fn xtokens_precompiles_transfer() {
ExtBuilder::default()
.with_xcm_assets(vec![XcmAssetInitialization {
asset_id: 1,
xcm_location: xcm::v5::Location::parent(),
xcm_location: AssetHubLocation::get(),
name: "RelayToken",
symbol: "Relay",
decimals: 12,
Expand All @@ -1581,13 +1581,11 @@ fn xtokens_precompiles_transfer() {
let xtokens_precompile_address = H160::from_low_u64_be(2052);

// We have the assetId that corresponds to the relay chain registered
let relay_asset_id: AssetId = 1;
let asset_id: AssetId = 1;

// Its address is
let asset_precompile_address = Runtime::asset_id_to_account(
FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX,
relay_asset_id,
);
let asset_precompile_address =
Runtime::asset_id_to_account(FOREIGN_ASSET_PRECOMPILE_ADDRESS_PREFIX, asset_id);

// Alice has 1000 tokens. She should be able to send through precompile
let destination = Location::new(
Expand Down Expand Up @@ -1663,9 +1661,9 @@ fn xtokens_precompiles_transfer_multiasset() {
ExtBuilder::default()
.with_xcm_assets(vec![XcmAssetInitialization {
asset_id: 1,
xcm_location: xcm::v5::Location::parent(),
name: "RelayToken",
symbol: "Relay",
xcm_location: AssetHubLocation::get(),
name: "DOT",
symbol: "DOT",
decimals: 12,
balances: vec![(AccountId::from(ALICE), 1_000 * UNIT)],
}])
Expand Down Expand Up @@ -1697,8 +1695,8 @@ fn xtokens_precompiles_transfer_multiasset() {
ALICE,
xtokens_precompile_address,
XtokensPCall::transfer_multiasset {
// We want to transfer the relay token
asset: Location::parent(),
// We want to transfer DOT
asset: AssetHubLocation::get(),
amount: 500_000_000_000_000u128.into(),
destination,
weight: 4_000_000,
Expand Down Expand Up @@ -2134,9 +2132,9 @@ fn root_can_change_default_xcm_vers() {
])
.with_xcm_assets(vec![XcmAssetInitialization {
asset_id: 1,
xcm_location: xcm::v5::Location::parent(),
name: "RelayToken",
symbol: "Relay",
xcm_location: AssetHubLocation::get(),
name: "Dot",
symbol: "Dot",
decimals: 12,
balances: vec![(AccountId::from(ALICE), 1_000_000_000_000_000)],
}])
Expand Down Expand Up @@ -2171,7 +2169,7 @@ fn root_can_change_default_xcm_vers() {
0,
WeightLimit::Unlimited
),
pallet_xcm::Error::<Runtime>::SendFailure
pallet_xcm::Error::<Runtime>::LocalExecutionIncomplete
);

// Root sets the defaultXcm
Expand Down
28 changes: 14 additions & 14 deletions runtime/moonbase/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn send_relay_asset_to_relay() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 123);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -310,7 +310,7 @@ fn send_relay_asset_to_para_b() {

ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -1077,7 +1077,7 @@ fn transact_through_derivative_multilocation() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -1229,7 +1229,7 @@ fn transact_through_derivative_with_custom_fee_weight() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -1383,7 +1383,7 @@ fn transact_through_derivative_with_custom_fee_weight_refund() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -1548,7 +1548,7 @@ fn transact_through_sovereign() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -1803,7 +1803,7 @@ fn transact_through_sovereign_with_custom_fee_weight() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -1955,7 +1955,7 @@ fn transact_through_sovereign_with_custom_fee_weight_refund() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_id), 100);
// free execution, full amount received
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -2888,7 +2888,7 @@ fn send_statemint_asset_from_para_a_to_statemint_with_relay_fee() {
);
let asset_fee =
currency_to_asset(parachain::CurrencyId::ForeignAsset(source_relay_id), 100);
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -3025,7 +3025,7 @@ fn send_dot_from_moonbeam_to_statemint_via_xtokens_transfer() {
// Finally we test that we are able to send back the DOTs to AssetHub from the ParaA
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_relay_id), 100);
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -3182,7 +3182,7 @@ fn send_dot_from_moonbeam_to_statemint_via_xtokens_transfer_with_fee() {
ParaA::execute_with(|| {
let asset = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_relay_id), 100);
let asset_fee = currency_to_asset(parachain::CurrencyId::ForeignAsset(source_relay_id), 10);
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -3344,7 +3344,7 @@ fn send_dot_from_moonbeam_to_statemint_via_xtokens_transfer_multiasset() {
};
// Finally we test that we are able to send back the DOTs to AssetHub from the ParaA
ParaA::execute_with(|| {
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -3584,7 +3584,7 @@ fn send_dot_from_moonbeam_to_statemint_via_xtokens_transfer_multicurrencies() {
);
let asset_fee =
currency_to_asset(parachain::CurrencyId::ForeignAsset(source_relay_id), 100);
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down Expand Up @@ -3843,7 +3843,7 @@ fn send_dot_from_moonbeam_to_statemint_via_xtokens_transfer_multiassets() {

// Finally we test that we are able to send back the DOTs to AssetHub from the ParaA
ParaA::execute_with(|| {
assert_ok!(PolkadotXcm::transfer_assets(
assert_ok!(PolkadotXcm::limited_reserve_transfer_assets(
parachain::RuntimeOrigin::signed(PARAALICE.into()),
Box::new(VersionedLocation::from(chain_part)),
Box::new(VersionedLocation::from(beneficiary)),
Expand Down
8 changes: 8 additions & 0 deletions runtime/moonbeam/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

//! # Moonbeam specific Migrations

use crate::xcm_config::AssetType;
use moonbeam_core_primitives::AssetId;
use sp_core::parameter_types;

parameter_types! {
pub RelayAssetId: AssetId = AssetType::Xcm(xcm::v3::Location::parent()).into();
}

type MoonbeamMigrations = ();

/// List of single block migrations to be executed by frame executive.
Expand Down
25 changes: 23 additions & 2 deletions runtime/moonbeam/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ use sp_consensus_slots::Slot;
use sp_core::{Encode, H160};
use sp_runtime::{traits::Dispatchable, BuildStorage, Digest, DigestItem, Perbill, Percent};

use std::collections::BTreeMap;

use cumulus_pallet_parachain_system::MessagingStateSnapshot;
use cumulus_primitives_core::AbridgedHrmpChannel;
use fp_rpc::ConvertTransaction;
use moonbeam_runtime::bridge_config::XcmOverKusamaInstance;
use moonbeam_runtime::{EvmForeignAssets, XcmWeightTrader};
use std::collections::BTreeMap;
use xcm::latest::{InteriorLocation, Location};

pub fn existential_deposit() -> u128 {
Expand Down Expand Up @@ -320,6 +321,26 @@ impl ExtBuilder {
let mut ext = sp_io::TestExternalities::new(t);
let xcm_assets = self.xcm_assets.clone();
ext.execute_with(|| {
// Mock hrmp egress_channels
cumulus_pallet_parachain_system::RelevantMessagingState::<Runtime>::put(
MessagingStateSnapshot {
dmq_mqc_head: Default::default(),
relay_dispatch_queue_remaining_capacity: Default::default(),
ingress_channels: vec![],
egress_channels: vec![(
1_000.into(),
AbridgedHrmpChannel {
max_capacity: u32::MAX,
max_total_size: u32::MAX,
max_message_size: u32::MAX,
msg_count: 0,
total_size: 0,
mqc_head: None,
},
)],
},
);

// If any xcm assets specified, we register them here
for xcm_asset_initialization in xcm_assets {
let asset_id: AssetId = xcm_asset_initialization.asset_type.clone().into();
Expand Down
Loading
Loading