mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
XCMv4 (#1230)
# Note for reviewer
Most changes are just syntax changes necessary for the new version.
Most important files should be the ones under the `xcm` folder.
# Description
Added XCMv4.
## Removed `Multi` prefix
The following types have been renamed:
- MultiLocation -> Location
- MultiAsset -> Asset
- MultiAssets -> Assets
- InteriorMultiLocation -> InteriorLocation
- MultiAssetFilter -> AssetFilter
- VersionedMultiAsset -> VersionedAsset
- WildMultiAsset -> WildAsset
- VersionedMultiLocation -> VersionedLocation
In order to fix a name conflict, the `Assets` in `xcm-executor` were
renamed to `HoldingAssets`, as they represent assets in holding.
## Removed `Abstract` asset id
It was not being used anywhere and this simplifies the code.
Now assets are just constructed as follows:
```rust
let asset: Asset = (AssetId(Location::new(1, Here)), 100u128).into();
```
No need for specifying `Concrete` anymore.
## Outcome is now a named fields struct
Instead of
```rust
pub enum Outcome {
Complete(Weight),
Incomplete(Weight, Error),
Error(Error),
}
```
we now have
```rust
pub enum Outcome {
Complete { used: Weight },
Incomplete { used: Weight, error: Error },
Error { error: Error },
}
```
## Added Reanchorable trait
Now both locations and assets implement this trait, making it easier to
reanchor both.
## New syntax for building locations and junctions
Now junctions are built using the following methods:
```rust
let location = Location {
parents: 1,
interior: [Parachain(1000), PalletInstance(50), GeneralIndex(1984)].into()
};
```
or
```rust
let location = Location::new(1, [Parachain(1000), PalletInstance(50), GeneralIndex(1984)]);
```
And they are matched like so:
```rust
match location.unpack() {
(1, [Parachain(id)]) => ...
(0, Here) => ...,
(1, [_]) => ...,
}
```
This syntax is mandatory in v4, and has been also implemented for v2 and
v3 for easier migration.
This was needed to make all sizes smaller.
# TODO
- [x] Scaffold v4
- [x] Port github.com/paritytech/polkadot/pull/7236
- [x] Remove `Multi` prefix
- [x] Remove `Abstract` asset id
---------
Co-authored-by: command-bot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ec7bfae00a
commit
8428f678fe
+15
-15
@@ -48,7 +48,7 @@ use frame_support::{parameter_types, traits::PalletInfoAccess};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use xcm::{
|
||||
latest::prelude::*,
|
||||
prelude::{InteriorMultiLocation, NetworkId},
|
||||
prelude::{InteriorLocation, NetworkId},
|
||||
};
|
||||
use xcm_builder::BridgeBlobDispatcher;
|
||||
|
||||
@@ -65,16 +65,16 @@ parameter_types! {
|
||||
/// Bridge specific chain (network) identifier of the Rococo Bulletin Chain.
|
||||
pub const RococoBulletinChainId: bp_runtime::ChainId = bp_runtime::POLKADOT_BULLETIN_CHAIN_ID;
|
||||
/// Interior location (relative to this runtime) of the with-RococoBulletin messages pallet.
|
||||
pub BridgeRococoToRococoBulletinMessagesPalletInstance: InteriorMultiLocation = X1(
|
||||
pub BridgeRococoToRococoBulletinMessagesPalletInstance: InteriorLocation = [
|
||||
PalletInstance(<BridgeRococoBulletinMessages as PalletInfoAccess>::index() as u8)
|
||||
);
|
||||
].into();
|
||||
/// Rococo Bulletin Network identifier.
|
||||
pub RococoBulletinGlobalConsensusNetwork: NetworkId = NetworkId::PolkadotBulletin;
|
||||
/// Relative location of the Rococo Bulletin chain.
|
||||
pub RococoBulletinGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
|
||||
parents: 2,
|
||||
interior: X1(GlobalConsensus(RococoBulletinGlobalConsensusNetwork::get()))
|
||||
};
|
||||
pub RococoBulletinGlobalConsensusNetworkLocation: Location = Location::new(
|
||||
2,
|
||||
[GlobalConsensus(RococoBulletinGlobalConsensusNetwork::get())]
|
||||
);
|
||||
/// All active lanes that the current bridge supports.
|
||||
pub ActiveOutboundLanesToRococoBulletin: &'static [bp_messages::LaneId]
|
||||
= &[XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN];
|
||||
@@ -94,11 +94,11 @@ parameter_types! {
|
||||
/// A route (XCM location and bridge lane) that the Rococo People Chain -> Rococo Bulletin Chain
|
||||
/// message is following.
|
||||
pub FromRococoPeopleToRococoBulletinRoute: SenderAndLane = SenderAndLane::new(
|
||||
ParentThen(X1(Parachain(RococoPeopleParaId::get().into()))).into(),
|
||||
ParentThen(Parachain(RococoPeopleParaId::get().into()).into()).into(),
|
||||
XCM_LANE_FOR_ROCOCO_PEOPLE_TO_ROCOCO_BULLETIN,
|
||||
);
|
||||
/// All active routes and their destinations.
|
||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||
(
|
||||
FromRococoPeopleToRococoBulletinRoute::get(),
|
||||
(RococoBulletinGlobalConsensusNetwork::get(), Here)
|
||||
@@ -282,11 +282,11 @@ mod tests {
|
||||
PriorityBoostPerMessage,
|
||||
>(FEE_BOOST_PER_MESSAGE);
|
||||
|
||||
assert_eq!(
|
||||
BridgeRococoToRococoBulletinMessagesPalletInstance::get(),
|
||||
X1(PalletInstance(
|
||||
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX
|
||||
))
|
||||
);
|
||||
let expected: InteriorLocation = PalletInstance(
|
||||
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_BULLETIN_MESSAGES_PALLET_INDEX,
|
||||
)
|
||||
.into();
|
||||
|
||||
assert_eq!(BridgeRococoToRococoBulletinMessagesPalletInstance::get(), expected,);
|
||||
}
|
||||
}
|
||||
|
||||
+20
-20
@@ -48,7 +48,7 @@ use frame_support::{parameter_types, traits::PalletInfoAccess};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use xcm::{
|
||||
latest::prelude::*,
|
||||
prelude::{InteriorMultiLocation, NetworkId},
|
||||
prelude::{InteriorLocation, NetworkId},
|
||||
};
|
||||
use xcm_builder::BridgeBlobDispatcher;
|
||||
|
||||
@@ -58,12 +58,12 @@ parameter_types! {
|
||||
pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
|
||||
bp_bridge_hub_rococo::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
|
||||
pub const BridgeHubWestendChainId: bp_runtime::ChainId = bp_runtime::BRIDGE_HUB_WESTEND_CHAIN_ID;
|
||||
pub BridgeRococoToWestendMessagesPalletInstance: InteriorMultiLocation = X1(PalletInstance(<BridgeWestendMessages as PalletInfoAccess>::index() as u8));
|
||||
pub BridgeRococoToWestendMessagesPalletInstance: InteriorLocation = [PalletInstance(<BridgeWestendMessages as PalletInfoAccess>::index() as u8)].into();
|
||||
pub WestendGlobalConsensusNetwork: NetworkId = NetworkId::Westend;
|
||||
pub WestendGlobalConsensusNetworkLocation: MultiLocation = MultiLocation {
|
||||
parents: 2,
|
||||
interior: X1(GlobalConsensus(WestendGlobalConsensusNetwork::get()))
|
||||
};
|
||||
pub WestendGlobalConsensusNetworkLocation: Location = Location::new(
|
||||
2,
|
||||
[GlobalConsensus(WestendGlobalConsensusNetwork::get())]
|
||||
);
|
||||
// see the `FEE_BOOST_PER_MESSAGE` constant to get the meaning of this value
|
||||
pub PriorityBoostPerMessage: u64 = 182_044_444_444_444;
|
||||
|
||||
@@ -74,26 +74,26 @@ parameter_types! {
|
||||
pub ActiveOutboundLanesToBridgeHubWestend: &'static [bp_messages::LaneId] = &[XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND];
|
||||
pub const AssetHubRococoToAssetHubWestendMessagesLane: bp_messages::LaneId = XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND;
|
||||
pub FromAssetHubRococoToAssetHubWestendRoute: SenderAndLane = SenderAndLane::new(
|
||||
ParentThen(X1(Parachain(AssetHubRococoParaId::get().into()))).into(),
|
||||
ParentThen([Parachain(AssetHubRococoParaId::get().into())].into()).into(),
|
||||
XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND,
|
||||
);
|
||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorMultiLocation))> = sp_std::vec![
|
||||
pub ActiveLanes: sp_std::vec::Vec<(SenderAndLane, (NetworkId, InteriorLocation))> = sp_std::vec![
|
||||
(
|
||||
FromAssetHubRococoToAssetHubWestendRoute::get(),
|
||||
(WestendGlobalConsensusNetwork::get(), X1(Parachain(AssetHubWestendParaId::get().into())))
|
||||
(WestendGlobalConsensusNetwork::get(), [Parachain(AssetHubWestendParaId::get().into())].into())
|
||||
)
|
||||
];
|
||||
|
||||
pub CongestedMessage: Xcm<()> = build_congestion_message(true).into();
|
||||
pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into();
|
||||
|
||||
pub BridgeHubWestendLocation: MultiLocation = MultiLocation {
|
||||
parents: 2,
|
||||
interior: X2(
|
||||
pub BridgeHubWestendLocation: Location = Location::new(
|
||||
2,
|
||||
[
|
||||
GlobalConsensus(WestendGlobalConsensusNetwork::get()),
|
||||
Parachain(<bp_bridge_hub_westend::BridgeHubWestend as bp_runtime::Parachain>::PARACHAIN_ID)
|
||||
)
|
||||
};
|
||||
]
|
||||
);
|
||||
}
|
||||
pub const XCM_LANE_FOR_ASSET_HUB_ROCOCO_TO_ASSET_HUB_WESTEND: LaneId = LaneId([0, 0, 0, 2]);
|
||||
|
||||
@@ -327,11 +327,11 @@ mod tests {
|
||||
PriorityBoostPerMessage,
|
||||
>(FEE_BOOST_PER_MESSAGE);
|
||||
|
||||
assert_eq!(
|
||||
BridgeRococoToWestendMessagesPalletInstance::get(),
|
||||
X1(PalletInstance(
|
||||
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX
|
||||
))
|
||||
);
|
||||
let expected: InteriorLocation = [PalletInstance(
|
||||
bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WESTEND_MESSAGES_PALLET_INDEX,
|
||||
)]
|
||||
.into();
|
||||
|
||||
assert_eq!(BridgeRococoToWestendMessagesPalletInstance::get(), expected,);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ use bridge_hub_common::{
|
||||
use pallet_xcm::EnsureXcm;
|
||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
pub use sp_runtime::{MultiAddress, Perbill, Permill};
|
||||
use xcm::VersionedMultiLocation;
|
||||
use xcm::VersionedLocation;
|
||||
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -385,7 +385,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
parameter_types! {
|
||||
/// The asset ID for the asset that we use to pay for message delivery fees.
|
||||
pub FeeAssetId: AssetId = Concrete(xcm_config::TokenLocation::get());
|
||||
pub FeeAssetId: AssetId = AssetId(xcm_config::TokenLocation::get());
|
||||
/// The base fee for the message delivery fees.
|
||||
pub const BaseDeliveryFee: u128 = CENTS.saturating_mul(3);
|
||||
}
|
||||
@@ -517,7 +517,7 @@ pub mod benchmark_helpers {
|
||||
use snowbridge_beacon_primitives::CompactExecutionHeader;
|
||||
use snowbridge_pallet_inbound_queue::BenchmarkHelper;
|
||||
use sp_core::H256;
|
||||
use xcm::latest::{MultiAssets, MultiLocation, SendError, SendResult, SendXcm, Xcm, XcmHash};
|
||||
use xcm::latest::{Assets, Location, SendError, SendResult, SendXcm, Xcm, XcmHash};
|
||||
|
||||
impl<T: snowbridge_pallet_ethereum_client::Config> BenchmarkHelper<T> for Runtime {
|
||||
fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) {
|
||||
@@ -530,10 +530,10 @@ pub mod benchmark_helpers {
|
||||
type Ticket = Xcm<()>;
|
||||
|
||||
fn validate(
|
||||
_dest: &mut Option<MultiLocation>,
|
||||
_dest: &mut Option<Location>,
|
||||
xcm: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<Self::Ticket> {
|
||||
Ok((xcm.clone().unwrap(), MultiAssets::new()))
|
||||
Ok((xcm.clone().unwrap(), Assets::new()))
|
||||
}
|
||||
fn deliver(xcm: Xcm<()>) -> Result<XcmHash, SendError> {
|
||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||
@@ -542,7 +542,7 @@ pub mod benchmark_helpers {
|
||||
}
|
||||
|
||||
impl snowbridge_pallet_system::BenchmarkHelper<RuntimeOrigin> for () {
|
||||
fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin {
|
||||
fn make_xcm_origin(location: Location) -> RuntimeOrigin {
|
||||
RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location))
|
||||
}
|
||||
}
|
||||
@@ -1016,7 +1016,7 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
impl snowbridge_system_runtime_api::ControlApi<Block> for Runtime {
|
||||
fn agent_id(location: VersionedMultiLocation) -> Option<AgentId> {
|
||||
fn agent_id(location: VersionedLocation) -> Option<AgentId> {
|
||||
snowbridge_pallet_system::api::agent_id::<Runtime>(location)
|
||||
}
|
||||
}
|
||||
@@ -1095,28 +1095,28 @@ impl_runtime_apis! {
|
||||
|
||||
use pallet_xcm::benchmarking::Pallet as PalletXcmExtrinsicsBenchmark;
|
||||
impl pallet_xcm::benchmarking::Config for Runtime {
|
||||
fn reachable_dest() -> Option<MultiLocation> {
|
||||
fn reachable_dest() -> Option<Location> {
|
||||
Some(Parent.into())
|
||||
}
|
||||
|
||||
fn teleportable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
||||
fn teleportable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||
// Relay/native token can be teleported between BH and Relay.
|
||||
Some((
|
||||
MultiAsset {
|
||||
Asset {
|
||||
fun: Fungible(EXISTENTIAL_DEPOSIT),
|
||||
id: Concrete(Parent.into())
|
||||
id: AssetId(Parent.into())
|
||||
},
|
||||
Parent.into(),
|
||||
))
|
||||
}
|
||||
|
||||
fn reserve_transferable_asset_and_dest() -> Option<(MultiAsset, MultiLocation)> {
|
||||
fn reserve_transferable_asset_and_dest() -> Option<(Asset, Location)> {
|
||||
// Reserve transfers are disabled on BH.
|
||||
None
|
||||
}
|
||||
|
||||
fn set_up_complex_asset_transfer(
|
||||
) -> Option<(MultiAssets, u32, MultiLocation, Box<dyn FnOnce()>)> {
|
||||
) -> Option<(Assets, u32, Location, Box<dyn FnOnce()>)> {
|
||||
// BH only supports teleports to system parachain.
|
||||
// Relay/native token can be teleported between BH and Relay.
|
||||
let native_location = Parent.into();
|
||||
@@ -1132,7 +1132,7 @@ impl_runtime_apis! {
|
||||
use xcm_config::TokenLocation;
|
||||
|
||||
parameter_types! {
|
||||
pub ExistentialDepositMultiAsset: Option<MultiAsset> = Some((
|
||||
pub ExistentialDepositAsset: Option<Asset> = Some((
|
||||
TokenLocation::get(),
|
||||
ExistentialDeposit::get()
|
||||
).into());
|
||||
@@ -1143,17 +1143,17 @@ impl_runtime_apis! {
|
||||
type AccountIdConverter = xcm_config::LocationToAccountId;
|
||||
type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper<
|
||||
xcm_config::XcmConfig,
|
||||
ExistentialDepositMultiAsset,
|
||||
ExistentialDepositAsset,
|
||||
xcm_config::PriceForParentDelivery,
|
||||
>;
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
fn valid_destination() -> Result<Location, BenchmarkError> {
|
||||
Ok(TokenLocation::get())
|
||||
}
|
||||
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
|
||||
fn worst_case_holding(_depositable_count: u32) -> Assets {
|
||||
// just concrete assets according to relay chain.
|
||||
let assets: Vec<MultiAsset> = vec![
|
||||
MultiAsset {
|
||||
id: Concrete(TokenLocation::get()),
|
||||
let assets: Vec<Asset> = vec![
|
||||
Asset {
|
||||
id: AssetId(TokenLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
}
|
||||
];
|
||||
@@ -1162,12 +1162,12 @@ impl_runtime_apis! {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TrustedTeleporter: Option<(MultiLocation, MultiAsset)> = Some((
|
||||
pub const TrustedTeleporter: Option<(Location, Asset)> = Some((
|
||||
TokenLocation::get(),
|
||||
MultiAsset { fun: Fungible(UNITS), id: Concrete(TokenLocation::get()) },
|
||||
Asset { fun: Fungible(UNITS), id: AssetId(TokenLocation::get()) },
|
||||
));
|
||||
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
|
||||
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
|
||||
pub const TrustedReserve: Option<(Location, Asset)> = None;
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||
@@ -1177,9 +1177,9 @@ impl_runtime_apis! {
|
||||
type TrustedTeleporter = TrustedTeleporter;
|
||||
type TrustedReserve = TrustedReserve;
|
||||
|
||||
fn get_multi_asset() -> MultiAsset {
|
||||
MultiAsset {
|
||||
id: Concrete(TokenLocation::get()),
|
||||
fn get_asset() -> Asset {
|
||||
Asset {
|
||||
id: AssetId(TokenLocation::get()),
|
||||
fun: Fungible(UNITS),
|
||||
}
|
||||
}
|
||||
@@ -1193,35 +1193,35 @@ impl_runtime_apis! {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
|
||||
fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn universal_alias() -> Result<(MultiLocation, Junction), BenchmarkError> {
|
||||
fn universal_alias() -> Result<(Location, Junction), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
|
||||
fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> {
|
||||
Ok((TokenLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
fn subscribe_origin() -> Result<Location, BenchmarkError> {
|
||||
Ok(TokenLocation::get())
|
||||
}
|
||||
|
||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
||||
fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> {
|
||||
let origin = TokenLocation::get();
|
||||
let assets: MultiAssets = (Concrete(TokenLocation::get()), 1_000 * UNITS).into();
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
let assets: Assets = (AssetId(TokenLocation::get()), 1_000 * UNITS).into();
|
||||
let ticket = Location { parents: 0, interior: Here };
|
||||
Ok((origin, ticket, assets))
|
||||
}
|
||||
|
||||
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
|
||||
fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
|
||||
fn export_message_origin_and_destination(
|
||||
) -> Result<(MultiLocation, NetworkId, InteriorMultiLocation), BenchmarkError> {
|
||||
) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> {
|
||||
// save XCM version for remote bridge hub
|
||||
let _ = PolkadotXcm::force_xcm_version(
|
||||
RuntimeOrigin::root(),
|
||||
@@ -1241,12 +1241,12 @@ impl_runtime_apis! {
|
||||
(
|
||||
bridge_to_westend_config::FromAssetHubRococoToAssetHubWestendRoute::get().location,
|
||||
NetworkId::Westend,
|
||||
X1(Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into()))
|
||||
[Parachain(bridge_to_westend_config::AssetHubWestendParaId::get().into())].into()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fn alias_origin() -> Result<(MultiLocation, MultiLocation), BenchmarkError> {
|
||||
fn alias_origin() -> Result<(Location, Location), BenchmarkError> {
|
||||
Err(BenchmarkError::Skip)
|
||||
}
|
||||
}
|
||||
@@ -1296,7 +1296,7 @@ impl_runtime_apis! {
|
||||
Runtime,
|
||||
bridge_common_config::BridgeGrandpaWestendInstance,
|
||||
bridge_to_westend_config::WithBridgeHubWestendMessageBridge,
|
||||
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(Rococo), Parachain(42))))
|
||||
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Rococo), Parachain(42)].into()))
|
||||
}
|
||||
|
||||
fn prepare_message_delivery_proof(
|
||||
@@ -1331,7 +1331,7 @@ impl_runtime_apis! {
|
||||
Runtime,
|
||||
bridge_common_config::BridgeGrandpaRococoBulletinInstance,
|
||||
bridge_to_bulletin_config::WithRococoBulletinMessageBridge,
|
||||
>(params, generate_xcm_builder_bridge_message_sample(X2(GlobalConsensus(Rococo), Parachain(42))))
|
||||
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Rococo), Parachain(42)].into()))
|
||||
}
|
||||
|
||||
fn prepare_message_delivery_proof(
|
||||
|
||||
@@ -24,14 +24,14 @@ use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
|
||||
trait WeighAssets {
|
||||
fn weigh_assets(&self, weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
const MAX_ASSETS: u64 = 100;
|
||||
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
impl WeighAssets for AssetFilter {
|
||||
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
|
||||
Self::Wild(asset) => match asset {
|
||||
@@ -50,40 +50,36 @@ impl WeighMultiAssets for MultiAssetFilter {
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
|
||||
impl WeighAssets for Assets {
|
||||
fn weigh_assets(&self, weight: Weight) -> Weight {
|
||||
weight.saturating_mul(self.inner().iter().count() as u64)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BridgeHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
fn withdraw_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
|
||||
}
|
||||
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
||||
fn reserve_asset_deposited(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
|
||||
}
|
||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
fn receive_teleported_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
|
||||
}
|
||||
fn query_response(
|
||||
_query_id: &u64,
|
||||
_response: &Response,
|
||||
_max_weight: &Weight,
|
||||
_querier: &Option<MultiLocation>,
|
||||
_querier: &Option<Location>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_response()
|
||||
}
|
||||
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
@@ -111,44 +107,36 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
|
||||
fn descend_origin(_who: &InteriorLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin()
|
||||
}
|
||||
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
|
||||
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
||||
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
|
||||
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
assets: &AssetFilter,
|
||||
_reserve: &Location,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
|
||||
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
|
||||
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> Weight {
|
||||
@@ -163,7 +151,7 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset()
|
||||
}
|
||||
fn trap(_code: &u64) -> Weight {
|
||||
@@ -175,13 +163,13 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
fn burn_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
fn burn_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
|
||||
}
|
||||
fn expect_asset(assets: &MultiAssets) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
fn expect_asset(assets: &Assets) -> Weight {
|
||||
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
|
||||
}
|
||||
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
|
||||
fn expect_origin(_origin: &Option<Location>) -> Weight {
|
||||
XcmGeneric::<Runtime>::expect_origin()
|
||||
}
|
||||
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
|
||||
@@ -215,16 +203,16 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
let inner_encoded_len = inner.encode().len() as u32;
|
||||
XcmGeneric::<Runtime>::export_message(inner_encoded_len)
|
||||
}
|
||||
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn lock_asset(_: &Asset, _: &Location) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn unlock_asset(_: &Asset, _: &Location) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn note_unlockable(_: &Asset, _: &Location) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
|
||||
fn request_unlock(_: &Asset, _: &Location) -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_fees_mode(_: &bool) -> Weight {
|
||||
@@ -236,11 +224,11 @@ impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<Call> {
|
||||
fn clear_topic() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_topic()
|
||||
}
|
||||
fn alias_origin(_: &MultiLocation) -> Weight {
|
||||
fn alias_origin(_: &Location) -> Weight {
|
||||
// XCM Executor does not currently support alias origin operations
|
||||
Weight::MAX
|
||||
}
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
|
||||
fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
|
||||
XcmGeneric::<Runtime>::unpaid_execution()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ use bp_messages::LaneId;
|
||||
use bp_relayers::{PayRewardFromAccount, RewardsAccountOwner, RewardsAccountParams};
|
||||
use bp_runtime::ChainId;
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
parameter_types,
|
||||
traits::{ConstU32, Contains, Equals, Everything, Nothing},
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
@@ -69,19 +69,19 @@ use xcm_executor::{
|
||||
};
|
||||
|
||||
parameter_types! {
|
||||
pub const TokenLocation: MultiLocation = MultiLocation::parent();
|
||||
pub const TokenLocation: Location = Location::parent();
|
||||
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
|
||||
pub RelayNetwork: NetworkId = NetworkId::Rococo;
|
||||
pub UniversalLocation: InteriorMultiLocation =
|
||||
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
|
||||
pub UniversalLocation: InteriorLocation =
|
||||
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into();
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
pub const MaxAssetsIntoHolding: u32 = 64;
|
||||
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
|
||||
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||
pub SiblingPeople: MultiLocation = (Parent, Parachain(rococo_runtime_constants::system_parachain::PEOPLE_ID)).into();
|
||||
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
|
||||
pub SiblingPeople: Location = (Parent, Parachain(rococo_runtime_constants::system_parachain::PEOPLE_ID)).into();
|
||||
}
|
||||
|
||||
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
|
||||
/// 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 = (
|
||||
@@ -100,7 +100,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
|
||||
Balances,
|
||||
// Use this currency when it is a fungible asset matching the given location or name:
|
||||
IsConcrete<TokenLocation>,
|
||||
// Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:
|
||||
// Do a simple punn to convert an AccountId32 Location into a native chain account ID:
|
||||
LocationToAccountId,
|
||||
// Our chain's account ID type (we can't get away without mentioning it explicitly):
|
||||
AccountId,
|
||||
@@ -132,11 +132,11 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
XcmPassthrough<RuntimeOrigin>,
|
||||
);
|
||||
|
||||
match_types! {
|
||||
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
|
||||
MultiLocation { parents: 1, interior: Here } |
|
||||
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
|
||||
};
|
||||
pub struct ParentOrParentsPlurality;
|
||||
impl Contains<Location> for ParentOrParentsPlurality {
|
||||
fn contains(location: &Location) -> bool {
|
||||
matches!(location.unpack(), (1, []) | (1, [Plurality { .. }]))
|
||||
}
|
||||
}
|
||||
|
||||
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
|
||||
@@ -331,7 +331,7 @@ impl xcm_executor::Config for XcmConfig {
|
||||
pub type PriceForParentDelivery =
|
||||
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, ParachainSystem>;
|
||||
|
||||
/// Converts a local signed origin into an XCM multilocation.
|
||||
/// Converts a local signed origin into an XCM location.
|
||||
/// Forms the basis for local origins sending/executing XCMs.
|
||||
pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
|
||||
|
||||
@@ -407,14 +407,10 @@ impl<
|
||||
BridgeLaneId,
|
||||
>
|
||||
{
|
||||
fn handle_fee(
|
||||
fee: MultiAssets,
|
||||
maybe_context: Option<&XcmContext>,
|
||||
reason: FeeReason,
|
||||
) -> MultiAssets {
|
||||
fn handle_fee(fee: Assets, maybe_context: Option<&XcmContext>, reason: FeeReason) -> Assets {
|
||||
if matches!(reason, FeeReason::Export { network: bridged_network, destination }
|
||||
if bridged_network == DestNetwork::get() &&
|
||||
destination == X1(Parachain(DestParaId::get().into())))
|
||||
destination == [Parachain(DestParaId::get().into())])
|
||||
{
|
||||
// We have 2 relayer rewards accounts:
|
||||
// - the SA of the source parachain on this BH: this pays the relayers for delivering
|
||||
@@ -445,14 +441,14 @@ impl<
|
||||
Fungible(total_fee) => {
|
||||
let source_fee = total_fee / 2;
|
||||
deposit_or_burn_fee::<AssetTransactor, _>(
|
||||
MultiAsset { id: asset.id, fun: Fungible(source_fee) }.into(),
|
||||
Asset { id: asset.id.clone(), fun: Fungible(source_fee) }.into(),
|
||||
maybe_context,
|
||||
source_para_account.clone(),
|
||||
);
|
||||
|
||||
let dest_fee = total_fee - source_fee;
|
||||
deposit_or_burn_fee::<AssetTransactor, _>(
|
||||
MultiAsset { id: asset.id, fun: Fungible(dest_fee) }.into(),
|
||||
Asset { id: asset.id, fun: Fungible(dest_fee) }.into(),
|
||||
maybe_context,
|
||||
dest_para_account.clone(),
|
||||
);
|
||||
@@ -467,7 +463,7 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
return MultiAssets::new()
|
||||
return Assets::new()
|
||||
}
|
||||
|
||||
fee
|
||||
@@ -477,10 +473,10 @@ impl<
|
||||
pub struct XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, HandleFee>(
|
||||
PhantomData<(WaivedLocations, HandleFee)>,
|
||||
);
|
||||
impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
|
||||
impl<WaivedLocations: Contains<Location>, FeeHandler: HandleFee> FeeManager
|
||||
for XcmFeeManagerFromComponentsBridgeHub<WaivedLocations, FeeHandler>
|
||||
{
|
||||
fn is_waived(origin: Option<&MultiLocation>, fee_reason: FeeReason) -> bool {
|
||||
fn is_waived(origin: Option<&Location>, fee_reason: FeeReason) -> bool {
|
||||
let Some(loc) = origin else { return false };
|
||||
if let Export { network, destination: Here } = fee_reason {
|
||||
return !(network == EthereumNetwork::get())
|
||||
@@ -488,7 +484,7 @@ impl<WaivedLocations: Contains<MultiLocation>, FeeHandler: HandleFee> FeeManager
|
||||
WaivedLocations::contains(loc)
|
||||
}
|
||||
|
||||
fn handle_fee(fee: MultiAssets, context: Option<&XcmContext>, reason: FeeReason) {
|
||||
fn handle_fee(fee: Assets, context: Option<&XcmContext>, reason: FeeReason) {
|
||||
FeeHandler::handle_fee(fee, context, reason);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user