Skip to content

Commit

Permalink
Merge pull request #14 from paritytech/xcm-improvements
Browse files Browse the repository at this point in the history
Improve XCm configuration for mainnet
  • Loading branch information
Moliholy authored Mar 12, 2024
2 parents 6c1acf2 + c87609a commit ce0ab5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion primitives/xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use frame_support::traits::{Get, OriginTrait};
use xcm::latest::prelude::*;

// Convert a local Origin (i.e., a signed 20 byte account Origin) to a Multilocation
// Convert a local Origin (i.e., a signed 20 byte account Origin) to a Location
pub struct SignedToAccountId20<Origin, AccountId, Network>(
sp_std::marker::PhantomData<(Origin, AccountId, Network)>,
);
Expand Down
5 changes: 3 additions & 2 deletions runtime/mainnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};

// XCM Imports

use crate::xcm_config::SelfReserve;
use xcm::latest::prelude::BodyId;

/// The address format for describing accounts.
Expand Down Expand Up @@ -440,7 +441,7 @@ impl pallet_message_queue::Config for Runtime {

parameter_types! {
/// The asset ID for the asset that we use to pay for message delivery fees.
pub FeeAssetId: AssetId = AssetId(xcm_config::RelayLocation::get());
pub FeeAssetId: AssetId = AssetId(SelfReserve::get());
/// The base fee for the message delivery fees.
pub const BaseDeliveryFee: Balance = 300_000_000;
/// The fee per byte
Expand All @@ -457,7 +458,7 @@ pub type PriceForSiblingParachainDelivery = polkadot_runtime_common::xcm_sender:
impl cumulus_pallet_xcmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
type VersionWrapper = PolkadotXcm;
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = frame_support::traits::TransformOrigin<
MessageQueue,
Expand Down
22 changes: 10 additions & 12 deletions runtime/mainnet/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,34 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountKey20Aliases, AllowExplicitUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom,
CreateMatcher, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, MatchXcm,
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, WithComputedOrigin,
WithUniqueTopic,
CreateMatcher, DescribeFamily, DescribeTerminus, EnsureXcmOrigin, FixedWeightBounds,
FrameTransactionalProcessor, HashedDescription, MatchXcm, RelayChainAsNative,
SiblingParachainAsNative, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
WithComputedOrigin, WithUniqueTopic,
};
use xcm_executor::traits::Properties;
use xcm_executor::{traits::ShouldExecute, XcmExecutor};
use xcm_primitives::SignedToAccountId20;

parameter_types! {
pub const RelayLocation: Location = Location::parent();
pub const RelayNetwork: NetworkId = cumulus_primitives_core::Ethereum { chain_id: 132 }; // todo!();
pub SelfReserve: Location = Location { parents: 0, interior: Here };
pub PlaceholderAccount: AccountId = PolkadotXcm::check_account();
pub const RelayNetwork: NetworkId = NetworkId::Polkadot;
pub SelfReserve: Location = Location::here();
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorLocation = (GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())).into();
pub UniversalLocation: InteriorLocation =
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
/// `Transact` in order to determine the dispatch Origin.
pub type LocationToAccountId = (
// The parent (Relay-chain) origin converts to the parent `AccountId`.
ParentIsPreset<AccountId>,
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
SiblingParachainConvertsVia<Sibling, AccountId>,
HashedDescription<AccountId, DescribeFamily<DescribeTerminus>>,
// If we receive a Location of type AccountKey20, just generate a native account
AccountKey20Aliases<RelayNetwork, AccountId>,
);
Expand Down Expand Up @@ -201,7 +199,7 @@ pub type LocalOriginToLocation = SignedToAccountId20<RuntimeOrigin, AccountId, R
/// queues.
pub type XcmRouter = WithUniqueTopic<(
// Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, (), ()>,
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// and XCMP to communicate with the sibling chains.
XcmpQueue,
)>;
Expand Down

0 comments on commit ce0ab5d

Please sign in to comment.