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

Small nits for XCMv5 #6383

Merged
merged 7 commits into from
Nov 6, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ pub(crate) fn open_bridge_between_asset_hub_rococo_and_asset_hub_westend() {
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), ROC * 5);
AssetHubRococo::open_bridge(
AssetHubRococo::sibling_location_of(BridgeHubRococo::para_id()),
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(AssetHubWestend::para_id().into())].into(),
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(AssetHubWestend::para_id().into()),
]
.into(),
Some((
(roc_at_ah_rococo(), ROC * 1).into(),
BridgeHubRococo::sovereign_account_id_of(BridgeHubRococo::sibling_location_of(
Expand All @@ -263,7 +267,11 @@ pub(crate) fn open_bridge_between_asset_hub_rococo_and_asset_hub_westend() {
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), WND * 5);
AssetHubWestend::open_bridge(
AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()),
[GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(AssetHubRococo::para_id().into())].into(),
[
GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)),
Parachain(AssetHubRococo::para_id().into()),
]
.into(),
Some((
(wnd_at_ah_westend(), WND * 1).into(),
BridgeHubWestend::sovereign_account_id_of(BridgeHubWestend::sibling_location_of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,9 @@ fn send_pens_and_wnds_from_penpal_westend_via_ahw_to_ahr() {
pens_at_ahw
.interior()
.clone()
.pushed_front_with(Junction::GlobalConsensus(NetworkId::ByGenesis(WESTEND_GENESIS_HASH)))
.pushed_front_with(Junction::GlobalConsensus(NetworkId::ByGenesis(
WESTEND_GENESIS_HASH,
)))
.unwrap(),
);
let wnds_to_send = amount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ pub(crate) fn open_bridge_between_asset_hub_rococo_and_asset_hub_westend() {
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id(), ROC * 5);
AssetHubRococo::open_bridge(
AssetHubRococo::sibling_location_of(BridgeHubRococo::para_id()),
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(AssetHubWestend::para_id().into())].into(),
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(AssetHubWestend::para_id().into()),
]
.into(),
Some((
(roc_at_ah_rococo(), ROC * 1).into(),
BridgeHubRococo::sovereign_account_id_of(BridgeHubRococo::sibling_location_of(
Expand All @@ -273,7 +277,11 @@ pub(crate) fn open_bridge_between_asset_hub_rococo_and_asset_hub_westend() {
BridgeHubWestend::fund_para_sovereign(AssetHubWestend::para_id(), WND * 5);
AssetHubWestend::open_bridge(
AssetHubWestend::sibling_location_of(BridgeHubWestend::para_id()),
[GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(AssetHubRococo::para_id().into())].into(),
[
GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)),
Parachain(AssetHubRococo::para_id().into()),
]
.into(),
Some((
(wnd_at_ah_westend(), WND * 1).into(),
BridgeHubWestend::sovereign_account_id_of(BridgeHubWestend::sibling_location_of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ fn transfer_relay_token() {
BridgeHubWestend::fund_accounts(vec![(assethub_sovereign.clone(), INITIAL_FUND)]);

let asset_id: Location = Location { parents: 1, interior: [].into() };
let expected_asset_id: Location =
Location { parents: 1, interior: [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))].into() };
let expected_asset_id: Location = Location {
parents: 1,
interior: [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH))].into(),
};

let expected_token_id = TokenIdOf::convert_location(&expected_asset_id).unwrap();

Expand Down Expand Up @@ -465,10 +467,15 @@ fn transfer_ah_token() {
],
);

let asset_id_after_reanchored =
Location::new(1, [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(AssetHubWestend::para_id().into())])
.appended_with(asset_id.clone().interior)
.unwrap();
let asset_id_after_reanchored = Location::new(
1,
[
GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)),
Parachain(AssetHubWestend::para_id().into()),
],
)
.appended_with(asset_id.clone().interior)
.unwrap();

let token_id = TokenIdOf::convert_location(&asset_id_after_reanchored).unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,13 @@ where
{
use pallet_xcm_bridge_hub::{Bridge, BridgeId, BridgeState};
use sp_runtime::traits::Zero;
use xcm::{VersionedInteriorLocation, latest::ROCOCO_GENESIS_HASH};
use xcm::{latest::ROCOCO_GENESIS_HASH, VersionedInteriorLocation};

// insert bridge metadata
let lane_id = with;
let sibling_parachain = Location::new(1, [Parachain(sibling_para_id)]);
let universal_source = [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(sibling_para_id)].into();
let universal_source =
[GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(sibling_para_id)].into();
let universal_destination =
[GlobalConsensus(RococoBulletinGlobalConsensusNetwork::get()), Parachain(2075)].into();
let bridge_id = BridgeId::new(&universal_source, &universal_destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,16 @@ where
{
use pallet_xcm_bridge_hub::{Bridge, BridgeId, BridgeState};
use sp_runtime::traits::Zero;
use xcm::latest::ROCOCO_GENESIS_HASH;
use xcm::VersionedInteriorLocation;

// insert bridge metadata
let lane_id = with;
let sibling_parachain = Location::new(1, [Parachain(sibling_para_id)]);
let universal_source = [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(sibling_para_id)].into();
let universal_destination = [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(2075)].into();
let universal_source =
[GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(sibling_para_id)].into();
let universal_destination =
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(2075)].into();
let bridge_id = BridgeId::new(&universal_source, &universal_destination);

// insert only bridge metadata, because the benchmarks create lanes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};

#[cfg(feature = "runtime-benchmarks")]
use xcm::latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH};
use xcm::latest::WESTEND_GENESIS_HASH;
use xcm::VersionedLocation;
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ where
{
use pallet_xcm_bridge_hub::{Bridge, BridgeId, BridgeState};
use sp_runtime::traits::Zero;
use xcm::VersionedInteriorLocation;
use xcm::{latest::WESTEND_GENESIS_HASH, VersionedInteriorLocation};

// insert bridge metadata
let lane_id = with;
let sibling_parachain = Location::new(1, [Parachain(sibling_para_id)]);
let universal_source = [GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(sibling_para_id)].into();
let universal_destination = [GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(2075)].into();
let universal_source =
[GlobalConsensus(ByGenesis(WESTEND_GENESIS_HASH)), Parachain(sibling_para_id)].into();
let universal_destination =
[GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(2075)].into();
let bridge_id = BridgeId::new(&universal_source, &universal_destination);

// insert only bridge metadata, because the benchmarks create lanes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub use sp_runtime::BuildStorage;
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};

#[cfg(feature = "runtime-benchmarks")]
use xcm::latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH};
use xcm::latest::ROCOCO_GENESIS_HASH;
use xcm::prelude::*;

use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use frame_support::{
use pallet_message_queue::OnQueueChanged;
use scale_info::TypeInfo;
use snowbridge_core::ChannelId;
use xcm::v5::{Junction, Location};
use xcm::latest::prelude::{Junction, Location};

/// The aggregate origin of an inbound message.
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue-pallet is also using
Expand Down Expand Up @@ -53,7 +53,7 @@ impl From<AggregateMessageOrigin> for Location {
Here => Location::here(),
Parent => Location::parent(),
Sibling(id) => Location::new(1, Junction::Parachain(id.into())),
// NOTE: We don't need this conversion for Snowbridge. However we have to
// NOTE: We don't need this conversion for Snowbridge. However, we have to
// implement it anyway as xcm_builder::ProcessXcmMessage requires it.
Snowbridge(_) => Location::default(),
}
Expand Down
12 changes: 6 additions & 6 deletions cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ use xcm_builder::{
AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
AsPrefixedGeneralIndex, ConvertedConcreteId, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter,
FungiblesAdapter, HashedDescription, IsConcrete,
LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SingleAssetExchangeAdapter,
SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents,
FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SingleAssetExchangeAdapter, SovereignSignedViaLocation, StartsWith,
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents,
};
use xcm_executor::{traits::JustTry, XcmExecutor};

Expand Down
29 changes: 17 additions & 12 deletions polkadot/runtime/parachains/src/coretime/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ mod v_coretime {
use sp_arithmetic::traits::SaturatedConversion;
use sp_core::Get;
use sp_runtime::BoundedVec;
use xcm::prelude::{send_xcm, Instruction, Junction, Location, SendError, WeightLimit, Xcm};
use xcm::prelude::{
send_xcm, Instruction, Junction, Location, SendError, SendXcm, WeightLimit, Xcm,
};

/// Return information about a legacy lease of a parachain.
pub trait GetLegacyLease<N> {
Expand All @@ -62,10 +64,10 @@ mod v_coretime {

impl<
T: Config,
SendXcm: xcm::latest::SendXcm,
XcmSender: SendXcm,
LegacyLease: GetLegacyLease<BlockNumberFor<T>>,
const TIMESLICE_PERIOD: u32,
> MigrateToCoretime<T, SendXcm, LegacyLease, TIMESLICE_PERIOD>
> MigrateToCoretime<T, XcmSender, LegacyLease, TIMESLICE_PERIOD>
{
fn already_migrated() -> bool {
// We are using the assigner coretime because the coretime pallet doesn't has any
Expand Down Expand Up @@ -95,18 +97,18 @@ mod v_coretime {

impl<
T: Config + crate::dmp::Config,
SendXcm: xcm::latest::SendXcm,
XcmSender: SendXcm,
LegacyLease: GetLegacyLease<BlockNumberFor<T>>,
const TIMESLICE_PERIOD: u32,
> OnRuntimeUpgrade for MigrateToCoretime<T, SendXcm, LegacyLease, TIMESLICE_PERIOD>
> OnRuntimeUpgrade for MigrateToCoretime<T, XcmSender, LegacyLease, TIMESLICE_PERIOD>
{
fn on_runtime_upgrade() -> Weight {
if Self::already_migrated() {
return Weight::zero()
}

log::info!("Migrating existing parachains to coretime.");
migrate_to_coretime::<T, SendXcm, LegacyLease, TIMESLICE_PERIOD>()
migrate_to_coretime::<T, XcmSender, LegacyLease, TIMESLICE_PERIOD>()
}

#[cfg(feature = "try-runtime")]
Expand Down Expand Up @@ -157,7 +159,7 @@ mod v_coretime {
// NOTE: Also migrates `num_cores` config value in configuration::ActiveConfig.
fn migrate_to_coretime<
T: Config,
SendXcm: xcm::latest::SendXcm,
XcmSender: SendXcm,
LegacyLease: GetLegacyLease<BlockNumberFor<T>>,
const TIMESLICE_PERIOD: u32,
>() -> Weight {
Expand Down Expand Up @@ -198,9 +200,12 @@ mod v_coretime {
c.scheduler_params.num_cores = total_cores;
});

if let Err(err) =
migrate_send_assignments_to_coretime_chain::<T, SendXcm, LegacyLease, TIMESLICE_PERIOD>(
) {
if let Err(err) = migrate_send_assignments_to_coretime_chain::<
T,
XcmSender,
LegacyLease,
TIMESLICE_PERIOD,
>() {
log::error!("Sending legacy chain data to coretime chain failed: {:?}", err);
}

Expand All @@ -215,7 +220,7 @@ mod v_coretime {

fn migrate_send_assignments_to_coretime_chain<
T: Config,
SendXcm: xcm::latest::SendXcm,
XcmSender: SendXcm,
LegacyLease: GetLegacyLease<BlockNumberFor<T>>,
const TIMESLICE_PERIOD: u32,
>() -> result::Result<(), SendError> {
Expand Down Expand Up @@ -300,7 +305,7 @@ mod v_coretime {
};

for message in messages {
send_xcm::<SendXcm>(
send_xcm::<XcmSender>(
Location::new(0, Junction::Parachain(T::BrokerId::get())),
message,
)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame::{
runtime::prelude::*,
traits::{Everything, Nothing},
};
use xcm::v5::prelude::*;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin,
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use frame::{
traits::{IdentityLookup, ProcessMessage, ProcessMessageError},
};
use polkadot_runtime_parachains::inclusion::{AggregateMessageOrigin, UmpQueueId};
use xcm::v5::prelude::*;
use xcm::latest::prelude::*;

mod xcm_config;
pub use xcm_config::LocationToAccountId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame::{
runtime::prelude::*,
traits::{Everything, Nothing},
};
use xcm::v5::prelude::*;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, DescribeAllTerminal, DescribeFamily, EnsureXcmOrigin,
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
Expand Down
5 changes: 1 addition & 4 deletions polkadot/xcm/src/v4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub use traits::{
SendError, SendResult, SendXcm, Weight, XcmHash,
};
// These parts of XCM v3 are unchanged in XCM v4, and are re-imported here.
pub use super::v3::{MaybeErrorCode, OriginKind, WeightLimit};
pub use super::v3::{MaxDispatchErrorLen, MaybeErrorCode, OriginKind, WeightLimit};

/// This module's XCM version.
pub const VERSION: super::Version = 4;
Expand Down Expand Up @@ -229,9 +229,6 @@ pub mod prelude {

parameter_types! {
pub MaxPalletNameLen: u32 = 48;
/// Maximum size of the encoded error code coming from a `Dispatch` result, used for
/// `MaybeErrorCode`. This is not (yet) enforced, so it's just an indication of expectation.
pub MaxDispatchErrorLen: u32 = 128;
pub MaxPalletsInfo: u32 = 64;
}

Expand Down
5 changes: 1 addition & 4 deletions polkadot/xcm/src/v5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use traits::{
SendError, SendResult, SendXcm, Weight, XcmHash,
};
// These parts of XCM v4 are unchanged in XCM v5, and are re-imported here.
pub use super::v4::{MaybeErrorCode, OriginKind, WeightLimit};
pub use super::v4::{MaxDispatchErrorLen, MaybeErrorCode, OriginKind, WeightLimit};

pub const VERSION: super::Version = 5;

Expand Down Expand Up @@ -223,9 +223,6 @@ pub mod prelude {

parameter_types! {
pub MaxPalletNameLen: u32 = 48;
/// Maximum size of the encoded error code coming from a `Dispatch` result, used for
/// `MaybeErrorCode`. This is not (yet) enforced, so it's just an indication of expectation.
pub MaxDispatchErrorLen: u32 = 128;
pub MaxPalletsInfo: u32 = 64;
}

Expand Down
Loading